@pxp-nd/flow 1.0.94 → 1.0.96

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.
@@ -17,6 +17,7 @@
17
17
  * 01-Sep-2023 SP08SEP23 Rensi Arteaga add base flow list
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
+ * 07-Feb-2025 8353064698 Mercedes Zambrana Add validation for opt in page when flow si funnel change
20
21
  * ******************************************************************************
21
22
  */
22
23
  import { EntityManager } from 'typeorm';
@@ -18,6 +18,7 @@
18
18
  * 01-Sep-2023 SP08SEP23 Rensi Arteaga add base flow list
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
+ * 07-Feb-2025 8353064698 Mercedes Zambrana Add validation for opt in page when flow si funnel change
21
22
  * ******************************************************************************
22
23
  */
23
24
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -66,6 +67,7 @@ const Flow_1 = __importDefault(require("../entity/Flow"));
66
67
  const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
67
68
  const NodeInstance_1 = __importDefault(require("../entity/NodeInstance"));
68
69
  const Node_2 = __importDefault(require("./Node"));
70
+ const axios_1 = __importDefault(require("axios"));
69
71
  //import {configFacebookStrategy} from "./passport-facebook";
70
72
  let Flow = class Flow extends core_1.Controller {
71
73
  async get(params) {
@@ -217,14 +219,11 @@ let Flow = class Flow extends core_1.Controller {
217
219
  let flowDataClone;
218
220
  //if we have a vendoId as parameter the origin is a template
219
221
  if (params.vendorId) {
220
- console.log("con vendor:", flowToClone);
221
222
  flowDataClone = await manager.save(Flow_1.default, { ...flowToClone, name: `${params.name}`, vendorId: params.vendorId, type: 'custom' });
222
223
  }
223
224
  else {
224
- console.log("sin vendore:", flowToClone);
225
225
  flowDataClone = await manager.save(Flow_1.default, { ...flowToClone, name: `${flowData.name} Copy` });
226
226
  }
227
- console.log("el clonado:::", flowDataClone);
228
227
  const dataNode = await Node_1.default.findOne({ where: { flowId: params.flowId, isInit: 'Y', isActive: true }, order: { nodeId: "ASC" } });
229
228
  dataNode && await this.copyNode(dataNode, flowDataClone.flowId, manager, true);
230
229
  return { success: true, flowId: flowDataClone.flowId };
@@ -234,6 +233,7 @@ let Flow = class Flow extends core_1.Controller {
234
233
  }
235
234
  }
236
235
  async saveFlow(params, manager) {
236
+ var _a, _b;
237
237
  let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
238
238
  let nodes = params.board.tasks ? params.board.tasks : [];
239
239
  let masterId = null;
@@ -325,6 +325,31 @@ let Flow = class Flow extends core_1.Controller {
325
325
  await manager.query(dNode);
326
326
  }
327
327
  }
328
+ if (flowIdDel.action.actionType.name === 'CHAINED FLOW') {
329
+ if (((_a = flowIdDel.action) === null || _a === void 0 ? void 0 : _a.configJsonTemplate) && flowIdDel.actionConfigJson) {
330
+ try {
331
+ const parsedConfig = JSON.parse(flowIdDel.action.configJsonTemplate);
332
+ const parsedValues = JSON.parse(flowIdDel.actionConfigJson);
333
+ if (parsedConfig.deleteController && parsedValues.flowId) {
334
+ const params = {
335
+ flowId: parsedValues.flowId,
336
+ };
337
+ const config = {
338
+ method: "post",
339
+ url: `http://localhost:${process.env.PORT}/api/${parsedConfig.addController}`,
340
+ headers: {
341
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
342
+ "Content-Type": "application/json",
343
+ },
344
+ data: params,
345
+ };
346
+ }
347
+ }
348
+ catch (error) {
349
+ console.error("Not valid json", error);
350
+ }
351
+ }
352
+ }
328
353
  }
329
354
  else {
330
355
  throw new core_1.PxpError(400, 'Please turn off the flow before make a change');
@@ -350,6 +375,38 @@ let Flow = class Flow extends core_1.Controller {
350
375
  const saveNode = await manager.save(newNode);
351
376
  id = saveNode.nodeId;
352
377
  newId = saveNode.nodeId;
378
+ if (newAction.actionType.name === 'CHAINED FLOW') {
379
+ if (newAction === null || newAction === void 0 ? void 0 : newAction.configJsonTemplate) {
380
+ try {
381
+ const parsedConfig = JSON.parse(newAction.configJsonTemplate);
382
+ if (parsedConfig.addController && parsedConfig.template) {
383
+ const params = {
384
+ template: parsedConfig.template,
385
+ flowId,
386
+ };
387
+ const config = {
388
+ method: "post",
389
+ url: `http://localhost:${process.env.PORT}/api/${parsedConfig.addController}`,
390
+ headers: {
391
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
392
+ "Content-Type": "application/json",
393
+ },
394
+ data: params,
395
+ };
396
+ const resControllerAxios = await (0, axios_1.default)(config);
397
+ const chainedFlowId = (_b = resControllerAxios.data) === null || _b === void 0 ? void 0 : _b.flowId;
398
+ const parsedValues = {
399
+ flowId: chainedFlowId
400
+ };
401
+ saveNode.actionConfigJson = JSON.stringify(parsedValues);
402
+ await manager.save(saveNode);
403
+ }
404
+ }
405
+ catch (error) {
406
+ console.error("Not valid json", error);
407
+ }
408
+ }
409
+ }
353
410
  }
354
411
  else {
355
412
  id = nodeId;
@@ -399,13 +456,12 @@ let Flow = class Flow extends core_1.Controller {
399
456
  else {
400
457
  const oName = (_a = totalNodes === null || totalNodes === void 0 ? void 0 : totalNodes.action) === null || _a === void 0 ? void 0 : _a.originName;
401
458
  if (flow.templateType == 'funnel') {
402
- cond = `and (at.name ='PAGE') and (a.originName is null or a.originName = '${oName}')`;
459
+ cond = `and (at.name ='PAGE' || at.name = 'CHAINED FLOW') and (a.originName is null or a.originName = '${oName}')`;
403
460
  }
404
461
  else {
405
- cond = `and (at.name != 'EVENT' and at.name!='PAGE') and (a.originName is null or a.originName = '${oName}')`;
462
+ cond = `and (at.name != 'EVENT' and at.name!='PAGE' and at.name!='CHAINED FLOW') and (a.originName is null or a.originName = '${oName}')`;
406
463
  }
407
464
  }
408
- console.log("condicion es:", cond);
409
465
  let actions = await (0, typeorm_1.getManager)()
410
466
  .createQueryBuilder(Action_1.default, "a")
411
467
  .select([
@@ -419,7 +475,6 @@ let Flow = class Flow extends core_1.Controller {
419
475
  .innerJoin("a.actionType", "at")
420
476
  .where(`a.isActive = 1 and a.hidden = 'N'` + cond)
421
477
  .getMany();
422
- console.log("actions:", actions);
423
478
  const connections = await (0, typeorm_1.getManager)()
424
479
  .createQueryBuilder(NodeConnection_1.default, "nc")
425
480
  .select([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.94",
3
+ "version": "1.0.96",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",