@pxp-nd/flow 1.0.24 → 1.0.25

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.
@@ -35,8 +35,22 @@ let Flow = class Flow extends core_1.Controller {
35
35
  const nodes = await Node_1.default.find({ flowId: params.flowId });
36
36
  const restNodes = [];
37
37
  for (let node of nodes) {
38
+ const { actionConfigJson, action: { actionType: { schemaJson } } } = node;
39
+ const actionConfigJsonObject = actionConfigJson ? JSON.parse(actionConfigJson) : {};
40
+ const schemaJsonObject = schemaJson ? JSON.parse(schemaJson) : {};
41
+ const valuesForShowingInNode = {};
42
+ Object.entries(schemaJsonObject).filter(([n, sjo]) => sjo.showInNode === true).forEach(([nameKey, json]) => {
43
+ valuesForShowingInNode[nameKey] = {
44
+ label: json.label,
45
+ value: actionConfigJsonObject[nameKey] || null
46
+ };
47
+ });
48
+ const nodeRow = {
49
+ ...node,
50
+ valuesForShowingInNode
51
+ };
38
52
  const connections = await NodeConnection_1.default.find({ nodeIdMaster: node.nodeId });
39
- restNodes.push({ node, connections: connections.map(c => c.nodeIdChild) });
53
+ restNodes.push({ node: nodeRow, connections: connections.map(c => c.nodeIdChild) });
40
54
  }
41
55
  return restNodes;
42
56
  }
@@ -82,7 +82,7 @@ let Node = class Node extends core_1.Controller {
82
82
  }
83
83
  async getParameterizedNode(params, manager) {
84
84
  lodash_1.default.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
85
- const { nodeId, flowId, substitutionsSchemaJson } = params;
85
+ const { nodeId, flowId, substitutionsSchemaJson = {} } = params;
86
86
  const tNodeOrigin = await core_1.__(Node_1.default.findOne({
87
87
  relations: ['action'],
88
88
  where: {
@@ -128,11 +128,20 @@ let Node = class Node extends core_1.Controller {
128
128
  metadata: found
129
129
  };
130
130
  };
131
+ const findFieldMapUniqueByType = (fieldMappingType) => {
132
+ const filtered = fieldMapData.filter((fmd) => fmd.type === fieldMappingType);
133
+ if (filtered && filtered.length === 1) {
134
+ const [found] = filtered;
135
+ return {
136
+ initialValue: found.alias,
137
+ metadata: found
138
+ };
139
+ }
140
+ return undefined;
141
+ };
131
142
  // this logic is for autocomplete for moment
132
143
  const findFieldInConfigForComponent = async (json, value) => {
133
- console.log('json', json);
134
144
  if (json.formComponent && json.formComponent.type === 'AutoComplete') {
135
- console.log('json.formComponent', json.formComponent.store);
136
145
  const url = json.formComponent.store.axios.url;
137
146
  const method = json.formComponent.store.axios.method;
138
147
  const data = json.formComponent.store.axios.data;
@@ -150,20 +159,34 @@ let Node = class Node extends core_1.Controller {
150
159
  [idDD]: value
151
160
  }
152
161
  };
153
- console.log('config', config);
154
162
  // @ts-ignore
155
163
  const resControllerAxios = await core_1.__(axios_1.default(config));
156
- console.log('resControllerAxios', resControllerAxios.data.data);
157
- console.log('resControllerAxios', resControllerAxios.data.data[descDD]);
158
164
  const desc = resControllerAxios.data.data[descDD];
159
165
  return desc;
160
166
  }
167
+ else if (json.formComponentTemplate && json.configGetDescValue) { // todo we need to see how works here
168
+ const { controller, storeId, descColumn } = json.configGetDescValue;
169
+ const config = {
170
+ method: "get",
171
+ url: `http://localhost:${process.env.PORT}/api/${controller}`,
172
+ headers: {
173
+ 'Authorization': '' + process.env.TOKEN_PXP_ND + '',
174
+ 'Content-Type': 'application/json'
175
+ },
176
+ data: {
177
+ [storeId]: value
178
+ }
179
+ };
180
+ // @ts-ignore
181
+ const resControllerAxios = await core_1.__(axios_1.default(config));
182
+ const desc = resControllerAxios.data.data[descColumn];
183
+ return desc;
184
+ }
161
185
  return undefined;
162
186
  };
163
187
  for (const [nameKey, value] of Object.entries(mergeValues)) {
164
188
  if (schemaJsonObject[nameKey]) {
165
189
  const descValue = await core_1.__(findFieldInConfigForComponent(schemaJsonObject[nameKey], value));
166
- console.log('descValue', descValue);
167
190
  schemaJsonObject[nameKey] = {
168
191
  ...schemaJsonObject[nameKey],
169
192
  initialValue: value,
@@ -172,6 +195,15 @@ let Node = class Node extends core_1.Controller {
172
195
  };
173
196
  }
174
197
  }
198
+ Object.entries(schemaJsonObject)
199
+ .filter(([, value]) => value.initialValue === undefined && value.fromFieldMap === undefined && value.fieldMappingType)
200
+ .forEach(([nameKey]) => {
201
+ const hasUniqueByTypeInMappingData = findFieldMapUniqueByType(schemaJsonObject[nameKey].fieldMappingType);
202
+ schemaJsonObject[nameKey] = {
203
+ ...schemaJsonObject[nameKey],
204
+ ...(hasUniqueByTypeInMappingData && { fromFieldMap: true, ...hasUniqueByTypeInMappingData }),
205
+ };
206
+ });
175
207
  return {
176
208
  actionConfigJsonObject,
177
209
  configJsonTemplateObject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",