@pxp-nd/flow 1.0.50 → 1.0.52

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.
@@ -11,8 +11,9 @@
11
11
  * 08-Jul-2021 Jaime Rivera Created
12
12
  * 18-Jul-2023 SP28JUL23 Mercedes Zambrana Add deleteFlow, saveFlowName, duplicateFlow
13
13
  * 02-Aug-2023 SP11AUG23 Mercedes Zambrana Add validations in deleteFlow and saveFlow
14
- * 15-Aug-2023 SP25AUG23 Rensi Arteaga Add logic to duplicate flows templates
14
+ * 15-Aug-2023 SP25AUG23 Rensi Arteaga Add logic to duplicate flows templates nadd icons
15
15
  * 17-Aug-2023 SP25AUG23 Mercedes Zambrana Add insertEventFlow
16
+ * 18-Aug-2023 SP25AUG23 Mercedes Zambrana Add removeFlow
16
17
  * ******************************************************************************
17
18
  */
18
19
  import { EntityManager } from 'typeorm';
@@ -31,5 +32,7 @@ declare class Flow extends Controller {
31
32
  getFlowRender(params: Record<string, any>): Promise<unknown>;
32
33
  sortNodesByConnections(nodes: any[], connections: any[]): any[];
33
34
  insertEventFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
35
+ removeFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
36
+ changeStatusFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
34
37
  }
35
38
  export default Flow;
@@ -12,8 +12,9 @@
12
12
  * 08-Jul-2021 Jaime Rivera Created
13
13
  * 18-Jul-2023 SP28JUL23 Mercedes Zambrana Add deleteFlow, saveFlowName, duplicateFlow
14
14
  * 02-Aug-2023 SP11AUG23 Mercedes Zambrana Add validations in deleteFlow and saveFlow
15
- * 15-Aug-2023 SP25AUG23 Rensi Arteaga Add logic to duplicate flows templates
15
+ * 15-Aug-2023 SP25AUG23 Rensi Arteaga Add logic to duplicate flows templates nadd icons
16
16
  * 17-Aug-2023 SP25AUG23 Mercedes Zambrana Add insertEventFlow
17
+ * 18-Aug-2023 SP25AUG23 Mercedes Zambrana Add removeFlow
17
18
  * ******************************************************************************
18
19
  */
19
20
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -325,6 +326,7 @@ let Flow = class Flow extends core_1.Controller {
325
326
  "a.code",
326
327
  "a.name",
327
328
  "a.description",
329
+ "a.icon",
328
330
  "at.name"
329
331
  ])
330
332
  .innerJoin("a.actionType", "at")
@@ -347,6 +349,7 @@ let Flow = class Flow extends core_1.Controller {
347
349
  "a.code",
348
350
  "a.name",
349
351
  "a.description",
352
+ "a.icon",
350
353
  ])
351
354
  .innerJoin("n.action", "a")
352
355
  .where(`n.isActive = 1 and n.flowId = :flowId`, { flowId: params.flowId })
@@ -457,6 +460,44 @@ let Flow = class Flow extends core_1.Controller {
457
460
  return { success: false, msg: "Flow not found" };
458
461
  }
459
462
  }
