@pxp-nd/flow 1.0.39 → 1.0.41
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/Flow.js +36 -29
- package/dist/entity/Flow.js +1 -1
- package/package.json +3 -3
package/dist/controllers/Flow.js
CHANGED
|
@@ -138,35 +138,42 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
138
138
|
}
|
|
139
139
|
async duplicateFlow(params, manager) {
|
|
140
140
|
const flowData = await manager.findOne(Flow_1.default, params.flowId);
|
|
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
|
-
|
|
141
|
+
if (flowData) {
|
|
142
|
+
const flowToClone = {
|
|
143
|
+
...flowData,
|
|
144
|
+
flowId: undefined,
|
|
145
|
+
nodes: [],
|
|
146
|
+
createdAt: undefined
|
|
147
|
+
};
|
|
148
|
+
const flowDataClone = await manager.save(Flow_1.default, { ...flowToClone, name: `${flowData.name} Copy` });
|
|
149
|
+
const nodesToDuplicate = await manager.find(Node_1.default, { flowId: flowData === null || flowData === void 0 ? void 0 : flowData.flowId });
|
|
150
|
+
if (nodesToDuplicate) {
|
|
151
|
+
const originalNodeIds = nodesToDuplicate.map((node) => node.nodeId);
|
|
152
|
+
const duplicatedNodes = nodesToDuplicate.map((node) => {
|
|
153
|
+
const duplicatedNode = manager.create(Node_1.default, { ...node, nodeId: undefined });
|
|
154
|
+
duplicatedNode.flowId = flowDataClone.flowId;
|
|
155
|
+
return duplicatedNode;
|
|
156
|
+
});
|
|
157
|
+
const savedNodes = await manager.save(duplicatedNodes);
|
|
158
|
+
const newNodeIds = savedNodes.map((node) => node.nodeId);
|
|
159
|
+
const connectionsToDuplicate = await manager.find(NodeConnection_1.default, {
|
|
160
|
+
where: { nodeIdChild: typeorm_1.In(originalNodeIds) }
|
|
161
|
+
});
|
|
162
|
+
const duplicatedConnections = newNodeIds.map((nodeId, index) => {
|
|
163
|
+
const duplicatedConnection = manager.create(NodeConnection_1.default, {
|
|
164
|
+
nodeConnectionId: undefined,
|
|
165
|
+
nodeIdMaster: index === 0 ? null : newNodeIds[index - 1],
|
|
166
|
+
nodeIdChild: nodeId,
|
|
167
|
+
});
|
|
168
|
+
return duplicatedConnection;
|
|
169
|
+
});
|
|
170
|
+
await manager.save(duplicatedConnections);
|
|
171
|
+
}
|
|
172
|
+
return { success: true };
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return { success: false, "respuesta": "No Flow" };
|
|
176
|
+
}
|
|
170
177
|
}
|
|
171
178
|
async getFlowRender(params) {
|
|
172
179
|
let actions = await typeorm_1.getManager()
|
package/dist/entity/Flow.js
CHANGED
|
@@ -51,7 +51,7 @@ __decorate([
|
|
|
51
51
|
__metadata("design:type", Array)
|
|
52
52
|
], Flow.prototype, "instances", void 0);
|
|
53
53
|
__decorate([
|
|
54
|
-
typeorm_1.OneToMany(() => Node_1.default, node => node.flow),
|
|
54
|
+
typeorm_1.OneToMany(() => Node_1.default, node => node.flow, { eager: true }),
|
|
55
55
|
__metadata("design:type", Array)
|
|
56
56
|
], Flow.prototype, "nodes", void 0);
|
|
57
57
|
Flow = __decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pxp-nd/flow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"description": "Workflow module for pxp-nd framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/lodash": "^4.14.172",
|
|
33
33
|
"@types/node": "^16.4.13",
|
|
34
34
|
"rimraf": "^3.0.2",
|
|
35
|
-
"tsc-watch": "^4.2
|
|
36
|
-
"typescript": "^4.
|
|
35
|
+
"tsc-watch": "^4.6.2",
|
|
36
|
+
"typescript": "^4.9.5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@pxp-nd/common": "^1.1.4",
|