@pxp-nd/flow 1.0.89 → 1.0.90

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.
@@ -65,6 +65,7 @@ const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
65
65
  const Flow_1 = __importDefault(require("../entity/Flow"));
66
66
  const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
67
67
  const NodeInstance_1 = __importDefault(require("../entity/NodeInstance"));
68
+ const Node_2 = __importDefault(require("./Node"));
68
69
  //import {configFacebookStrategy} from "./passport-facebook";
69
70
  let Flow = class Flow extends core_1.Controller {
70
71
  async get(params) {
@@ -378,20 +379,13 @@ let Flow = class Flow extends core_1.Controller {
378
379
  .where(`n.isActive = 1 and n.flowId = :flowId`, { flowId: params.flowId })
379
380
  .getOne();
380
381
  let cond = " and 0=0";
381
- console.log("totalNodes::::", totalNodes);
382
382
  if (!totalNodes) {
383
383
  cond = " and at.name= 'EVENT' ";
384
384
  }
385
385
  else {
386
386
  const oName = (_a = totalNodes === null || totalNodes === void 0 ? void 0 : totalNodes.action) === null || _a === void 0 ? void 0 : _a.originName;
387
- if (flow.templateType == 'funnel') {
388
- console.log("es funnel???");
389
- cond = `and at.name = 'PAGE' `;
390
- }
391
- else {
392
- cond = `and (at.name != 'EVENT' and at.name!='PAGE') and (a.originName is null or a.originName = '${oName}')`;
393
- }
394
- console.log("cond:", cond);
387
+ //
388
+ cond = `and at.name != 'EVENT' and (a.originName is null or a.originName = '${oName}')`;
395
389
  }
396
390
  let actions = await (0, typeorm_1.getManager)()
397
391
  .createQueryBuilder(Action_1.default, "a")
@@ -604,6 +598,12 @@ let Flow = class Flow extends core_1.Controller {
604
598
  const valueNode = !node.actionConfigJson ? {} : JSON.parse(node.actionConfigJson);
605
599
  const valueAction = !node.action.configJsonTemplate ? {} : JSON.parse(node.action.configJsonTemplate);
606
600
  const values = _.merge({}, valueAction, valueNode);
601
+ //valid controllerValidation
602
+ const { action: { actionType } } = node;
603
+ const { validationController } = actionType;
604
+ const nodeController = new Node_2.default('flow-nd');
605
+ await nodeController.executeValidationController({ validationController, actionConfigJson: values, showException: true });
606
+ //end valid controller
607
607
  const missingRequired = [];
608
608
  required.forEach((property) => {
609
609
  if (!values.hasOwnProperty(property)) {
@@ -9,15 +9,26 @@
9
9
  * 08-Jul-2021 Favio Figueroa Created
10
10
  * 04-Sep-2023 SP08SEP23 Rensi Arteaga add modifiedAt for flows
11
11
  * 29-Sep-2023 SP06OCT23 Mercedes Zambrana Add validation when flow is on
12
+ * 19-Jan-2025 8201489097 Favio Figueroa Add Controller Validation
12
13
  * ******************************************************************************
13
14
  */
14
15
  import { EntityManager } from 'typeorm';
15
16
  import { Controller } from '@pxp-nd/core';
17
+ interface InterfaceParamsExecuteValidationController {
18
+ validationController: string;
19
+ actionConfigJson: Record<any, any>;
20
+ showException?: boolean;
21
+ }
22
+ interface InterfaceResExecuteValidationController {
23
+ validated: boolean;
24
+ msg: string;
25
+ }
16
26
  declare class Node extends Controller {
17
27
  getNodeData(node: any, dataId: any, manager: EntityManager): Promise<string>;
18
28
  add(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
19
29
  AddActionConfigJson(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
20
30
  getParameterizedNode(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
21
31
  executeActionJson(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
32
+ executeValidationController(params: InterfaceParamsExecuteValidationController): Promise<InterfaceResExecuteValidationController>;
22
33
  }
23
34
  export default Node;
@@ -10,6 +10,7 @@
10
10
  * 08-Jul-2021 Favio Figueroa Created
11
11
  * 04-Sep-2023 SP08SEP23 Rensi Arteaga add modifiedAt for flows
12
12
  * 29-Sep-2023 SP06OCT23 Mercedes Zambrana Add validation when flow is on
13
+ * 19-Jan-2025 8201489097 Favio Figueroa Add Controller Validation
13
14
  * ******************************************************************************
14
15
  */
15
16
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -73,6 +74,7 @@ let Node = class Node extends core_1.Controller {
73
74
  return nodeData;
74
75
  }
75
76
  async AddActionConfigJson(params, manager) {
77
+ let validated = { validated: true, msg: "SUCCESS" };
76
78
  let { nodeId: removed, __metadata: removed2, ...actionConfigJson } = params;
77
79
  Object.entries(params.__metadata).forEach(([nameKey, values]) => {
78
80
  actionConfigJson[nameKey] = `{{ ${values.name} }}`;
@@ -90,6 +92,9 @@ let Node = class Node extends core_1.Controller {
90
92
  }
91
93
  }
92
94
  }
95
+ const { action: { actionType } } = dataNode;
96
+ const { validationController } = actionType;
97
+ await this.executeValidationController({ validationController, actionConfigJson, showException: true });
93
98
  if (allowChange) {
94
99
  const upd = await (0, core_1.__)(manager.update(Node_1.default, params.nodeId, {
95
100
  actionConfigJson: JSON.stringify(actionConfigJson),
@@ -265,6 +270,28 @@ let Node = class Node extends core_1.Controller {
265
270
  ...resExecuteView[0]
266
271
  };
267
272
  }
273
+ async executeValidationController(params) {
274
+ const { validationController, actionConfigJson, showException = false } = params;
275
+ let validated = { validated: true, msg: "NOTHING TO VALIDATE" };
276
+ if (validationController) {
277
+ const config = {
278
+ method: "post",
279
+ url: `http://localhost:${process.env.PORT}/api/${validationController}`,
280
+ headers: {
281
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
282
+ "Content-Type": "application/json",
283
+ },
284
+ data: actionConfigJson,
285
+ };
286
+ // @ts-ignore
287
+ const resValidationControllerAxios = await (0, core_1.__)((0, axios_1.default)(config));
288
+ validated = resValidationControllerAxios.data || { validated: false, msg: "ERROR" };
289
+ if (!validated.validated && showException) {
290
+ throw new core_1.PxpError(400, validated.msg);
291
+ }
292
+ }
293
+ return validated;
294
+ }
268
295
  };
269
296
  __decorate([
270
297
  (0, core_1.Post)(),
@@ -1,3 +1,15 @@
1
+ /**
2
+ * ******************************************************************************
3
+ * NAME: Node.ts
4
+ * DEVELOPER: Favio Figueroa
5
+ * DESCRIPTION: Flow Controller
6
+ * REVISIONS:
7
+ * Date Change ID Author Description
8
+ * -------------- ----------- -------------- ------------------------------------
9
+ * 08-Jul-2021 Favio Figueroa Created
10
+ * 19-Jan-2025 8201489097 Favio Figueroa Added validation_controller
11
+ * ******************************************************************************
12
+ */
1
13
  import Action from './Action';
2
14
  import { PxpEntity } from '@pxp-nd/common';
3
15
  export default class ActionType extends PxpEntity {
@@ -12,5 +24,6 @@ export default class ActionType extends PxpEntity {
12
24
  controller: string;
13
25
  extraSchemaJson: string;
14
26
  actionsJson: string;
27
+ validationController: string;
15
28
  actions: Action[];
16
29
  }
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ /**
3
+ * ******************************************************************************
4
+ * NAME: Node.ts
5
+ * DEVELOPER: Favio Figueroa
6
+ * DESCRIPTION: Flow Controller
7
+ * REVISIONS:
8
+ * Date Change ID Author Description
9
+ * -------------- ----------- -------------- ------------------------------------
10
+ * 08-Jul-2021 Favio Figueroa Created
11
+ * 19-Jan-2025 8201489097 Favio Figueroa Added validation_controller
12
+ * ******************************************************************************
13
+ */
2
14
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
15
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
16
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -61,6 +73,10 @@ __decorate([
61
73
  (0, typeorm_1.Column)({ name: 'actions_json', type: 'text' }),
62
74
  __metadata("design:type", String)
63
75
  ], ActionType.prototype, "actionsJson", void 0);
76
+ __decorate([
77
+ (0, typeorm_1.Column)({ name: 'validation_controller', type: 'text' }),
78
+ __metadata("design:type", String)
79
+ ], ActionType.prototype, "validationController", void 0);
64
80
  __decorate([
65
81
  (0, typeorm_1.OneToMany)(() => Action_1.default, (action) => action.actionType),
66
82
  __metadata("design:type", Array)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- # flow-nd
@@ -1,39 +0,0 @@
1
- {
2
- "name": "@pxp-nd/flow",
3
- "version": "1.0.83",
4
- "description": "Workflow module for pxp-nd framework",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "prepublish": "tsc",
8
- "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "build": "rimraf ./dist && tsc",
11
- "dev:publish": "yalc publish",
12
- "prod:publish": "npm publish",
13
- "dev": "tsc-watch --target es2017 --outDir ./dist --onSuccess \"node .\"",
14
- "start": "npm run build && node dist/index.js"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/kplian/flow-nd.git"
19
- },
20
- "keywords": [
21
- "flow",
22
- "pxp",
23
- "pxp-nd"
24
- ],
25
- "author": "Kplian",
26
- "license": "ISC",
27
- "bugs": {
28
- "url": "https://github.com/kplian/flow-nd/issues"
29
- },
30
- "homepage": "https://github.com/kplian/flow-nd#readme",
31
- "dependencies": {
32
- "@pxp-nd/common": "^1.1.4",
33
- "@pxp-nd/core": "^1.1.13",
34
- "axios": "^0.21.1",
35
- "lodash": "^4.17.21",
36
- "typeorm": "^0.2.36"
37
- },
38
- "yalcSig": "cde9f14a08a99b57ae1fa35548ae318d"
39
- }
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2019",
4
- "module": "commonjs",
5
- "allowJs": false,
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "strict": false,
9
- "noImplicitAny": true,
10
- "esModuleInterop": true,
11
- "resolveJsonModule": true,
12
- "skipLibCheck": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "emitDecoratorMetadata": true,
15
- "experimentalDecorators": true,
16
- "moduleResolution": "node",
17
- "declaration": true,
18
- "isolatedModules": true,
19
- "strictPropertyInitialization": false,
20
- },
21
- "include": [
22
- "custom.d.ts",
23
- "src/**/*.ts"
24
- ],
25
- "exclude": [
26
- "node_modules",
27
- "dist"
28
- ]
29
- }
@@ -1 +0,0 @@
1
- cde9f14a08a99b57ae1fa35548ae318d
package/yalc.lock DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "version": "v1",
3
- "packages": {
4
- "@pxp-nd/flow": {
5
- "signature": "cde9f14a08a99b57ae1fa35548ae318d",
6
- "file": true
7
- }
8
- }
9
- }