impaktapps-ui-builder 0.0.382-alpha.61 → 0.0.382-alpha.62

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.
@@ -6,3 +6,4 @@ export declare function buildApiPayload(compConfig: any, body: any, headers: any
6
6
  headers: any;
7
7
  }>;
8
8
  export declare function getRefreshElements(eventConfig: any, eventGropus: any): string[];
9
+ export declare function asyncOperation(): Promise<unknown>;
@@ -8,4 +8,5 @@ export interface handlersProps {
8
8
  serviceHolder: any;
9
9
  eventGroups?: any;
10
10
  parentEventOutput?: any;
11
+ functionsProvider?: Record<string, any>;
11
12
  }
@@ -7,19 +7,21 @@ interface funcParamsProps {
7
7
  schema: any;
8
8
  service: any;
9
9
  userValue: any;
10
+ functionsProvider?: Record<string, any>;
10
11
  }
11
12
  declare const _default: (funcParams: funcParamsProps) => {
12
13
  setPage: () => Promise<void>;
13
14
  onClick: () => Promise<void>;
15
+ onMount: () => Promise<void>;
14
16
  onFileDownload: () => Promise<void>;
15
17
  onFileUpload: () => Promise<void>;
18
+ backHandler: () => void;
16
19
  onPaginationChange: (paginationValues: any) => Promise<any>;
17
20
  getSelectOptions: (param: any) => Promise<any>;
18
21
  onChange: () => Promise<void>;
19
22
  updateConfigApiBody: (paramValue: any, apiBody: any) => Promise<any>;
20
23
  onBack: (functionParameters: any) => Promise<void>;
21
24
  onNext: (functionParameters: any) => Promise<void>;
22
- backHandler: () => void;
23
25
  onReset: (functionParameters: any) => Promise<void>;
24
26
  callHandler: (eventType: string, functionParameters?: any) => Promise<void>;
25
27
  downloadFile: (obj: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.382-alpha.61",
3
+ "version": "0.0.382-alpha.62",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -1,3 +1,242 @@
1
+ // import _, { cloneDeep } from "lodash";
2
+ // import { handlersProps } from "./interface";
3
+
4
+
5
+ // export const executeEvents = async (
6
+ // params: handlersProps
7
+ // ) => {
8
+ // let nextEvent = [];
9
+ // let finalResponse = null;
10
+ // try {
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;
17
+ // const SuccessEvent = params.config?.events.filter(e => e.eventType === "Success");
18
+ // nextEvent = SuccessEvent;
19
+ // } catch (err) {
20
+ // const FailEvent = params.config?.events?.filter(e => e.eventType === "Fail")
21
+ // const setEvent = FailEvent?.length > 0 ? FailEvent : []
22
+ // nextEvent = setEvent;
23
+ // }
24
+ // if (nextEvent?.length > 0) {
25
+ // for (const actionConfig of nextEvent) {
26
+ // await executeEvents({ ...params, config: actionConfig, parentEventOutput: finalResponse })
27
+ // }
28
+ // }
29
+ // return finalResponse;
30
+ // }
31
+
32
+ // async function executeEventsHandler(params: handlersProps) {
33
+ // if (params.config.Handler === "api") {
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()
58
+ // }
59
+ // }
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 });
65
+ // }
66
+ // }
67
+ // }
68
+ // async function executeApiEventHandler(params: handlersProps) {
69
+ // const initialBody = { ...params.userValue?.payload };
70
+ // const initialHeaders = {
71
+ // "X-Requested-With": "XMLHttpRequest",
72
+ // "Access-Control-Allow-Origin": "*"
73
+ // };
74
+ // const { body, headers } = await buildApiPayload(params.config, initialBody, initialHeaders, params.store, params.dynamicData, params.userValue, params.service)
75
+
76
+ // const response = await params.service[params.config.method](
77
+ // params.config.path,
78
+ // body,
79
+ // headers && { headers: headers }
80
+ // );
81
+ // return response;
82
+ // }
83
+
84
+ // async function executeInBuiltFunctionHandler(params: handlersProps) {
85
+ // let parameter = {};
86
+ // if (params.config.funcParametersCode) {
87
+ // const makeFunc = eval(params.config.funcParametersCode)
88
+ // parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
89
+ // }
90
+ // params.serviceHolder[params.config.inBuiltFunctionType](parameter)
91
+ // }
92
+
93
+ // async function executeCustomHandler(params: handlersProps) {
94
+ // const makeFunc = eval(params.config.eventCode)
95
+ // const response = await makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.componentName);
96
+ // return response;
97
+ // }
98
+
99
+ // async function mergeFormdata(handlerResponse: any, componentName: string, eventConfig: any, store: any, service: any) {
100
+ // if (eventConfig.type === "Select" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
101
+ // store.setSchema((pre) => {
102
+ // return {
103
+ // ...pre, properties: {
104
+ // ...pre.properties, [componentName]: {
105
+ // ...pre.properties?.[componentName],
106
+ // oneOf: handlerResponse.data
107
+ // }
108
+ // }
109
+ // }
110
+ // })
111
+ // }
112
+ // else if (eventConfig.type === "MultipleSelect" && !(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
113
+ // store.setSchema((pre) => {
114
+ // return {
115
+ // ...pre, properties: {
116
+ // ...pre.properties, [componentName]: {
117
+ // ...pre.properties?.[componentName],
118
+ // type: "array",
119
+ // items: {
120
+ // oneOf: handlerResponse?.data
121
+ // }
122
+ // }
123
+ // }
124
+ // }
125
+ // })
126
+ // }
127
+ // else if (eventConfig.type === "page") {
128
+ // if (!(_.isEmpty(handlerResponse?.data) && handlerResponse?.data)) {
129
+ // store.setFormdata((pre: any) => { return { ...pre, ...handlerResponse?.data } })
130
+ // }
131
+ // }
132
+ // else {
133
+ // if (handlerResponse) {
134
+ // store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse.data.data : handlerResponse.data } });
135
+ // const demoData = await asyncOperation();
136
+ // }
137
+ // }
138
+ // }
139
+
140
+ // const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
141
+ // const finalBody = { ...userValue?.payload };
142
+ // body.map((elem) => {
143
+ // if (typeof elem?.value !== "string") {
144
+ // finalBody[elem.key] = elem.value;
145
+ // } else {
146
+ // if (elem?.value?.startsWith("$userValue")) {
147
+ // const finalpath = elem.value.substring(11);
148
+ // finalBody[elem.key] = _.get(userValue, finalpath);;
149
+ // }
150
+ // else if (elem?.value?.startsWith("$")) {
151
+ // const finalpath = elem.value.substring(1);
152
+ // finalBody[elem.key] = _.get(formData, finalpath);;
153
+ // } else {
154
+ // finalBody[elem.key] = elem.value;
155
+ // }
156
+ // }
157
+ // })
158
+ // return finalBody;
159
+ // }
160
+
161
+ // const buildHeadersFormat = (headers: any[]) => {
162
+ // const headerObj = {
163
+ // // "Content-Type": "application/json",
164
+ // "X-Requested-With": "XMLHttpRequest"
165
+ // }
166
+ // headers.map((elem) => {
167
+ // headerObj[elem.key] = elem.value;
168
+ // })
169
+ // return headerObj;
170
+ // }
171
+
172
+ // async function shouldEventExecute(params: handlersProps) {
173
+ // const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
174
+ // if (startEvent?.length > 0) {
175
+ // const response = await executeEventsHandler({ ...params, config: startEvent[0] });
176
+ // return response;
177
+ // } else {
178
+ // return true
179
+ // }
180
+ // }
181
+
182
+ // export async function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service) {
183
+ // if (compConfig?.headers) {
184
+ // headers = buildHeadersFormat(compConfig.headers)
185
+
186
+ // }
187
+ // if (compConfig.body) {
188
+ // body = { ...buildBodyFormat(compConfig.body, store.newData || store?.ctx?.core?.data || store.formData, userValue) };
189
+ // }
190
+ // if (compConfig.apiBody) {
191
+ // const makeFunc = eval(compConfig.apiBody);
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
+ // })
204
+
205
+ // } else {
206
+ // if (eventGropus?.onLoad) {
207
+ // result = Object.keys(eventGropus?.onLoad)
208
+ // result.push(result[0]);
209
+ // }
210
+ // }
211
+ // console.log(result);
212
+ // return result;
213
+ // }
214
+
215
+
216
+ // 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
+ // });
226
+ // }
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
1
240
  import _, { cloneDeep } from "lodash";
