@pxp-nd/flow 1.1.5 → 1.1.7
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.
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* 16-Sep-2023 SP22SEP23 Mercedes Zambrana Change GET to POST in insertEventFlow
|
|
19
19
|
* 28-Sep-2023 SP06OCT23 Mercedes Zambrana Add Validation when change off status (validateFlow, deleteflow, saveFlow, saveflowName)
|
|
20
20
|
* 07-Feb-2025 8353064698 Mercedes Zambrana Add validation for opt in page when flow si funnel change
|
|
21
|
+
* 18-Feb-2025 8501163144 Mercedes Zambrana Add publish filter
|
|
21
22
|
* ******************************************************************************
|
|
22
23
|
*/
|
|
23
24
|
import { EntityManager } from 'typeorm';
|
|
@@ -41,5 +42,7 @@ declare class Flow extends Controller {
|
|
|
41
42
|
validateFlow(flowId: number, manager: EntityManager, status: string): Promise<unknown>;
|
|
42
43
|
basicFlowList(params: Record<string, any>): Promise<unknown>;
|
|
43
44
|
listTemplates(params: Record<string, any>): Promise<unknown>;
|
|
45
|
+
changePublishTemplate(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
|
|
46
|
+
validatePublishTemplate(flowId: number, manager: EntityManager, publish: string): Promise<unknown>;
|
|
44
47
|
}
|
|
45
48
|
export default Flow;
|
package/dist/controllers/Flow.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* 16-Sep-2023 SP22SEP23 Mercedes Zambrana Change GET to POST in insertEventFlow
|
|
20
20
|
* 28-Sep-2023 SP06OCT23 Mercedes Zambrana Add Validation when change off status (validateFlow, deleteflow, saveFlow, saveflowName)
|
|
21
21
|
* 07-Feb-2025 8353064698 Mercedes Zambrana Add validation for opt in page when flow si funnel change
|
|
22
|
+
* 18-Feb-2025 8501163144 Mercedes Zambrana Add publish filter
|
|
22
23
|
* ******************************************************************************
|
|
23
24
|
*/
|
|
24
25
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -233,7 +234,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
async saveFlow(params, manager) {
|
|
236
|
-
var _a, _b;
|
|
237
|
+
var _a, _b, _c, _d;
|
|
237
238
|
let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
|
|
238
239
|
let nodes = params.board.tasks ? params.board.tasks : [];
|
|
239
240
|
let masterId = null;
|
|
@@ -348,7 +349,14 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
351
|
catch (error) {
|
|
351
|
-
|
|
352
|
+
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
353
|
+
const message = ((_c = (_b = error.response.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error';
|
|
354
|
+
throw new core_1.PxpError(400, message);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
console.error("Not valid json", error);
|
|
358
|
+
throw new core_1.PxpError(500, 'Unexpected error while processing the request');
|
|
359
|
+
}
|
|
352
360
|
}
|
|
353
361
|
}
|
|
354
362
|
}
|
|
@@ -396,7 +404,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
396
404
|
data: params,
|
|
397
405
|
};
|
|
398
406
|
const resControllerAxios = await (0, axios_1.default)(config);
|
|
399
|
-
const chainedFlowId = (
|
|
407
|
+
const chainedFlowId = (_d = resControllerAxios.data) === null || _d === void 0 ? void 0 : _d.flowId;
|
|
400
408
|
const parsedValues = {
|
|
401
409
|
flowId: chainedFlowId
|
|
402
410
|
};
|
|
@@ -883,6 +891,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
883
891
|
const filter = (params === null || params === void 0 ? void 0 : params.filter) ? JSON.parse(params === null || params === void 0 ? void 0 : params.filter) : null;
|
|
884
892
|
const filters = (filter === null || filter === void 0 ? void 0 : filter.items) || [];
|
|
885
893
|
const logicOperator = ((_a = filter === null || filter === void 0 ? void 0 : filter.logicOperator) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "AND";
|
|
894
|
+
const publish = params._publish;
|
|
886
895
|
const queryBuilder = await (0, typeorm_1.getManager)()
|
|
887
896
|
.createQueryBuilder()
|
|
888
897
|
.select([
|
|
@@ -910,6 +919,9 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
910
919
|
if (isActive !== undefined) {
|
|
911
920
|
queryBuilder.where("f.is_active = :isActive", { isActive });
|
|
912
921
|
}
|
|
922
|
+
if (publish !== undefined) {
|
|
923
|
+
queryBuilder.where("f.publish = :publish", { publish });
|
|
924
|
+
}
|
|
913
925
|
if (type) {
|
|
914
926
|
queryBuilder.andWhere("f.type = :type", { type });
|
|
915
927
|
}
|
|
@@ -1003,6 +1015,9 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
1003
1015
|
if (isActive !== undefined) {
|
|
1004
1016
|
countQuery.where("f.is_active = :isActive", { isActive });
|
|
1005
1017
|
}
|
|
1018
|
+
if (publish !== undefined) {
|
|
1019
|
+
countQuery.where("f.publish = :publish", { publish });
|
|
1020
|
+
}
|
|
1006
1021
|
if (type) {
|
|
1007
1022
|
countQuery.andWhere("f.type = :type", { type });
|
|
1008
1023
|
}
|
|
@@ -1024,6 +1039,41 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
1024
1039
|
const totalCount = await countQuery.getRawOne();
|
|
1025
1040
|
return { data, count: totalCount.count };
|
|
1026
1041
|
}
|
|
1042
|
+
async changePublishTemplate(params, manager) {
|
|
1043
|
+
let dataFlow = await (0, core_1.__)(Flow_1.default.findOne(params.flowId));
|
|
1044
|
+
if (dataFlow) {
|
|
1045
|
+
console.log("publish es:::::::::", dataFlow.publish);
|
|
1046
|
+
if (dataFlow.publish === 'N') {
|
|
1047
|
+
await this.validatePublishTemplate(params.flowId, manager, 'Y');
|
|
1048
|
+
//change to active
|
|
1049
|
+
dataFlow.publish = 'Y';
|
|
1050
|
+
}
|
|
1051
|
+
else {
|
|
1052
|
+
await this.validatePublishTemplate(params.flowId, manager, 'N');
|
|
1053
|
+
dataFlow.publish = 'N';
|
|
1054
|
+
}
|
|
1055
|
+
dataFlow.modifiedAt = new Date();
|
|
1056
|
+
dataFlow.modifiedBy = this.user.username;
|
|
1057
|
+
const updFlow = await (0, core_1.__)(manager.save(dataFlow));
|
|
1058
|
+
return { success: true };
|
|
1059
|
+
}
|
|
1060
|
+
else {
|
|
1061
|
+
return { success: false };
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
async validatePublishTemplate(flowId, manager, publish) {
|
|
1065
|
+
if (publish == 'Y') {
|
|
1066
|
+
const nodes = await Node_1.default.find({ flowId, isActive: true });
|
|
1067
|
+
let res = '';
|
|
1068
|
+
if (nodes.length < 2) {
|
|
1069
|
+
throw new core_1.PxpError(400, 'Your template must have at least 2 steps. Please finish configuring it before publish');
|
|
1070
|
+
}
|
|
1071
|
+
return true;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
return true;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1027
1077
|
};
|
|
1028
1078
|
__decorate([
|
|
1029
1079
|
(0, core_1.Get)(),
|
|
@@ -1134,6 +1184,15 @@ __decorate([
|
|
|
1134
1184
|
__metadata("design:paramtypes", [Object]),
|
|
1135
1185
|
__metadata("design:returntype", Promise)
|
|
1136
1186
|
], Flow.prototype, "listTemplates", null);
|
|
1187
|
+
__decorate([
|
|
1188
|
+
(0, core_1.Post)(),
|
|
1189
|
+
(0, core_1.DbSettings)('Orm'),
|
|
1190
|
+
(0, core_1.ReadOnly)(false),
|
|
1191
|
+
(0, core_1.Log)(true),
|
|
1192
|
+
__metadata("design:type", Function),
|
|
1193
|
+
__metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
|
|
1194
|
+
__metadata("design:returntype", Promise)
|
|
1195
|
+
], Flow.prototype, "changePublishTemplate", null);
|
|
1137
1196
|
Flow = __decorate([
|
|
1138
1197
|
(0, core_1.Model)('flow-nd/Flow')
|
|
1139
1198
|
], Flow);
|
package/dist/entity/Flow.d.ts
CHANGED
package/dist/entity/Flow.js
CHANGED
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
* 04-Sep-2023 SP08SEP23 Rensi Arteaga add modified at and by
|
|
26
26
|
* 06-Dec-2024 8001237262 Mercedes Zambrana add flow_type
|
|
27
27
|
* 31-Jan-2025 8035304698 Mercedes Zambrana Change code to string
|
|
28
|
+
* 18-Feb-2025 8501163144 Mercedes Zambrana Add publish column
|
|
28
29
|
****************************************************************************/
|
|
29
30
|
const typeorm_1 = require("typeorm");
|
|
30
31
|
const FlowInstance_1 = __importDefault(require("./FlowInstance"));
|
|
@@ -92,6 +93,10 @@ __decorate([
|
|
|
92
93
|
(0, typeorm_1.Column)({ name: 'flow_type', type: 'varchar', nullable: true, length: 100 }),
|
|
93
94
|
__metadata("design:type", String)
|
|
94
95
|
], Flow.prototype, "flowType", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, typeorm_1.Column)({ name: 'publish', type: 'varchar', nullable: false, length: 1 }),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], Flow.prototype, "publish", void 0);
|
|
95
100
|
Flow = __decorate([
|
|
96
101
|
(0, typeorm_1.Entity)({ name: 'twf_flow' })
|
|
97
102
|
], Flow);
|