@pxp-nd/flow 1.0.24 → 1.0.26
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/README.md +1 -1
- package/dist/controllers/Action.d.ts +20 -20
- package/dist/controllers/Action.js +82 -82
- package/dist/controllers/ActionType.d.ts +17 -17
- package/dist/controllers/ActionType.js +28 -28
- package/dist/controllers/Event.d.ts +17 -17
- package/dist/controllers/Event.js +28 -28
- package/dist/controllers/FieldMap.d.ts +17 -17
- package/dist/controllers/FieldMap.js +28 -28
- package/dist/controllers/Flow.d.ts +24 -24
- package/dist/controllers/Flow.js +116 -102
- package/dist/controllers/FlowInstance.d.ts +20 -20
- package/dist/controllers/FlowInstance.js +78 -78
- package/dist/controllers/Node.d.ts +23 -23
- package/dist/controllers/Node.js +273 -241
- package/dist/controllers/NodeInstance.d.ts +21 -21
- package/dist/controllers/NodeInstance.js +165 -165
- package/dist/controllers/OriginName.d.ts +17 -17
- package/dist/controllers/OriginName.js +28 -28
- package/dist/controllers/index.d.ts +11 -11
- package/dist/controllers/index.js +25 -25
- package/dist/entity/Action.d.ts +20 -20
- package/dist/entity/Action.js +85 -85
- package/dist/entity/ActionType.d.ts +16 -16
- package/dist/entity/ActionType.js +71 -71
- package/dist/entity/Event.d.ts +9 -9
- package/dist/entity/Event.js +44 -44
- package/dist/entity/FieldMap.d.ts +11 -11
- package/dist/entity/FieldMap.js +52 -52
- package/dist/entity/Flow.d.ts +14 -14
- package/dist/entity/Flow.js +60 -60
- package/dist/entity/FlowInstance.d.ts +16 -16
- package/dist/entity/FlowInstance.js +69 -69
- package/dist/entity/Node.d.ts +23 -23
- package/dist/entity/Node.js +93 -93
- package/dist/entity/NodeConnection.d.ts +10 -10
- package/dist/entity/NodeConnection.js +49 -49
- package/dist/entity/NodeInstance.d.ts +13 -13
- package/dist/entity/NodeInstance.js +58 -58
- package/dist/entity/OriginName.d.ts +9 -9
- package/dist/entity/OriginName.js +43 -43
- package/dist/entity/index.d.ts +23 -23
- package/dist/entity/index.js +27 -27
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -15
- package/dist/subscribers/Event.d.ts +21 -21
- package/dist/subscribers/Event.js +83 -83
- package/dist/subscribers/index.d.ts +3 -3
- package/dist/subscribers/index.js +6 -6
- package/package.json +45 -45
- package/tsconfig.json +29 -29
package/dist/controllers/Node.js
CHANGED
|
@@ -1,241 +1,273 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Effex 2021
|
|
4
|
-
*
|
|
5
|
-
* MIT
|
|
6
|
-
*
|
|
7
|
-
* Member Controller
|
|
8
|
-
*
|
|
9
|
-
* @summary Member Controller
|
|
10
|
-
* @author Favio Figueroa
|
|
11
|
-
*
|
|
12
|
-
* Created at : 2021-07-08 12:55:38
|
|
13
|
-
* Last modified :
|
|
14
|
-
*/
|
|
15
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
18
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
19
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
20
|
-
};
|
|
21
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
22
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
const typeorm_1 = require("typeorm");
|
|
29
|
-
const Node_1 = __importDefault(require("../entity/Node"));
|
|
30
|
-
const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
|
|
31
|
-
const core_1 = require("@pxp-nd/core");
|
|
32
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
33
|
-
const FieldMap_1 = __importDefault(require("../entity/FieldMap"));
|
|
34
|
-
const OriginName_1 = __importDefault(require("../entity/OriginName"));
|
|
35
|
-
const axios_1 = __importDefault(require("axios"));
|
|
36
|
-
let Node = class Node extends core_1.Controller {
|
|
37
|
-
async getNodeData(node, dataId, manager) {
|
|
38
|
-
const { action: { originName, originKey } } = node;
|
|
39
|
-
const executeView = `select * from ${originName} where ${originKey} = ${dataId}`;
|
|
40
|
-
const resExecuteView = await core_1.__(manager.query(executeView));
|
|
41
|
-
return JSON.stringify(resExecuteView[0]);
|
|
42
|
-
}
|
|
43
|
-
async add(params, manager) {
|
|
44
|
-
let node = new Node_1.default();
|
|
45
|
-
node.isInit = params.isInit;
|
|
46
|
-
node.isEnd = params.isEnd;
|
|
47
|
-
node.actionId = params.actionId;
|
|
48
|
-
node.flowId = params.flowId;
|
|
49
|
-
node = await manager.save(node);
|
|
50
|
-
if (params.parents) {
|
|
51
|
-
for (let parent of params.parents) {
|
|
52
|
-
const nc = await NodeConnection_1.default.find({ nodeIdMaster: parent.parentId });
|
|
53
|
-
for (let connection of nc) {
|
|
54
|
-
connection.nodeIdMaster = node.nodeId;
|
|
55
|
-
await manager.save(connection);
|
|
56
|
-
}
|
|
57
|
-
let nodeConnection = new NodeConnection_1.default();
|
|
58
|
-
nodeConnection.nodeIdChild = node.nodeId;
|
|
59
|
-
nodeConnection.nodeIdMaster = parent.parentId;
|
|
60
|
-
nodeConnection.condition = parent.condition;
|
|
61
|
-
nodeConnection = await manager.save(nodeConnection);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const { nodeId } = node;
|
|
65
|
-
const nodeData = await manager.findOne(Node_1.default, nodeId);
|
|
66
|
-
return nodeData;
|
|
67
|
-
}
|
|
68
|
-
async AddActionConfigJson(params, manager) {
|
|
69
|
-
let { nodeId: removed, __metadata: removed2, ...actionConfigJson } = params;
|
|
70
|
-
Object.entries(params.__metadata).forEach(([nameKey, values]) => {
|
|
71
|
-
actionConfigJson[nameKey] = `{{ ${values.name} }}`;
|
|
72
|
-
});
|
|
73
|
-
const upd = await core_1.__(manager.update(Node_1.default, params.nodeId, {
|
|
74
|
-
actionConfigJson: JSON.stringify(actionConfigJson),
|
|
75
|
-
}));
|
|
76
|
-
return {
|
|
77
|
-
actionConfigJson,
|
|
78
|
-
success: true,
|
|
79
|
-
nodeId: params.nodeId,
|
|
80
|
-
upd
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
async getParameterizedNode(params, manager) {
|
|
84
|
-
lodash_1.default.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
85
|
-
const { nodeId, flowId, substitutionsSchemaJson } = params;
|
|
86
|
-
const tNodeOrigin = await core_1.__(Node_1.default.findOne({
|
|
87
|
-
relations: ['action'],
|
|
88
|
-
where: {
|
|
89
|
-
flowId: flowId,
|
|
90
|
-
isInit: 'Y',
|
|
91
|
-
action: {
|
|
92
|
-
originName: typeorm_1.Not(typeorm_1.IsNull())
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
|
-
const tNodeData = core_1.__(Node_1.default.findOne(nodeId));
|
|
97
|
-
const tFieldMapData = core_1.__(manager.createQueryBuilder(FieldMap_1.default, 'fm')
|
|
98
|
-
.innerJoin(OriginName_1.default, 'on', 'on.originNameId = fm.originNameId')
|
|
99
|
-
.where("on.name = :n ", { n: tNodeOrigin.action.originName })
|
|
100
|
-
.getMany());
|
|
101
|
-
//const nodeOrigin = await tNodeOrigin; todo
|
|
102
|
-
const nodeData = await tNodeData;
|
|
103
|
-
const fieldMapData = await tFieldMapData;
|
|
104
|
-
/*const [nodeData, fieldMapData] = await Promise.all([
|
|
105
|
-
tNodeData,
|
|
106
|
-
tFieldMapData
|
|
107
|
-
]);*/
|
|
108
|
-
const { actionConfigJson, action: { schemaJson, configJsonTemplate, actionType: { schemaJson: schemaJsonFromActionType } } } = nodeData;
|
|
109
|
-
const actionConfigJsonObject = actionConfigJson ? JSON.parse(actionConfigJson) : {};
|
|
110
|
-
const configJsonTemplateObject = configJsonTemplate ? JSON.parse(configJsonTemplate) : {};
|
|
111
|
-
let schemaJsonFromActionTypeObject = schemaJsonFromActionType ? JSON.parse(lodash_1.default.template(schemaJsonFromActionType)(substitutionsSchemaJson)) : {};
|
|
112
|
-
let schemaJsonFromActionObject = schemaJson ? JSON.parse(lodash_1.default.template(schemaJson)(substitutionsSchemaJson)) : {};
|
|
113
|
-
let schemaJsonObject = { ...schemaJsonFromActionTypeObject, ...schemaJsonFromActionObject };
|
|
114
|
-
const mergeValues = {
|
|
115
|
-
...configJsonTemplateObject,
|
|
116
|
-
...actionConfigJsonObject
|
|
117
|
-
};
|
|
118
|
-
const verifyIfValueFromFieldMap = (str) => {
|
|
119
|
-
if (/^{{/.test(str) && /}}$/.test(str)) {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
};
|
|
124
|
-
const findFieldMapAndMetaData = (value) => {
|
|
125
|
-
const found = fieldMapData.find((fmd) => `{{ ${fmd.name} }}` === value) || {};
|
|
126
|
-
return {
|
|
127
|
-
initialValue: found.alias || value,
|
|
128
|
-
metadata: found
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Effex 2021
|
|
4
|
+
*
|
|
5
|
+
* MIT
|
|
6
|
+
*
|
|
7
|
+
* Member Controller
|
|
8
|
+
*
|
|
9
|
+
* @summary Member Controller
|
|
10
|
+
* @author Favio Figueroa
|
|
11
|
+
*
|
|
12
|
+
* Created at : 2021-07-08 12:55:38
|
|
13
|
+
* Last modified :
|
|
14
|
+
*/
|
|
15
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
16
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
18
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
19
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
20
|
+
};
|
|
21
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
const typeorm_1 = require("typeorm");
|
|
29
|
+
const Node_1 = __importDefault(require("../entity/Node"));
|
|
30
|
+
const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
|
|
31
|
+
const core_1 = require("@pxp-nd/core");
|
|
32
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
33
|
+
const FieldMap_1 = __importDefault(require("../entity/FieldMap"));
|
|
34
|
+
const OriginName_1 = __importDefault(require("../entity/OriginName"));
|
|
35
|
+
const axios_1 = __importDefault(require("axios"));
|
|
36
|
+
let Node = class Node extends core_1.Controller {
|
|
37
|
+
async getNodeData(node, dataId, manager) {
|
|
38
|
+
const { action: { originName, originKey } } = node;
|
|
39
|
+
const executeView = `select * from ${originName} where ${originKey} = ${dataId}`;
|
|
40
|
+
const resExecuteView = await core_1.__(manager.query(executeView));
|
|
41
|
+
return JSON.stringify(resExecuteView[0]);
|
|
42
|
+
}
|
|
43
|
+
async add(params, manager) {
|
|
44
|
+
let node = new Node_1.default();
|
|
45
|
+
node.isInit = params.isInit;
|
|
46
|
+
node.isEnd = params.isEnd;
|
|
47
|
+
node.actionId = params.actionId;
|
|
48
|
+
node.flowId = params.flowId;
|
|
49
|
+
node = await manager.save(node);
|
|
50
|
+
if (params.parents) {
|
|
51
|
+
for (let parent of params.parents) {
|
|
52
|
+
const nc = await NodeConnection_1.default.find({ nodeIdMaster: parent.parentId });
|
|
53
|
+
for (let connection of nc) {
|
|
54
|
+
connection.nodeIdMaster = node.nodeId;
|
|
55
|
+
await manager.save(connection);
|
|
56
|
+
}
|
|
57
|
+
let nodeConnection = new NodeConnection_1.default();
|
|
58
|
+
nodeConnection.nodeIdChild = node.nodeId;
|
|
59
|
+
nodeConnection.nodeIdMaster = parent.parentId;
|
|
60
|
+
nodeConnection.condition = parent.condition;
|
|
61
|
+
nodeConnection = await manager.save(nodeConnection);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const { nodeId } = node;
|
|
65
|
+
const nodeData = await manager.findOne(Node_1.default, nodeId);
|
|
66
|
+
return nodeData;
|
|
67
|
+
}
|
|
68
|
+
async AddActionConfigJson(params, manager) {
|
|
69
|
+
let { nodeId: removed, __metadata: removed2, ...actionConfigJson } = params;
|
|
70
|
+
Object.entries(params.__metadata).forEach(([nameKey, values]) => {
|
|
71
|
+
actionConfigJson[nameKey] = `{{ ${values.name} }}`;
|
|
72
|
+
});
|
|
73
|
+
const upd = await core_1.__(manager.update(Node_1.default, params.nodeId, {
|
|
74
|
+
actionConfigJson: JSON.stringify(actionConfigJson),
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
actionConfigJson,
|
|
78
|
+
success: true,
|
|
79
|
+
nodeId: params.nodeId,
|
|
80
|
+
upd
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async getParameterizedNode(params, manager) {
|
|
84
|
+
lodash_1.default.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
85
|
+
const { nodeId, flowId, substitutionsSchemaJson = {} } = params;
|
|
86
|
+
const tNodeOrigin = await core_1.__(Node_1.default.findOne({
|
|
87
|
+
relations: ['action'],
|
|
88
|
+
where: {
|
|
89
|
+
flowId: flowId,
|
|
90
|
+
isInit: 'Y',
|
|
91
|
+
action: {
|
|
92
|
+
originName: typeorm_1.Not(typeorm_1.IsNull())
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
const tNodeData = core_1.__(Node_1.default.findOne(nodeId));
|
|
97
|
+
const tFieldMapData = core_1.__(manager.createQueryBuilder(FieldMap_1.default, 'fm')
|
|
98
|
+
.innerJoin(OriginName_1.default, 'on', 'on.originNameId = fm.originNameId')
|
|
99
|
+
.where("on.name = :n ", { n: tNodeOrigin.action.originName })
|
|
100
|
+
.getMany());
|
|
101
|
+
//const nodeOrigin = await tNodeOrigin; todo
|
|
102
|
+
const nodeData = await tNodeData;
|
|
103
|
+
const fieldMapData = await tFieldMapData;
|
|
104
|
+
/*const [nodeData, fieldMapData] = await Promise.all([
|
|
105
|
+
tNodeData,
|
|
106
|
+
tFieldMapData
|
|
107
|
+
]);*/
|
|
108
|
+
const { actionConfigJson, action: { schemaJson, configJsonTemplate, actionType: { schemaJson: schemaJsonFromActionType } } } = nodeData;
|
|
109
|
+
const actionConfigJsonObject = actionConfigJson ? JSON.parse(actionConfigJson) : {};
|
|
110
|
+
const configJsonTemplateObject = configJsonTemplate ? JSON.parse(configJsonTemplate) : {};
|
|
111
|
+
let schemaJsonFromActionTypeObject = schemaJsonFromActionType ? JSON.parse(lodash_1.default.template(schemaJsonFromActionType)(substitutionsSchemaJson)) : {};
|
|
112
|
+
let schemaJsonFromActionObject = schemaJson ? JSON.parse(lodash_1.default.template(schemaJson)(substitutionsSchemaJson)) : {};
|
|
113
|
+
let schemaJsonObject = { ...schemaJsonFromActionTypeObject, ...schemaJsonFromActionObject };
|
|
114
|
+
const mergeValues = {
|
|
115
|
+
...configJsonTemplateObject,
|
|
116
|
+
...actionConfigJsonObject
|
|
117
|
+
};
|
|
118
|
+
const verifyIfValueFromFieldMap = (str) => {
|
|
119
|
+
if (/^{{/.test(str) && /}}$/.test(str)) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
};
|
|
124
|
+
const findFieldMapAndMetaData = (value) => {
|
|
125
|
+
const found = fieldMapData.find((fmd) => `{{ ${fmd.name} }}` === value) || {};
|
|
126
|
+
return {
|
|
127
|
+
initialValue: found.alias || value,
|
|
128
|
+
metadata: found
|
|
129
|
+
};
|
|
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
|
+
};
|
|
142
|
+
// this logic is for autocomplete for moment
|
|
143
|
+
const findFieldInConfigForComponent = async (json, value) => {
|
|
144
|
+
if (json.formComponent && json.formComponent.type === 'AutoComplete') {
|
|
145
|
+
const url = json.formComponent.store.axios.url;
|
|
146
|
+
const method = json.formComponent.store.axios.method;
|
|
147
|
+
const data = json.formComponent.store.axios.data;
|
|
148
|
+
const idDD = json.formComponent.store.idDD;
|
|
149
|
+
const descDD = json.formComponent.store.descDD;
|
|
150
|
+
const config = {
|
|
151
|
+
method: method,
|
|
152
|
+
url: url,
|
|
153
|
+
headers: {
|
|
154
|
+
'Authorization': '' + process.env.TOKEN_PXP_ND + '',
|
|
155
|
+
'Content-Type': 'application/json'
|
|
156
|
+
},
|
|
157
|
+
data: {
|
|
158
|
+
...data,
|
|
159
|
+
[idDD]: value
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
const resControllerAxios = await core_1.__(axios_1.default(config));
|
|
164
|
+
const desc = resControllerAxios.data.data[descDD];
|
|
165
|
+
return desc;
|
|
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
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
};
|
|
187
|
+
for (const [nameKey, value] of Object.entries(mergeValues)) {
|
|
188
|
+
if (schemaJsonObject[nameKey]) {
|
|
189
|
+
const descValue = await core_1.__(findFieldInConfigForComponent(schemaJsonObject[nameKey], value));
|
|
190
|
+
schemaJsonObject[nameKey] = {
|
|
191
|
+
...schemaJsonObject[nameKey],
|
|
192
|
+
initialValue: value,
|
|
193
|
+
...(descValue && { descValue: descValue }),
|
|
194
|
+
...(verifyIfValueFromFieldMap(value) && { fromFieldMap: true, ...findFieldMapAndMetaData(value) }),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
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
|
+
});
|
|
207
|
+
return {
|
|
208
|
+
actionConfigJsonObject,
|
|
209
|
+
configJsonTemplateObject,
|
|
210
|
+
mergeValues,
|
|
211
|
+
schemaJsonObject,
|
|
212
|
+
schemaJson,
|
|
213
|
+
node: nodeData,
|
|
214
|
+
fieldMapData,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async executeActionJson(params, manager) {
|
|
218
|
+
const { nodeId, originName, originKey, fromValues } = params;
|
|
219
|
+
// we need to get the value from merge values with originKey
|
|
220
|
+
const getParameterizedNodeData = await core_1.__(this.getParameterizedNode({ nodeId: nodeId }, manager));
|
|
221
|
+
const { mergeValues } = getParameterizedNodeData;
|
|
222
|
+
const findOriginValue = Object.entries(mergeValues).find(([nameValue]) => fromValues === nameValue);
|
|
223
|
+
const resValueObject = Object.fromEntries([findOriginValue]);
|
|
224
|
+
const originValue = resValueObject[fromValues];
|
|
225
|
+
const executeViewString = `select * from ${originName} where ${originKey} = ${originValue}`;
|
|
226
|
+
const resExecuteView = await typeorm_1.getManager().query(executeViewString);
|
|
227
|
+
/*const executeView = `select * from ${originName} where ${originKey} = ${newEvent.dataId}`;
|
|
228
|
+
const resExecuteView = await getManager().query(executeView);*/
|
|
229
|
+
return {
|
|
230
|
+
...resExecuteView[0]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
__decorate([
|
|
235
|
+
core_1.Post(),
|
|
236
|
+
core_1.DbSettings('Orm'),
|
|
237
|
+
core_1.ReadOnly(false),
|
|
238
|
+
core_1.Log(true),
|
|
239
|
+
__metadata("design:type", Function),
|
|
240
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
241
|
+
__metadata("design:returntype", Promise)
|
|
242
|
+
], Node.prototype, "add", null);
|
|
243
|
+
__decorate([
|
|
244
|
+
core_1.Post(),
|
|
245
|
+
core_1.DbSettings('Orm'),
|
|
246
|
+
core_1.ReadOnly(false),
|
|
247
|
+
core_1.Log(true),
|
|
248
|
+
__metadata("design:type", Function),
|
|
249
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
250
|
+
__metadata("design:returntype", Promise)
|
|
251
|
+
], Node.prototype, "AddActionConfigJson", null);
|
|
252
|
+
__decorate([
|
|
253
|
+
core_1.Post(),
|
|
254
|
+
core_1.DbSettings('Orm'),
|
|
255
|
+
core_1.ReadOnly(false),
|
|
256
|
+
core_1.Log(true),
|
|
257
|
+
__metadata("design:type", Function),
|
|
258
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
259
|
+
__metadata("design:returntype", Promise)
|
|
260
|
+
], Node.prototype, "getParameterizedNode", null);
|
|
261
|
+
__decorate([
|
|
262
|
+
core_1.Post(),
|
|
263
|
+
core_1.DbSettings('Orm'),
|
|
264
|
+
core_1.ReadOnly(false),
|
|
265
|
+
core_1.Log(true),
|
|
266
|
+
__metadata("design:type", Function),
|
|
267
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
268
|
+
__metadata("design:returntype", Promise)
|
|
269
|
+
], Node.prototype, "executeActionJson", null);
|
|
270
|
+
Node = __decorate([
|
|
271
|
+
core_1.Model('flow-nd/Node')
|
|
272
|
+
], Node);
|
|
273
|
+
exports.default = Node;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kplian 2021
|
|
3
|
-
*
|
|
4
|
-
* MIT
|
|
5
|
-
*
|
|
6
|
-
* NodeInstance Controller
|
|
7
|
-
*
|
|
8
|
-
* @summary Member Controller
|
|
9
|
-
* @author Favio Figueroa
|
|
10
|
-
* Jaime Rivera
|
|
11
|
-
*
|
|
12
|
-
* Created at : 2021-07-08 12:55:38
|
|
13
|
-
* Last modified :
|
|
14
|
-
*/
|
|
15
|
-
import { EntityManager } from 'typeorm';
|
|
16
|
-
import { Controller } from '@pxp-nd/core';
|
|
17
|
-
declare class NodeInstance extends Controller {
|
|
18
|
-
RecursiveInstance(params: Record<string, any>): Promise<unknown>;
|
|
19
|
-
ProcessDelay(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
20
|
-
}
|
|
21
|
-
export default NodeInstance;
|
|
1
|
+
/**
|
|
2
|
+
* Kplian 2021
|
|
3
|
+
*
|
|
4
|
+
* MIT
|
|
5
|
+
*
|
|
6
|
+
* NodeInstance Controller
|
|
7
|
+
*
|
|
8
|
+
* @summary Member Controller
|
|
9
|
+
* @author Favio Figueroa
|
|
10
|
+
* Jaime Rivera
|
|
11
|
+
*
|
|
12
|
+
* Created at : 2021-07-08 12:55:38
|
|
13
|
+
* Last modified :
|
|
14
|
+
*/
|
|
15
|
+
import { EntityManager } from 'typeorm';
|
|
16
|
+
import { Controller } from '@pxp-nd/core';
|
|
17
|
+
declare class NodeInstance extends Controller {
|
|
18
|
+
RecursiveInstance(params: Record<string, any>): Promise<unknown>;
|
|
19
|
+
ProcessDelay(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
20
|
+
}
|
|
21
|
+
export default NodeInstance;
|