2
241
  import { handlersProps } from "./interface";
3
242
 
@@ -86,8 +325,10 @@ async function executeInBuiltFunctionHandler(params: handlersProps) {
86
325
  if (params.config.funcParametersCode) {
87
326
  const makeFunc = eval(params.config.funcParametersCode)
88
327
  parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
328
+ params.serviceHolder[params.config.inBuiltFunctionType](parameter, params.service)
329
+ } else {
330
+ params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service)
89
331
  }
90
- params.serviceHolder[params.config.inBuiltFunctionType](parameter)
91
332
  }
92
333
 
93
334
  async function executeCustomHandler(params: handlersProps) {
@@ -131,14 +372,14 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
131
372
  }
132
373
  else {
133
374
  if (handlerResponse) {
134
- store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse.data.data : handlerResponse.data } });
375
+ store.setFormdata((pre) => { return { ...pre, [componentName]: eventConfig.lazyLoading ? handlerResponse?.data?.data : handlerResponse.data } });
135
376
  const demoData = await asyncOperation();
136
377
  }
137
378
  }
138
379
  }
139
380
 
140
381
  const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
141
- const finalBody = { ...userValue?.payload };
382
+ let finalBody = { ...userValue?.payload };
142
383
  body.map((elem) => {
143
384
  if (typeof elem?.value !== "string") {
144
385
  finalBody[elem.key] = elem.value;
@@ -150,7 +391,12 @@ const buildBodyFormat = (body: any[], formData: any, userValue: any) => {
150
391
  else if (elem?.value?.startsWith("$")) {
151
392
  const finalpath = elem.value.substring(1);
152
393
  finalBody[elem.key] = _.get(formData, finalpath);;
153
- } else {
394
+ } else if (elem?.value === "*" && elem?.key === "*") {
395
+ finalBody = { ...finalBody, ...formData };
396
+ } else if (elem?.value === "*") {
397
+ finalBody[elem.key] = formData;
398
+ }
399
+ else {
154
400
  finalBody[elem.key] = elem.value;
155
401
  }
156
402
  }
@@ -213,7 +459,7 @@ export function getRefreshElements(eventConfig: any, eventGropus: any) {
213
459
  }
214
460
 
215
461
 
216
- function asyncOperation() {
462
+ export function asyncOperation() {
217
463
  return new Promise((resolve, reject) => {
218
464
  setTimeout(() => {
219
465
  const success = true;
@@ -223,4 +469,4 @@ function asyncOperation() {
223
469
  }
224
470
  }, 50);
225
471
  });
226
- }
472
+ }
@@ -1,11 +1,24 @@
1
+ // export interface handlersProps {
2
+ // config: any,
3
+ // componentName: string,
4
+ // store: any,
5
+ // dynamicData: any,
6
+ // userValue: any,
7
+ // service: any,
8
+ // serviceHolder: any,
9
+ // eventGroups?: any,
10
+ // parentEventOutput?: any
11
+ // }
12
+
1
13
  export interface handlersProps {
2
- config: any,
3
- componentName: string,
4
- store: any,
5
- dynamicData: any,
6
- userValue: any,
7
- service: any,
8
- serviceHolder: any,
9
- eventGroups?: any,
10
- parentEventOutput?: any
14
+ config: any,
15
+ componentName: string,
16
+ store: any,
17
+ dynamicData: any,
18
+ userValue: any,
19
+ service: any,
20
+ serviceHolder: any,
21
+ eventGroups?: any,
22
+ parentEventOutput?: any,
23
+ functionsProvider?:Record<string,any>
11
24
  }