463
+ async removeFlow(params, manager) {
464
+ const flowId = params.flowId;
465
+ let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(flowId));
466
+ if (dataFlow) {
467
+ const nodesToDelete = await manager.find(Node_1.default, { flowId });
468
+ const nodeIdsToDelete = nodesToDelete.map(node => node.nodeId);
469
+ const nodeConnectionsToDelete = await manager.find(NodeConnection_1.default, {
470
+ where: [
471
+ { nodeIdMaster: (0, typeorm_1.In)(nodeIdsToDelete) },
472
+ { nodeIdChild: (0, typeorm_1.In)(nodeIdsToDelete) }
473
+ ]
474
+ });
475
+ await manager.remove(nodeConnectionsToDelete);
476
+ await manager.remove(nodesToDelete);
477
+ await manager.remove(dataFlow);
478
+ return { success: true };
479
+ }
480
+ else {
481
+ return { success: false };
482
+ }
483
+ }
484
+ async changeStatusFlow(params, manager) {
485
+ let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
486
+ if (dataFlow) {
487
+ if (dataFlow.status === 'draft' || dataFlow.status === 'paused') {
488
+ //change to active
489
+ dataFlow.status = 'active';
490
+ }
491
+ else if (dataFlow.status === 'active') {
492
+ dataFlow.status = 'paused';
493
+ }
494
+ const updFlow = await (0, core_1.__)(manager.save(dataFlow));
495
+ return { success: true };
496
+ }
497
+ else {
498
+ return { success: false };
499
+ }
500
+ }
460
501
  };
461
502
  __decorate([
462
503
  (0, core_1.Get)(),
@@ -530,6 +571,24 @@ __decorate([
530
571
  __metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
531
572
  __metadata("design:returntype", Promise)
532
573
  ], Flow.prototype, "insertEventFlow", null);
574
+ __decorate([
575
+ (0, core_1.Post)(),
576
+ (0, core_1.DbSettings)('Orm'),
577
+ (0, core_1.ReadOnly)(false),
578
+ (0, core_1.Log)(true),
579
+ __metadata("design:type", Function),
580
+ __metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
581
+ __metadata("design:returntype", Promise)
582
+ ], Flow.prototype, "removeFlow", null);
583
+ __decorate([
584
+ (0, core_1.Post)(),
585
+ (0, core_1.DbSettings)('Orm'),
586
+ (0, core_1.ReadOnly)(false),
587
+ (0, core_1.Log)(true),
588
+ __metadata("design:type", Function),
589
+ __metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
590
+ __metadata("design:returntype", Promise)
591
+ ], Flow.prototype, "changeStatusFlow", null);
533
592
  Flow = __decorate([
534
593
  (0, core_1.Model)('flow-nd/Flow')
535
594
  ], Flow);
@@ -17,4 +17,5 @@ export default class Action extends PxpEntity {
17
17
  actionType: ActionType;
18
18
  nodes: Node[];
19
19
  eventNodes: Node[];
20
+ icon: string;
20
21
  }
@@ -79,6 +79,10 @@ __decorate([
79
79
  (0, typeorm_1.OneToMany)(() => Node_1.default, eventNode => eventNode.actionEvent),
80
80
  __metadata("design:type", Array)
81
81
  ], Action.prototype, "eventNodes", void 0);
82
+ __decorate([
83
+ (0, typeorm_1.Column)({ type: 'varchar', length: 200 }),
84
+ __metadata("design:type", String)
85
+ ], Action.prototype, "icon", void 0);
82
86
  Action = __decorate([
83
87
  (0, typeorm_1.Entity)({ name: 'twf_action' })
84
88
  ], Action);
@@ -11,4 +11,6 @@ export default class Flow extends PxpEntity {
11
11
  type: string;
12
12
  instances: FlowInstance[];
13
13
  nodes: Node[];
14
+ icon: string;
15
+ status: string;
14
16
  }
@@ -54,6 +54,14 @@ __decorate([
54
54
  (0, typeorm_1.OneToMany)(() => Node_1.default, node => node.flow),
55
55
  __metadata("design:type", Array)
56
56
  ], Flow.prototype, "nodes", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)({ type: 'varchar', length: 200 }),
59
+ __metadata("design:type", String)
60
+ ], Flow.prototype, "icon", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Column)({ type: 'varchar', length: 30 }),
63
+ __metadata("design:type", String)
64
+ ], Flow.prototype, "status", void 0);
57
65
  Flow = __decorate([
58
66
  (0, typeorm_1.Entity)({ name: 'twf_flow' })
59
67
  ], Flow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",