@pxp-nd/flow 1.0.28 → 1.0.31

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.
@@ -157,6 +157,7 @@ let NodeInstance = class NodeInstance extends core_1.Controller {
157
157
  }));
158
158
  }
159
159
  catch (error) {
160
+ console.log(error);
160
161
  await manager.update(NodeInstance_1.default, nodeInstance.nodeInstanceId, {
161
162
  status: "ERROR",
162
163
  });
@@ -12,8 +12,8 @@
12
12
  * Created at : 2021-07-08 12:55:38
13
13
  * Last modified :
14
14
  */
15
- import { EntitySubscriberInterface, InsertEvent } from 'typeorm';
16
- import EventModel from '../entity/Event';
15
+ import { EntitySubscriberInterface, InsertEvent } from "typeorm";
16
+ import EventModel from "../entity/Event";
17
17
  export declare class Event implements EntitySubscriberInterface<EventModel> {
18
18
  listenTo(): typeof EventModel;
19
19
  afterInsert(event: InsertEvent<EventModel>): Promise<void>;
@@ -36,17 +36,18 @@ let Event = class Event {
36
36
  return Event_1.default;
37
37
  }
38
38
  async afterInsert(event) {
39
- console.log('entra');
39
+ console.log("entra");
40
40
  //todo investigate replace variables into condition
41
41
  const newEvent = event.entity;
42
42
  const node = await core_1.__(Node_1.default.find({ where: { actionId: newEvent.actionId } }));
43
43
  for (const n of node) {
44
44
  //get data of view
45
- const { action: { originName, originKey } } = n;
45
+ const { action: { originName, originKey }, } = n;
46
46
  const executeView = `select * from ${originName} where ${originKey} = ${newEvent.dataId}`;
47
47
  const resExecuteView = await typeorm_1.getManager().query(executeView);
48
48
  const flow = await core_1.__(Flow_1.default.findOne({ where: { flowId: n.flowId } }));
49
- if (flow.vendorId == resExecuteView[0].vendor_id && this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId)) {
49
+ if (flow.vendorId == resExecuteView[0].vendor_id &&
50
+ (await this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId))) {
50
51
  //now check all conditions
51
52
  let flowInstance = new FlowInstance_1.default();
52
53
  flowInstance.flowId = n.flowId;
@@ -54,7 +55,7 @@ let Event = class Event {
54
55
  flowInstance.originName = originName;
55
56
  flowInstance.originKey = originKey;
56
57
  flowInstance.actionId = newEvent.actionId;
57
- flowInstance.status = 'pending';
58
+ flowInstance.status = "pending";
58
59
  flowInstance = await event.manager.save(FlowInstance_1.default, flowInstance);
59
60
  }
60
61
  }
@@ -62,13 +63,14 @@ let Event = class Event {
62
63
  async checkConditions(viewData, flowId, actionId) {
63
64
  const action = await Action_1.default.findOne(actionId);
64
65
  const node = await Node_1.default.findOne({ where: { actionId, flowId } });
65
- const actionConfigJson = JSON.parse(node.actionConfigJson);
66
66
  let res = true;
67
- if (action.eventConfig) {
67
+ if (action.eventConfig && node.actionConfigJson) {
68
68
  const eventConfig = JSON.parse(action.eventConfig);
69
+ const actionConfigJson = JSON.parse(node.actionConfigJson);
69
70
  if (eventConfig.filters) {
70
71
  eventConfig.filters.forEach((filter) => {
71
- if (actionConfigJson[filter.nodeField] && viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
72
+ if (actionConfigJson[filter.nodeField] &&
73
+ viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
72
74
  res = false;
73
75
  }
74
76
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.28",
3
+ "version": "1.0.31",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",