@pxp-nd/flow 1.0.42 → 1.0.45
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/dist/controllers/Action.js +10 -10
- package/dist/controllers/ActionType.js +1 -1
- package/dist/controllers/Event.js +1 -1
- package/dist/controllers/FieldMap.js +1 -1
- package/dist/controllers/Flow.d.ts +2 -1
- package/dist/controllers/Flow.js +162 -142
- package/dist/controllers/FlowInstance.js +7 -7
- package/dist/controllers/Node.js +28 -28
- package/dist/controllers/NodeInstance.js +21 -21
- package/dist/controllers/OriginName.js +1 -1
- package/dist/entity/Action.js +17 -17
- package/dist/entity/ActionType.js +13 -13
- package/dist/entity/Event.js +7 -7
- package/dist/entity/FieldMap.js +9 -9
- package/dist/entity/Flow.js +10 -10
- package/dist/entity/FlowInstance.js +13 -13
- package/dist/entity/Node.js +20 -20
- package/dist/entity/NodeConnection.js +9 -9
- package/dist/entity/NodeInstance.js +11 -11
- package/dist/entity/OriginName.js +6 -6
- package/dist/index.js +5 -1
- package/dist/subscribers/Event.js +4 -4
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ const OriginName_1 = __importDefault(require("../entity/OriginName"));
|
|
|
33
33
|
let Action = class Action extends core_1.Controller {
|
|
34
34
|
async getFieldMapByAction(params, manager) {
|
|
35
35
|
const { originName } = params;
|
|
36
|
-
const fieldMapData = await core_1.__(manager.createQueryBuilder(FieldMap_1.default, 'fm')
|
|
36
|
+
const fieldMapData = await (0, core_1.__)(manager.createQueryBuilder(FieldMap_1.default, 'fm')
|
|
37
37
|
.innerJoin(OriginName_1.default, 'on', 'on.originNameId = fm.originNameId')
|
|
38
38
|
.where("on.name = :n ", { n: originName })
|
|
39
39
|
.getMany());
|
|
@@ -59,24 +59,24 @@ let Action = class Action extends core_1.Controller {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
__decorate([
|
|
62
|
-
core_1.Get(),
|
|
63
|
-
core_1.DbSettings('Orm'),
|
|
64
|
-
core_1.ReadOnly(false),
|
|
65
|
-
core_1.Log(true),
|
|
62
|
+
(0, core_1.Get)(),
|
|
63
|
+
(0, core_1.DbSettings)('Orm'),
|
|
64
|
+
(0, core_1.ReadOnly)(false),
|
|
65
|
+
(0, core_1.Log)(true),
|
|
66
66
|
__metadata("design:type", Function),
|
|
67
67
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
68
68
|
__metadata("design:returntype", Promise)
|
|
69
69
|
], Action.prototype, "getFieldMapByAction", null);
|
|
70
70
|
__decorate([
|
|
71
|
-
core_1.Get(),
|
|
72
|
-
core_1.DbSettings('Orm'),
|
|
73
|
-
core_1.ReadOnly(true),
|
|
74
|
-
core_1.Log(true),
|
|
71
|
+
(0, core_1.Get)(),
|
|
72
|
+
(0, core_1.DbSettings)('Orm'),
|
|
73
|
+
(0, core_1.ReadOnly)(true),
|
|
74
|
+
(0, core_1.Log)(true),
|
|
75
75
|
__metadata("design:type", Function),
|
|
76
76
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
77
77
|
__metadata("design:returntype", Promise)
|
|
78
78
|
], Action.prototype, "getActions", null);
|
|
79
79
|
Action = __decorate([
|
|
80
|
-
core_1.Model('flow-nd/Action')
|
|
80
|
+
(0, core_1.Model)('flow-nd/Action')
|
|
81
81
|
], Action);
|
|
82
82
|
exports.default = Action;
|
|
@@ -23,6 +23,6 @@ const core_1 = require("@pxp-nd/core");
|
|
|
23
23
|
let ActionType = class ActionType extends core_1.Controller {
|
|
24
24
|
};
|
|
25
25
|
ActionType = __decorate([
|
|
26
|
-
core_1.Model('flow-nd/ActionType')
|
|
26
|
+
(0, core_1.Model)('flow-nd/ActionType')
|
|
27
27
|
], ActionType);
|
|
28
28
|
exports.default = ActionType;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* * -------------- ----------- -------------- ------------------------------------
|
|
11
11
|
* 08-Jul-2021 Jaime Rivera Created
|
|
12
12
|
* 18-Jul-2023 SP28JUL23 Mercedes Zambrana Add deleteFlow, saveFlowName, duplicateFlow
|
|
13
|
+
* 02-Aug-2023 SP11AUG23 Mercedes Zambrana Add validations in deleteFlow and saveFlow
|
|
13
14
|
* ******************************************************************************
|
|
14
15
|
*/
|
|
15
16
|
import { EntityManager } from 'typeorm';
|
|
@@ -24,8 +25,8 @@ declare class Flow extends Controller {
|
|
|
24
25
|
deleteFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
25
26
|
saveFlowName(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
26
27
|
duplicateFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
28
|
+
saveFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
27
29
|
getFlowRender(params: Record<string, any>): Promise<unknown>;
|
|
28
30
|
sortNodesByConnections(nodes: any[], connections: any[]): any[];
|
|
29
|
-
saveFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
30
31
|
}
|
|
31
32
|
export default Flow;
|
package/dist/controllers/Flow.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* * -------------- ----------- -------------- ------------------------------------
|
|
12
12
|
* 08-Jul-2021 Jaime Rivera Created
|
|
13
13
|
* 18-Jul-2023 SP28JUL23 Mercedes Zambrana Add deleteFlow, saveFlowName, duplicateFlow
|
|
14
|
+
* 02-Aug-2023 SP11AUG23 Mercedes Zambrana Add validations in deleteFlow and saveFlow
|
|
14
15
|
* ******************************************************************************
|
|
15
16
|
*/
|
|
16
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -57,7 +58,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
57
58
|
return restNodes;
|
|
58
59
|
}
|
|
59
60
|
async copyNodeConnections(nodeId, newNodeId, newFlowId, manager) {
|
|
60
|
-
const connections = await core_1.__(NodeConnection_1.default.find({ nodeIdMaster: nodeId }));
|
|
61
|
+
const connections = await (0, core_1.__)(NodeConnection_1.default.find({ nodeIdMaster: nodeId }));
|
|
61
62
|
for (let connection of connections) {
|
|
62
63
|
const newNodeConnection = new NodeConnection_1.default();
|
|
63
64
|
const { nodeConnectionId, nodeIdMaster, nodeIdChild, createdAt, modifiedAt, ...nodeConnectionToCopy } = connection;
|
|
@@ -65,7 +66,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
65
66
|
const dataNodeChild = await Node_1.default.findOne({ nodeId: connection.nodeIdChild });
|
|
66
67
|
const { nodeId: newNodeIdChild } = await this.copyNode(dataNodeChild, newFlowId, manager);
|
|
67
68
|
Object.assign(newNodeConnection, { ...nodeConnectionToCopy, nodeIdMaster: newNodeId, nodeIdChild: newNodeIdChild });
|
|
68
|
-
const insertNewNodeConnection = await core_1.__(manager.save(NodeConnection_1.default, newNodeConnection));
|
|
69
|
+
const insertNewNodeConnection = await (0, core_1.__)(manager.save(NodeConnection_1.default, newNodeConnection));
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
async copyNode(node, newFlowId, manager) {
|
|
@@ -73,20 +74,20 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
73
74
|
const newNode = new Node_1.default();
|
|
74
75
|
const { nodeId, flowId, createdAt, modifiedAt, actionConfigJson, ...nodeToCopy } = node;
|
|
75
76
|
Object.assign(newNode, { ...nodeToCopy, flowId: newFlowId });
|
|
76
|
-
const insertNewNode = await core_1.__(manager.save(Node_1.default, newNode));
|
|
77
|
+
const insertNewNode = await (0, core_1.__)(manager.save(Node_1.default, newNode));
|
|
77
78
|
// insert connection
|
|
78
79
|
await this.copyNodeConnections(node.nodeId, insertNewNode.nodeId, newFlowId, manager);
|
|
79
80
|
return { nodeId: insertNewNode.nodeId };
|
|
80
81
|
}
|
|
81
82
|
async createFlowFromFlow(params, manager) {
|
|
82
83
|
// we need clone the flow selected
|
|
83
|
-
const dataFlow = await core_1.__(Flow_1.default.findOne(params.flowId));
|
|
84
|
+
const dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
|
|
84
85
|
const { flowId, createdAt, modifiedAt, nodes, ...flowToCopy } = dataFlow;
|
|
85
86
|
const newFlow = new Flow_1.default();
|
|
86
87
|
Object.assign(newFlow, flowToCopy);
|
|
87
88
|
newFlow.name = params.name;
|
|
88
89
|
newFlow.description = params.description;
|
|
89
|
-
const insertNewFlow = await core_1.__(manager.save(Flow_1.default, newFlow));
|
|
90
|
+
const insertNewFlow = await (0, core_1.__)(manager.save(Flow_1.default, newFlow));
|
|
90
91
|
// create the nodes
|
|
91
92
|
// get the first node "the trigger node"
|
|
92
93
|
const dataNode = await Node_1.default.findOne({ where: { flowId: params.flowId }, order: { nodeId: "ASC" } });
|
|
@@ -94,27 +95,32 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
94
95
|
return { flowId: insertNewFlow.flowId };
|
|
95
96
|
}
|
|
96
97
|
async deleteFlow(params, manager) {
|
|
97
|
-
let dataFlow = await core_1.__(Flow_1.default.findOne(params.flowId));
|
|
98
|
+
let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
|
|
98
99
|
if (dataFlow) {
|
|
99
100
|
dataFlow.isActive = 0;
|
|
100
101
|
dataFlow.enabled = 'N';
|
|
101
|
-
const updFlow = await core_1.__(manager.save(dataFlow));
|
|
102
|
+
const updFlow = await (0, core_1.__)(manager.save(dataFlow));
|
|
102
103
|
if (updFlow) {
|
|
103
104
|
let flowInstance = `UPDATE twf_flow_instance SET
|
|
104
105
|
is_active = 'N' WHERE flow_id = ${updFlow.flowId}`;
|
|
105
106
|
await manager.query(flowInstance);
|
|
106
|
-
|
|
107
|
+
const nodesToInact = await manager.find(Node_1.default, { flowId: updFlow.flowId, isActive: true });
|
|
108
|
+
if (nodesToInact.length > 0) {
|
|
109
|
+
let flowNode = `UPDATE twf_node SET
|
|
107
110
|
is_active = 'N' WHERE flow_id = ${updFlow.flowId}`;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
await manager.query(flowNode);
|
|
112
|
+
const nodesToInact = await manager.find(Node_1.default, { flowId: updFlow.flowId });
|
|
113
|
+
const originalNodeIds = nodesToInact.map((node) => node.nodeId);
|
|
114
|
+
const connectionsToInact = await manager.find(NodeConnection_1.default, {
|
|
115
|
+
where: { nodeIdChild: (0, typeorm_1.In)(originalNodeIds) } // Suponiendo que originalNodeIds contiene los IDs de los nodos originales que deseas duplicar
|
|
116
|
+
});
|
|
117
|
+
const originalNodeCIds = connectionsToInact.map((node) => node.nodeConnectionId);
|
|
118
|
+
if (originalNodeCIds.length > 0) {
|
|
119
|
+
let flowNodeC = `UPDATE twf_node_connection SET
|
|
116
120
|
is_active = 'N' WHERE node_connection_id in ( ${originalNodeCIds})`;
|
|
117
|
-
|
|
121
|
+
await manager.query(flowNodeC);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
118
124
|
return { success: true };
|
|
119
125
|
}
|
|
120
126
|
else {
|
|
@@ -126,10 +132,10 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
async saveFlowName(params, manager) {
|
|
129
|
-
let dataFlow = await core_1.__(Flow_1.default.findOne(params.flowId));
|
|
135
|
+
let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
|
|
130
136
|
if (dataFlow) {
|
|
131
137
|
dataFlow.name = params.name;
|
|
132
|
-
const updFlow = await core_1.__(manager.save(dataFlow));
|
|
138
|
+
const updFlow = await (0, core_1.__)(manager.save(dataFlow));
|
|
133
139
|
return { success: true };
|
|
134
140
|
}
|
|
135
141
|
else {
|
|
@@ -157,7 +163,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
157
163
|
const savedNodes = await manager.save(duplicatedNodes);
|
|
158
164
|
const newNodeIds = savedNodes.map((node) => node.nodeId);
|
|
159
165
|
const connectionsToDuplicate = await manager.find(NodeConnection_1.default, {
|
|
160
|
-
where: { nodeIdChild: typeorm_1.In(originalNodeIds) }
|
|
166
|
+
where: { nodeIdChild: (0, typeorm_1.In)(originalNodeIds) }
|
|
161
167
|
});
|
|
162
168
|
const duplicatedConnections = newNodeIds.map((nodeId, index) => {
|
|
163
169
|
const duplicatedConnection = manager.create(NodeConnection_1.default, {
|
|
@@ -175,8 +181,106 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
175
181
|
return { success: false, "respuesta": "No Flow" };
|
|
176
182
|
}
|
|
177
183
|
}
|
|
184
|
+
async saveFlow(params, manager) {
|
|
185
|
+
console.log(params);
|
|
186
|
+
let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
|
|
187
|
+
console.log("nodesRef:", nodeRefIds);
|
|
188
|
+
let nodes = params.board.tasks ? params.board.tasks : [];
|
|
189
|
+
console.log("nod:", nodes);
|
|
190
|
+
let masterId = null;
|
|
191
|
+
let id = null;
|
|
192
|
+
let flowId = null;
|
|
193
|
+
let taskIds = [];
|
|
194
|
+
if (nodeRefIds.length === 0) {
|
|
195
|
+
flowId = params.board.columns['2-column-nodes-configured'].flowId;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
for (const nodeId of nodeRefIds) {
|
|
199
|
+
// console.log ('node:',nodes[`${nodeId}`]);
|
|
200
|
+
if (nodeId != 'new') {
|
|
201
|
+
id = parseInt(nodeId.split("-")[1]);
|
|
202
|
+
taskIds.push(id);
|
|
203
|
+
const connectionsToDel = await manager.find(NodeConnection_1.default, {
|
|
204
|
+
where: { nodeIdChild: id }
|
|
205
|
+
});
|
|
206
|
+
if (connectionsToDel) {
|
|
207
|
+
//console.log("hay para eliminar---->", connectionsToDel);
|
|
208
|
+
const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
|
|
209
|
+
//console.log("eliminando: ", originalNodeCIds);
|
|
210
|
+
let flowNodeC = await (0, typeorm_1.getManager)().query(`DELETE
|
|
211
|
+
from twf_node_connection
|
|
212
|
+
WHERE node_connection_id = ${originalNodeCIds}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//if (nodes[`${nodeId}`]) {
|
|
219
|
+
//flowId = nodes[`${nodeId}`].flowId;
|
|
220
|
+
if (params.board.origin == 'deleteTask') {
|
|
221
|
+
console.log("aqui elimina", params.board.deleteID);
|
|
222
|
+
let nodeDelId = parseInt(params.board.deleteId.split("-")[1]);
|
|
223
|
+
console.log(nodeDelId);
|
|
224
|
+
if (nodeDelId) {
|
|
225
|
+
//If there are some nodes in node_connections after delete all records sent, to inactive node
|
|
226
|
+
let connectNoDel = await (0, typeorm_1.getManager)().query(`SELECT n.node_id
|
|
227
|
+
from twf_node_connection nd
|
|
228
|
+
inner join twf_node n on n.node_id = nd.node_id_child
|
|
229
|
+
WHERE n.node_id = ${nodeDelId}`);
|
|
230
|
+
const currentNodesIds = connectNoDel.map((record) => record.node_id);
|
|
231
|
+
// Get nodes to remove
|
|
232
|
+
const nodesToRemove = currentNodesIds.filter((nodeId) => !taskIds.includes(nodeId.toString()));
|
|
233
|
+
// Inactive nodes
|
|
234
|
+
if (nodesToRemove.length > 0) {
|
|
235
|
+
const delNodeConnect = await manager.delete(NodeConnection_1.default, { nodeIdChild: nodesToRemove[0] });
|
|
236
|
+
if (delNodeConnect) {
|
|
237
|
+
let dNode = `UPDATE twf_node
|
|
238
|
+
SET is_active = 'N'
|
|
239
|
+
WHERE node_id = ${nodesToRemove[0]}`;
|
|
240
|
+
await manager.query(dNode);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
console.log("aqui tiene q entrar a volver a insertar");
|
|
246
|
+
//armamos las relaciones
|
|
247
|
+
if (nodeRefIds.length === 0) {
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
for (const nodeId of nodeRefIds) {
|
|
251
|
+
// if (nodes[`${nodeId}`]) {
|
|
252
|
+
if (nodeId === 'new') {
|
|
253
|
+
//get information about Action
|
|
254
|
+
const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
|
|
255
|
+
const newNode = manager.create(Node_1.default, {
|
|
256
|
+
nodeId: undefined,
|
|
257
|
+
flowId: nodes[`${nodeId}`].flowId,
|
|
258
|
+
isInit: 'N',
|
|
259
|
+
actionId: newAction.actionId
|
|
260
|
+
});
|
|
261
|
+
const saveNode = await manager.save(newNode);
|
|
262
|
+
id = saveNode.nodeId;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
id = parseInt(nodeId.split("-")[1]);
|
|
266
|
+
}
|
|
267
|
+
//save in node and node_connection
|
|
268
|
+
const newConnection = manager.create(NodeConnection_1.default, {
|
|
269
|
+
nodeConnectionId: undefined,
|
|
270
|
+
nodeIdMaster: masterId,
|
|
271
|
+
nodeIdChild: id,
|
|
272
|
+
});
|
|
273
|
+
masterId = id;
|
|
274
|
+
const savedNodes = await manager.save(newConnection);
|
|
275
|
+
// }
|
|
276
|
+
}
|
|
277
|
+
//}
|
|
278
|
+
}
|
|
279
|
+
console.log("fin de funcion");
|
|
280
|
+
return { success: true };
|
|
281
|
+
}
|
|
178
282
|
async getFlowRender(params) {
|
|
179
|
-
let actions = await typeorm_1.getManager()
|
|
283
|
+
let actions = await (0, typeorm_1.getManager)()
|
|
180
284
|
.createQueryBuilder(Action_1.default, "a")
|
|
181
285
|
.select([
|
|
182
286
|
"a.actionId",
|
|
@@ -188,16 +292,16 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
188
292
|
.innerJoin("a.actionType", "at")
|
|
189
293
|
.where(`a.isActive = 1 and a.hidden = 'N'`)
|
|
190
294
|
.getMany();
|
|
191
|
-
const connections = await typeorm_1.getManager()
|
|
295
|
+
const connections = await (0, typeorm_1.getManager)()
|
|
192
296
|
.createQueryBuilder(NodeConnection_1.default, "nc")
|
|
193
297
|
.select([
|
|
194
298
|
"nc.nodeIdMaster",
|
|
195
299
|
"nc.nodeIdChild",
|
|
196
300
|
])
|
|
197
301
|
.innerJoin("nc.childNode", "cn")
|
|
198
|
-
.where(`cn.flowId = :flowId`, { flowId: params.flowId })
|
|
302
|
+
.where(`cn.isActive = 1 and cn.flowId = :flowId`, { flowId: params.flowId })
|
|
199
303
|
.getMany();
|
|
200
|
-
const nodes = await typeorm_1.getManager()
|
|
304
|
+
const nodes = await (0, typeorm_1.getManager)()
|
|
201
305
|
.createQueryBuilder(Node_1.default, "n")
|
|
202
306
|
.select([
|
|
203
307
|
"n.nodeId",
|
|
@@ -207,7 +311,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
207
311
|
"a.description",
|
|
208
312
|
])
|
|
209
313
|
.innerJoin("n.action", "a")
|
|
210
|
-
.where(`n.flowId = :flowId`, { flowId: params.flowId })
|
|
314
|
+
.where(`n.isActive = 1 and n.flowId = :flowId`, { flowId: params.flowId })
|
|
211
315
|
.getMany();
|
|
212
316
|
let sortedNodes = this.sortNodesByConnections(nodes, connections);
|
|
213
317
|
actions.forEach((item) => {
|
|
@@ -277,155 +381,71 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
277
381
|
});
|
|
278
382
|
return sortedNodes;
|
|
279
383
|
}
|
|
280
|
-
async saveFlow(params, manager) {
|
|
281
|
-
let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
|
|
282
|
-
let nodes = params.board.tasks;
|
|
283
|
-
let masterId = null;
|
|
284
|
-
let id = null;
|
|
285
|
-
let flowId = null;
|
|
286
|
-
let taskIds = [];
|
|
287
|
-
if (nodeRefIds.length === 0) {
|
|
288
|
-
flowId = params.board.columns['2-column-nodes-configured'].flowId;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
for (const nodeId of nodeRefIds) {
|
|
292
|
-
// console.log ('node:',nodes[`${nodeId}`]);
|
|
293
|
-
if (nodes[`${nodeId}`]) {
|
|
294
|
-
flowId = nodes[`${nodeId}`].flowId;
|
|
295
|
-
if (nodeId != 'new') {
|
|
296
|
-
id = parseInt(nodeId.split("-")[1]);
|
|
297
|
-
taskIds.push(id);
|
|
298
|
-
const connectionsToDel = await manager.find(NodeConnection_1.default, {
|
|
299
|
-
where: { nodeIdChild: id }
|
|
300
|
-
});
|
|
301
|
-
if (connectionsToDel) {
|
|
302
|
-
//console.log("hay para eliminar---->", connectionsToDel);
|
|
303
|
-
const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
|
|
304
|
-
//console.log("eliminando: ", originalNodeCIds);
|
|
305
|
-
let flowNodeC = await typeorm_1.getManager().query(`DELETE
|
|
306
|
-
from twf_node_connection
|
|
307
|
-
WHERE node_connection_id = ${originalNodeCIds}`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
//If there are some nodes in node_connections after delete all records sent, to inactive node
|
|
314
|
-
let connectNoDel = await typeorm_1.getManager().query(`SELECT n.node_id
|
|
315
|
-
from twf_node_connection nd
|
|
316
|
-
inner join twf_node n on n.node_id = nd.node_id_child
|
|
317
|
-
WHERE n.flow_id= ${flowId}`);
|
|
318
|
-
const currentNodesIds = connectNoDel.map((record) => record.node_id);
|
|
319
|
-
// Get nodes to remove
|
|
320
|
-
const nodesToRemove = currentNodesIds.filter((nodeId) => !taskIds.includes(nodeId.toString()));
|
|
321
|
-
// Inactive nodes
|
|
322
|
-
if (nodesToRemove.length > 0) {
|
|
323
|
-
const delNodeConnect = await manager.delete(NodeConnection_1.default, { nodeIdChild: nodesToRemove[0] });
|
|
324
|
-
if (delNodeConnect) {
|
|
325
|
-
let dNode = `UPDATE twf_node SET
|
|
326
|
-
is_active = 'N' WHERE node_id = ${nodesToRemove[0]}`;
|
|
327
|
-
await manager.query(dNode);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (nodeRefIds.length === 0) {
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
for (const nodeId of nodeRefIds) {
|
|
334
|
-
if (nodes[`${nodeId}`]) {
|
|
335
|
-
if (nodeId === 'new') {
|
|
336
|
-
//get information about Action
|
|
337
|
-
const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
|
|
338
|
-
const newNode = manager.create(Node_1.default, {
|
|
339
|
-
nodeId: undefined,
|
|
340
|
-
flowId: nodes[`${nodeId}`].flowId,
|
|
341
|
-
isInit: 'N',
|
|
342
|
-
actionId: newAction.actionId
|
|
343
|
-
});
|
|
344
|
-
const saveNode = await manager.save(newNode);
|
|
345
|
-
id = saveNode.nodeId;
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
id = parseInt(nodeId.split("-")[1]);
|
|
349
|
-
}
|
|
350
|
-
//save in node and node_connection
|
|
351
|
-
const newConnection = manager.create(NodeConnection_1.default, {
|
|
352
|
-
nodeConnectionId: undefined,
|
|
353
|
-
nodeIdMaster: masterId,
|
|
354
|
-
nodeIdChild: id,
|
|
355
|
-
});
|
|
356
|
-
masterId = id;
|
|
357
|
-
const savedNodes = await manager.save(newConnection);
|
|
358
|
-
// }
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return { success: true };
|
|
363
|
-
}
|
|
364
384
|
};
|
|
365
385
|
__decorate([
|
|
366
|
-
core_1.Get(),
|
|
367
|
-
core_1.DbSettings('Orm'),
|
|
368
|
-
core_1.ReadOnly(true),
|
|
369
|
-
core_1.Log(true),
|
|
386
|
+
(0, core_1.Get)(),
|
|
387
|
+
(0, core_1.DbSettings)('Orm'),
|
|
388
|
+
(0, core_1.ReadOnly)(true),
|
|
389
|
+
(0, core_1.Log)(true),
|
|
370
390
|
__metadata("design:type", Function),
|
|
371
391
|
__metadata("design:paramtypes", [Object]),
|
|
372
392
|
__metadata("design:returntype", Promise)
|
|
373
393
|
], Flow.prototype, "get", null);
|
|
374
394
|
__decorate([
|
|
375
|
-
core_1.Post(),
|
|
376
|
-
core_1.DbSettings('Orm'),
|
|
377
|
-
core_1.ReadOnly(false),
|
|
378
|
-
core_1.Log(true),
|
|
395
|
+
(0, core_1.Post)(),
|
|
396
|
+
(0, core_1.DbSettings)('Orm'),
|
|
397
|
+
(0, core_1.ReadOnly)(false),
|
|
398
|
+
(0, core_1.Log)(true),
|
|
379
399
|
__metadata("design:type", Function),
|
|
380
400
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
381
401
|
__metadata("design:returntype", Promise)
|
|
382
402
|
], Flow.prototype, "createFlowFromFlow", null);
|
|
383
403
|
__decorate([
|
|
384
|
-
core_1.Post(),
|
|
385
|
-
core_1.DbSettings('Orm'),
|
|
386
|
-
core_1.ReadOnly(false),
|
|
387
|
-
core_1.Log(true),
|
|
404
|
+
(0, core_1.Post)(),
|
|
405
|
+
(0, core_1.DbSettings)('Orm'),
|
|
406
|
+
(0, core_1.ReadOnly)(false),
|
|
407
|
+
(0, core_1.Log)(true),
|
|
388
408
|
__metadata("design:type", Function),
|
|
389
409
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
390
410
|
__metadata("design:returntype", Promise)
|
|
391
411
|
], Flow.prototype, "deleteFlow", null);
|
|
392
412
|
__decorate([
|
|
393
|
-
core_1.Post(),
|
|
394
|
-
core_1.DbSettings('Orm'),
|
|
395
|
-
core_1.ReadOnly(false),
|
|
396
|
-
core_1.Log(true),
|
|
413
|
+
(0, core_1.Post)(),
|
|
414
|
+
(0, core_1.DbSettings)('Orm'),
|
|
415
|
+
(0, core_1.ReadOnly)(false),
|
|
416
|
+
(0, core_1.Log)(true),
|
|
397
417
|
__metadata("design:type", Function),
|
|
398
418
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
399
419
|
__metadata("design:returntype", Promise)
|
|
400
420
|
], Flow.prototype, "saveFlowName", null);
|
|
401
421
|
__decorate([
|
|
402
|
-
core_1.Post(),
|
|
403
|
-
core_1.DbSettings('Orm'),
|
|
404
|
-
core_1.ReadOnly(false),
|
|
405
|
-
core_1.Log(true),
|
|
422
|
+
(0, core_1.Post)(),
|
|
423
|
+
(0, core_1.DbSettings)('Orm'),
|
|
424
|
+
(0, core_1.ReadOnly)(false),
|
|
425
|
+
(0, core_1.Log)(true),
|
|
406
426
|
__metadata("design:type", Function),
|
|
407
427
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
408
428
|
__metadata("design:returntype", Promise)
|
|
409
429
|
], Flow.prototype, "duplicateFlow", null);
|
|
410
430
|
__decorate([
|
|
411
|
-
core_1.
|
|
412
|
-
core_1.DbSettings('Orm'),
|
|
413
|
-
core_1.ReadOnly(
|
|
414
|
-
core_1.Log(true),
|
|
431
|
+
(0, core_1.Post)(),
|
|
432
|
+
(0, core_1.DbSettings)('Orm'),
|
|
433
|
+
(0, core_1.ReadOnly)(false),
|
|
434
|
+
(0, core_1.Log)(true),
|
|
415
435
|
__metadata("design:type", Function),
|
|
416
|
-
__metadata("design:paramtypes", [Object]),
|
|
436
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
417
437
|
__metadata("design:returntype", Promise)
|
|
418
|
-
], Flow.prototype, "
|
|
438
|
+
], Flow.prototype, "saveFlow", null);
|
|
419
439
|
__decorate([
|
|
420
|
-
core_1.
|
|
421
|
-
core_1.DbSettings('Orm'),
|
|
422
|
-
core_1.ReadOnly(
|
|
423
|
-
core_1.Log(true),
|
|
440
|
+
(0, core_1.Get)(),
|
|
441
|
+
(0, core_1.DbSettings)('Orm'),
|
|
442
|
+
(0, core_1.ReadOnly)(true),
|
|
443
|
+
(0, core_1.Log)(true),
|
|
424
444
|
__metadata("design:type", Function),
|
|
425
|
-
__metadata("design:paramtypes", [Object
|
|
445
|
+
__metadata("design:paramtypes", [Object]),
|
|
426
446
|
__metadata("design:returntype", Promise)
|
|
427
|
-
], Flow.prototype, "
|
|
447
|
+
], Flow.prototype, "getFlowRender", null);
|
|
428
448
|
Flow = __decorate([
|
|
429
|
-
core_1.Model('flow-nd/Flow')
|
|
449
|
+
(0, core_1.Model)('flow-nd/Flow')
|
|
430
450
|
], Flow);
|
|
431
451
|
exports.default = Flow;
|
|
@@ -42,7 +42,7 @@ class FlowInstance extends core_1.Controller {
|
|
|
42
42
|
}
|
|
43
43
|
flag.value = 'true';
|
|
44
44
|
let flowInstanceIdProcessing = -1;
|
|
45
|
-
await typeorm_1.getManager().save(flag);
|
|
45
|
+
await (0, typeorm_1.getManager)().save(flag);
|
|
46
46
|
try {
|
|
47
47
|
const maxFlows = await common_1.GlobalData.findOne({ data: 'wf_max_concurrent_flows_process' });
|
|
48
48
|
const flowInstances = await FlowInstance_1.default.find({ take: (maxFlows && maxFlows.value), where: [{ status: 'pending' }], order: { flowInstanceId: "ASC" } });
|
|
@@ -63,20 +63,20 @@ class FlowInstance extends core_1.Controller {
|
|
|
63
63
|
}
|
|
64
64
|
catch (error) {
|
|
65
65
|
flag.value = 'false';
|
|
66
|
-
await typeorm_1.getManager().save(flag);
|
|
66
|
+
await (0, typeorm_1.getManager)().save(flag);
|
|
67
67
|
throw new core_1.PxpError(400, 'Error processing flow: ' + flowInstanceIdProcessing);
|
|
68
68
|
}
|
|
69
69
|
flag.value = 'false';
|
|
70
|
-
await typeorm_1.getManager().save(flag);
|
|
70
|
+
await (0, typeorm_1.getManager)().save(flag);
|
|
71
71
|
}
|
|
72
72
|
return { success: true };
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
__decorate([
|
|
76
|
-
core_1.Post(),
|
|
77
|
-
core_1.DbSettings('Orm'),
|
|
78
|
-
core_1.ReadOnly(false),
|
|
79
|
-
core_1.Log(true),
|
|
76
|
+
(0, core_1.Post)(),
|
|
77
|
+
(0, core_1.DbSettings)('Orm'),
|
|
78
|
+
(0, core_1.ReadOnly)(false),
|
|
79
|
+
(0, core_1.Log)(true),
|
|
80
80
|
__metadata("design:type", Function),
|
|
81
81
|
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
82
82
|
__metadata("design:returntype", Promise)
|