@pxp-nd/flow 1.0.21 → 1.0.22

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
@@ -11,6 +11,7 @@ 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;
15
16
  schemaJson: string;
16
17
  actionType: ActionType;
@@ -54,6 +54,10 @@ __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)
@@ -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,8 @@ 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
+ if (flow.vendorId == resExecuteView[0].vendor_id && this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId)) {
50
+ //now check all conditions
49
51
  let flowInstance = new FlowInstance_1.default();
50
52
  flowInstance.flowId = n.flowId;
51
53
  flowInstance.dataId = newEvent.dataId;
@@ -57,6 +59,23 @@ let Event = class Event {
57
59
  }
58
60
  }
59
61
  }
62
+ async checkConditions(viewData, flowId, actionId) {
63
+ const action = await Action_1.default.findOne(actionId);
64
+ const node = await Node_1.default.findOne({ where: { actionId, flowId } });
65
+ const actionConfigJson = JSON.parse(node.actionConfigJson);
66
+ let res = true;
67
+ if (action.eventConfig) {
68
+ const eventConfig = JSON.parse(action.eventConfig);
69
+ if (eventConfig.filters) {
70
+ eventConfig.filters.forEach((filter) => {
71
+ if (actionConfigJson[filter.nodeField] && viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
72
+ res = false;
73
+ }
74
+ });
75
+ }
76
+ }
77
+ return res;
78
+ }
60
79
  };
61
80
  Event = __decorate([
62
81
  typeorm_1.EventSubscriber()
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@pxp-nd/flow",
3
- "version": "1.0.21",
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.22",
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
+ }