@pxp-nd/flow 1.0.69 → 1.0.71
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,6 +35,7 @@ declare class Flow extends Controller {
|
|
|
35
35
|
insertEventFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
36
36
|
removeFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
37
37
|
changeStatusFlow(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
38
|
+
validateFlow(flowId: number, manager: EntityManager): Promise<unknown>;
|
|
38
39
|
basicFlowList(params: Record<string, any>): Promise<unknown>;
|
|
39
40
|
}
|
|
40
41
|
export default Flow;
|
package/dist/controllers/Flow.js
CHANGED
|
@@ -18,12 +18,35 @@
|
|
|
18
18
|
* 01-Sep-2023 SP08SEP23 Rensi Arteaga add base flow list
|
|
19
19
|
* ******************************************************************************
|
|
20
20
|
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
21
37
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
22
38
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
39
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
24
40
|
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;
|
|
25
41
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
26
42
|
};
|
|
43
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
27
50
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
28
51
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
29
52
|
};
|
|
@@ -33,6 +56,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
57
|
const typeorm_1 = require("typeorm");
|
|
35
58
|
const core_1 = require("@pxp-nd/core");
|
|
59
|
+
const _ = __importStar(require("lodash"));
|
|
36
60
|
const Node_1 = __importDefault(require("../entity/Node"));
|
|
37
61
|
const Action_1 = __importDefault(require("../entity/Action"));
|
|
38
62
|
const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
|
|
@@ -488,6 +512,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
488
512
|
let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
|
|
489
513
|
if (dataFlow) {
|
|
490
514
|
if (dataFlow.status === 'off') {
|
|
515
|
+
await this.validateFlow(params.flowId, manager);
|
|
491
516
|
//change to active
|
|
492
517
|
dataFlow.status = 'on';
|
|
493
518
|
}
|
|
@@ -503,10 +528,48 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
503
528
|
return { success: false };
|
|
504
529
|
}
|
|
505
530
|
}
|
|
531
|
+
async validateFlow(flowId, manager) {
|
|
532
|
+
const nodes = await Node_1.default.find({ flowId, isActive: true });
|
|
533
|
+
let res = '';
|
|
534
|
+
for (const node of nodes) {
|
|
535
|
+
const configActionType = !node.action.actionType.schemaJson ? {} : JSON.parse(node.action.actionType.schemaJson);
|
|
536
|
+
const configAction = !node.action.schemaJson ? {} : JSON.parse(node.action.schemaJson);
|
|
537
|
+
const config = _.merge({}, configActionType, configAction);
|
|
538
|
+
const required = [];
|
|
539
|
+
for (const key in config) {
|
|
540
|
+
if (config.hasOwnProperty(key)) {
|
|
541
|
+
const prop = config[key];
|
|
542
|
+
if (prop && typeof prop === "object" &&
|
|
543
|
+
((prop.validate && prop.validate.shape.includes('required')) ||
|
|
544
|
+
(prop.formComponent && prop.formComponent.validate && prop.formComponent.validate.shape.includes('required')))) {
|
|
545
|
+
required.push(key);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const valueNode = !node.actionConfigJson ? {} : JSON.parse(node.actionConfigJson);
|
|
550
|
+
const valueAction = !node.action.configJsonTemplate ? {} : JSON.parse(node.action.configJsonTemplate);
|
|
551
|
+
const values = _.merge({}, valueAction, valueNode);
|
|
552
|
+
const missingRequired = [];
|
|
553
|
+
required.forEach((property) => {
|
|
554
|
+
if (!values.hasOwnProperty(property)) {
|
|
555
|
+
missingRequired.push(property);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
if (missingRequired.length > 0) {
|
|
559
|
+
res += `In node ${node.action.name} ${node.nodeId} you have missing fields: ${missingRequired.join(',')}, `;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (res != '') {
|
|
563
|
+
res = res.slice(0, -2);
|
|
564
|
+
throw new core_1.PxpError(400, 'Please resolve these issues before starting the flow: ' + res);
|
|
565
|
+
}
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
506
568
|
async basicFlowList(params) {
|
|
507
569
|
const isActive = params._isActive;
|
|
508
570
|
const type = params._type;
|
|
509
571
|
const vendorId = params._vendorId;
|
|
572
|
+
const allowedColumns = ['name', 'description'];
|
|
510
573
|
const queryBuilder = await (0, typeorm_1.getManager)()
|
|
511
574
|
.createQueryBuilder()
|
|
512
575
|
.select([
|
|
@@ -540,8 +603,11 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
540
603
|
if (vendorId) {
|
|
541
604
|
queryBuilder.andWhere('f.vendor_id = :vendorId', { vendorId });
|
|
542
605
|
}
|
|
543
|
-
|
|
544
|
-
|
|
606
|
+
if (allowedColumns.includes(params.genericFilterFields)) {
|
|
607
|
+
if (params.genericFilterFields && params.genericFilterValue) {
|
|
608
|
+
queryBuilder.andWhere(`f.${params.genericFilterFields} LIKE :genericFilterValue`, { genericFilterValue: `%${params.genericFilterValue}%` });
|
|
609
|
+
}
|
|
610
|
+
}
|
|
545
611
|
queryBuilder.groupBy([
|
|
546
612
|
'f.flow_id',
|
|
547
613
|
'f.vendor_id',
|
|
@@ -560,6 +626,12 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
560
626
|
'f.icon',
|
|
561
627
|
'f.status',
|
|
562
628
|
]);
|
|
629
|
+
// Sorting and pagination
|
|
630
|
+
//queryBuilder.orderBy(`f.${params.sort}`, params.dir).skip(params.start).take(params.limit);
|
|
631
|
+
// Sorting and pagination
|
|
632
|
+
queryBuilder.orderBy(`f.${params.sort}`, params.dir);
|
|
633
|
+
// Agrega manualmente la cláusula LIMIT y OFFSET
|
|
634
|
+
queryBuilder.limit(params.limit).offset(params.start);
|
|
563
635
|
const data = await queryBuilder.getRawMany();
|
|
564
636
|
// Construct the count query
|
|
565
637
|
const countQuery = await (0, typeorm_1.getManager)()
|
|
@@ -576,9 +648,14 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
576
648
|
if (vendorId) {
|
|
577
649
|
countQuery.andWhere('f.vendor_id = :vendorId', { vendorId });
|
|
578
650
|
}
|
|
651
|
+
if (allowedColumns.includes(params.genericFilterFields)) {
|
|
652
|
+
if (params.genericFilterFields && params.genericFilterValue) {
|
|
653
|
+
countQuery.andWhere(`f.${params.genericFilterFields} LIKE :genericFilterValue`, { genericFilterValue: `%${params.genericFilterValue}%` });
|
|
654
|
+
}
|
|
655
|
+
}
|
|
579
656
|
const totalCount = await countQuery.getRawOne();
|
|
580
|
-
const
|
|
581
|
-
return { data,
|
|
657
|
+
const count = totalCount.count;
|
|
658
|
+
return { data, count };
|
|
582
659
|
}
|
|
583
660
|
};
|
|
584
661
|
__decorate([
|