@pxp-nd/flow 1.0.19 → 1.0.23

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.
package/README.md CHANGED
@@ -1 +1 @@
1
- # flow-nd
1
+ # flow-nd
@@ -69,6 +69,7 @@ let Flow = class Flow extends core_1.Controller {
69
69
  const newFlow = new Flow_1.default();
70
70
  Object.assign(newFlow, flowToCopy);
71
71
  newFlow.name = params.name;
72
+ newFlow.description = params.description;
72
73
  const insertNewFlow = await core_1.__(manager.save(Flow_1.default, newFlow));
73
74
  // create the nodes
74
75
  // get the first node "the trigger node"
@@ -29,6 +29,7 @@ const typeorm_1 = require("typeorm");
29
29
  const Node_1 = __importDefault(require("../entity/Node"));
30
30
  const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
31
31
  const core_1 = require("@pxp-nd/core");
32
+ const lodash_1 = __importDefault(require("lodash"));
32
33
  const FieldMap_1 = __importDefault(require("../entity/FieldMap"));
33
34
  const OriginName_1 = __importDefault(require("../entity/OriginName"));
34
35
  let Node = class Node extends core_1.Controller {
@@ -79,7 +80,8 @@ let Node = class Node extends core_1.Controller {
79
80
  };
80
81
  }
81
82
  async getParameterizedNode(params, manager) {
82
- const { nodeId, flowId } = params;
83
+ lodash_1.default.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
84
+ const { nodeId, flowId, substitutionsSchemaJson } = params;
83
85
  /*const tNodeOrigin = __(NodeModel.find({
84
86
  relations: ['action'],
85
87
  where: {
@@ -101,10 +103,12 @@ let Node = class Node extends core_1.Controller {
101
103
  tNodeData,
102
104
  tFieldMapData
103
105
  ]);*/
104
- const { actionConfigJson, action: { configJsonTemplate, actionType: { schemaJson } } } = nodeData;
106
+ const { actionConfigJson, action: { schemaJson, configJsonTemplate, actionType: { schemaJson: schemaJsonFromActionType } } } = nodeData;
105
107
  const actionConfigJsonObject = actionConfigJson ? JSON.parse(actionConfigJson) : {};
106
108
  const configJsonTemplateObject = configJsonTemplate ? JSON.parse(configJsonTemplate) : {};
107
- let schemaJsonObject = schemaJson ? JSON.parse(schemaJson) : {};
109
+ let schemaJsonFromActionTypeObject = schemaJsonFromActionType ? JSON.parse(lodash_1.default.template(schemaJsonFromActionType)(substitutionsSchemaJson)) : {};
110
+ let schemaJsonFromActionObject = schemaJson ? JSON.parse(lodash_1.default.template(schemaJson)(substitutionsSchemaJson)) : {};
111
+ let schemaJsonObject = { ...schemaJsonFromActionTypeObject, ...schemaJsonFromActionObject };
108
112
  const mergeValues = {
109
113
  ...configJsonTemplateObject,
110
114
  ...actionConfigJsonObject
@@ -177,7 +181,7 @@ __decorate([
177
181
  __metadata("design:returntype", Promise)
178
182
  ], Node.prototype, "AddActionConfigJson", null);
179
183
  __decorate([
180
- core_1.Get(),
184
+ core_1.Post(),
181
185
  core_1.DbSettings('Orm'),
182
186
  core_1.ReadOnly(false),
183
187
  core_1.Log(true),
@@ -11,7 +11,9 @@ export default class Action extends PxpEntity {
11
11
  originKey: string;
12
12
  controllerFunction: string;
13
13
  configJsonTemplate: string;
14
+ eventConfig: string;
14
15
  hidden: string;
16
+ schemaJson: string;
15
17
  actionType: ActionType;
16
18
  nodes: Node[];
17
19
  eventNodes: Node[];
@@ -54,10 +54,18 @@ __decorate([
54
54
  typeorm_1.Column({ name: 'config_json_template', type: 'text' }),
55
55
  __metadata("design:type", String)
56
56
  ], Action.prototype, "configJsonTemplate", void 0);
57
+ __decorate([
58
+ typeorm_1.Column({ name: 'event_config', type: 'text' }),
59
+ __metadata("design:type", String)
60
+ ], Action.prototype, "eventConfig", void 0);
57
61
  __decorate([
58
62
  typeorm_1.Column({ type: 'varchar', nullable: false, length: 1, default: 'N' }),
59
63
  __metadata("design:type", String)
60
64
  ], Action.prototype, "hidden", void 0);
65
+ __decorate([
66
+ typeorm_1.Column({ name: 'schema_json', type: 'text' }),
67
+ __metadata("design:type", String)
68
+ ], Action.prototype, "schemaJson", void 0);
61
69
  __decorate([
62
70
  typeorm_1.ManyToOne(() => ActionType_1.default, actionType => actionType.actions, { eager: true }),
63
71
  typeorm_1.JoinColumn({ name: 'action_type_id' }),
@@ -6,6 +6,7 @@ export default class Flow extends PxpEntity {
6
6
  vendorId: number;
7
7
  code: number;
8
8
  name: string;
9
+ description: string;
9
10
  enabled: string;
10
11
  type: string;
11
12
  instances: FlowInstance[];
@@ -34,6 +34,10 @@ __decorate([
34
34
  typeorm_1.Column({ type: 'varchar', nullable: false, length: 100 }),
35
35
  __metadata("design:type", String)
36
36
  ], Flow.prototype, "name", void 0);
37
+ __decorate([
38
+ typeorm_1.Column({ type: 'text', nullable: false }),
39
+ __metadata("design:type", String)
40
+ ], Flow.prototype, "description", void 0);
37
41
  __decorate([
38
42
  typeorm_1.Column({ type: 'varchar', nullable: false, length: 100 }),
39
43
  __metadata("design:type", String)
@@ -17,4 +17,5 @@ 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>;
20
+ checkConditions(viewData: Record<string, any>, flowId: number, actionId: number): Promise<boolean>;
20
21
  }
@@ -27,6 +27,7 @@ exports.Event = void 0;
27
27
  const typeorm_1 = require("typeorm");
28
28
  const Event_1 = __importDefault(require("../entity/Event"));
29
29
  const Node_1 = __importDefault(require("../entity/Node"));
30
+ const Action_1 = __importDefault(require("../entity/Action"));
30
31
  const Flow_1 = __importDefault(require("../entity/Flow"));
31
32
  const core_1 = require("@pxp-nd/core");
32
33
  const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
@@ -45,7 +46,9 @@ let Event = class Event {
45
46
  const executeView = `select * from ${originName} where ${originKey} = ${newEvent.dataId}`;
46
47
  const resExecuteView = await typeorm_1.getManager().query(executeView);
47
48
  const flow = await core_1.__(Flow_1.default.findOne({ where: { flowId: n.flowId } }));
48
- if (flow.vendorId == resExecuteView[0].vendor_id) {
49
+ const boolConditions = await core_1.__(this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId));
50
+ if (flow.vendorId == resExecuteView[0].vendor_id && boolConditions) {
51
+ //now check all conditions
49
52
  let flowInstance = new FlowInstance_1.default();
50
53
  flowInstance.flowId = n.flowId;
51
54
  flowInstance.dataId = newEvent.dataId;
@@ -57,6 +60,23 @@ let Event = class Event {
57
60
  }
58
61
  }
59
62
  }
63
+ async checkConditions(viewData, flowId, actionId) {
64
+ const action = await Action_1.default.findOne(actionId);
65
+ const node = await Node_1.default.findOne({ where: { actionId, flowId } });
66
+ const actionConfigJson = JSON.parse(node.actionConfigJson);
67
+ let res = true;
68
+ if (action.eventConfig) {
69
+ const eventConfig = JSON.parse(action.eventConfig);
70
+ if (eventConfig.filters) {
71
+ eventConfig.filters.forEach((filter) => {
72
+ if (actionConfigJson[filter.nodeField] && viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
73
+ res = false;
74
+ }
75
+ });
76
+ }
77
+ }
78
+ return res;
79
+ }
60
80
  };
61
81
  Event = __decorate([
62
82
  typeorm_1.EventSubscriber()
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@pxp-nd/flow",
3
- "version": "1.0.19",
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
- "devDependencies": {
32
- "@types/lodash": "^4.14.172",
33
- "@types/node": "^16.4.13",
34
- "rimraf": "^3.0.2",
35
- "tsc-watch": "^4.2.9",
36
- "typescript": "^4.2.4"
37
- },
38
- "dependencies": {
39
- "@pxp-nd/common": "^1.1.4",
40
- "@pxp-nd/core": "^1.1.13",
41
- "axios": "^0.21.1",
42
- "lodash": "^4.17.21",
43
- "typeorm": "^0.2.36"
44
- }
45
- }
1
+ {
2
+ "name": "@pxp-nd/flow",
3
+ "version": "1.0.23",
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
+ "devDependencies": {
32
+ "@types/lodash": "^4.14.172",
33
+ "@types/node": "^16.4.13",
34
+ "rimraf": "^3.0.2",
35
+ "tsc-watch": "^4.2.9",
36
+ "typescript": "^4.2.4"
37
+ },
38
+ "dependencies": {
39
+ "@pxp-nd/common": "^1.1.4",
40
+ "@pxp-nd/core": "^1.1.13",
41
+ "axios": "^0.21.1",
42
+ "lodash": "^4.17.21",
43
+ "typeorm": "^0.2.36"
44
+ }
45
+ }
package/tsconfig.json CHANGED
@@ -1,29 +1,29 @@
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
+ {
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
+ }