@pxp-nd/flow 1.0.31 → 1.0.34
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 +1 -1
- package/dist/controllers/Action.d.ts +20 -20
- package/dist/controllers/Action.js +82 -82
- package/dist/controllers/ActionType.d.ts +17 -17
- package/dist/controllers/ActionType.js +28 -28
- package/dist/controllers/Event.d.ts +17 -17
- package/dist/controllers/Event.js +28 -28
- package/dist/controllers/FieldMap.d.ts +17 -17
- package/dist/controllers/FieldMap.js +28 -28
- package/dist/controllers/Flow.d.ts +31 -24
- package/dist/controllers/Flow.js +415 -116
- package/dist/controllers/FlowInstance.d.ts +20 -20
- package/dist/controllers/FlowInstance.js +84 -84
- package/dist/controllers/Node.d.ts +23 -23
- package/dist/controllers/Node.js +273 -273
- package/dist/controllers/NodeInstance.d.ts +21 -21
- package/dist/controllers/NodeInstance.js +191 -191
- package/dist/controllers/OriginName.d.ts +17 -17
- package/dist/controllers/OriginName.js +28 -28
- package/dist/controllers/index.d.ts +11 -11
- package/dist/controllers/index.js +25 -25
- package/dist/entity/Action.d.ts +20 -20
- package/dist/entity/Action.js +85 -85
- package/dist/entity/ActionType.d.ts +16 -16
- package/dist/entity/ActionType.js +71 -71
- package/dist/entity/Event.d.ts +9 -9
- package/dist/entity/Event.js +44 -44
- package/dist/entity/FieldMap.d.ts +11 -11
- package/dist/entity/FieldMap.js +52 -52
- package/dist/entity/Flow.d.ts +14 -14
- package/dist/entity/Flow.js +60 -60
- package/dist/entity/FlowInstance.d.ts +16 -16
- package/dist/entity/FlowInstance.js +69 -69
- package/dist/entity/Node.d.ts +23 -23
- package/dist/entity/Node.js +93 -93
- package/dist/entity/NodeConnection.d.ts +10 -10
- package/dist/entity/NodeConnection.js +49 -49
- package/dist/entity/NodeInstance.d.ts +13 -13
- package/dist/entity/NodeInstance.js +58 -58
- package/dist/entity/OriginName.d.ts +9 -9
- package/dist/entity/OriginName.js +43 -43
- package/dist/entity/index.d.ts +23 -23
- package/dist/entity/index.js +27 -27
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -15
- package/dist/subscribers/Event.d.ts +21 -21
- package/dist/subscribers/Event.js +85 -85
- package/dist/subscribers/index.d.ts +3 -3
- package/dist/subscribers/index.js +6 -6
- package/package.json +45 -45
- package/tsconfig.json +29 -29
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Event = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* Kplian 2021
|
|
15
|
-
*
|
|
16
|
-
* MIT
|
|
17
|
-
*
|
|
18
|
-
* Member Controller
|
|
19
|
-
*
|
|
20
|
-
* @summary Event Subscriber
|
|
21
|
-
* @author Favio Figueroa
|
|
22
|
-
* Jaime Rivera
|
|
23
|
-
*
|
|
24
|
-
* Created at : 2021-07-08 12:55:38
|
|
25
|
-
* Last modified :
|
|
26
|
-
*/
|
|
27
|
-
const typeorm_1 = require("typeorm");
|
|
28
|
-
const Event_1 = __importDefault(require("../entity/Event"));
|
|
29
|
-
const Node_1 = __importDefault(require("../entity/Node"));
|
|
30
|
-
const Action_1 = __importDefault(require("../entity/Action"));
|
|
31
|
-
const Flow_1 = __importDefault(require("../entity/Flow"));
|
|
32
|
-
const core_1 = require("@pxp-nd/core");
|
|
33
|
-
const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
|
|
34
|
-
let Event = class Event {
|
|
35
|
-
listenTo() {
|
|
36
|
-
return Event_1.default;
|
|
37
|
-
}
|
|
38
|
-
async afterInsert(event) {
|
|
39
|
-
console.log("entra");
|
|
40
|
-
//todo investigate replace variables into condition
|
|
41
|
-
const newEvent = event.entity;
|
|
42
|
-
const node = await core_1.__(Node_1.default.find({ where: { actionId: newEvent.actionId } }));
|
|
43
|
-
for (const n of node) {
|
|
44
|
-
//get data of view
|
|
45
|
-
const { action: { originName, originKey }, } = n;
|
|
46
|
-
const executeView = `select * from ${originName} where ${originKey} = ${newEvent.dataId}`;
|
|
47
|
-
const resExecuteView = await typeorm_1.getManager().query(executeView);
|
|
48
|
-
const flow = await core_1.__(Flow_1.default.findOne({ where: { flowId: n.flowId } }));
|
|
49
|
-
if (flow.vendorId == resExecuteView[0].vendor_id &&
|
|
50
|
-
(await this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId))) {
|
|
51
|
-
//now check all conditions
|
|
52
|
-
let flowInstance = new FlowInstance_1.default();
|
|
53
|
-
flowInstance.flowId = n.flowId;
|
|
54
|
-
flowInstance.dataId = newEvent.dataId;
|
|
55
|
-
flowInstance.originName = originName;
|
|
56
|
-
flowInstance.originKey = originKey;
|
|
57
|
-
flowInstance.actionId = newEvent.actionId;
|
|
58
|
-
flowInstance.status = "pending";
|
|
59
|
-
flowInstance = await event.manager.save(FlowInstance_1.default, flowInstance);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
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
|
-
let res = true;
|
|
67
|
-
if (action.eventConfig && node.actionConfigJson) {
|
|
68
|
-
const eventConfig = JSON.parse(action.eventConfig);
|
|
69
|
-
const actionConfigJson = JSON.parse(node.actionConfigJson);
|
|
70
|
-
if (eventConfig.filters) {
|
|
71
|
-
eventConfig.filters.forEach((filter) => {
|
|
72
|
-
if (actionConfigJson[filter.nodeField] &&
|
|
73
|
-
viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
|
|
74
|
-
res = false;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return res;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
Event = __decorate([
|
|
83
|
-
typeorm_1.EventSubscriber()
|
|
84
|
-
], Event);
|
|
85
|
-
exports.Event = Event;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Event = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Kplian 2021
|
|
15
|
+
*
|
|
16
|
+
* MIT
|
|
17
|
+
*
|
|
18
|
+
* Member Controller
|
|
19
|
+
*
|
|
20
|
+
* @summary Event Subscriber
|
|
21
|
+
* @author Favio Figueroa
|
|
22
|
+
* Jaime Rivera
|
|
23
|
+
*
|
|
24
|
+
* Created at : 2021-07-08 12:55:38
|
|
25
|
+
* Last modified :
|
|
26
|
+
*/
|
|
27
|
+
const typeorm_1 = require("typeorm");
|
|
28
|
+
const Event_1 = __importDefault(require("../entity/Event"));
|
|
29
|
+
const Node_1 = __importDefault(require("../entity/Node"));
|
|
30
|
+
const Action_1 = __importDefault(require("../entity/Action"));
|
|
31
|
+
const Flow_1 = __importDefault(require("../entity/Flow"));
|
|
32
|
+
const core_1 = require("@pxp-nd/core");
|
|
33
|
+
const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
|
|
34
|
+
let Event = class Event {
|
|
35
|
+
listenTo() {
|
|
36
|
+
return Event_1.default;
|
|
37
|
+
}
|
|
38
|
+
async afterInsert(event) {
|
|
39
|
+
console.log("entra");
|
|
40
|
+
//todo investigate replace variables into condition
|
|
41
|
+
const newEvent = event.entity;
|
|
42
|
+
const node = await core_1.__(Node_1.default.find({ where: { actionId: newEvent.actionId } }));
|
|
43
|
+
for (const n of node) {
|
|
44
|
+
//get data of view
|
|
45
|
+
const { action: { originName, originKey }, } = n;
|
|
46
|
+
const executeView = `select * from ${originName} where ${originKey} = ${newEvent.dataId}`;
|
|
47
|
+
const resExecuteView = await typeorm_1.getManager().query(executeView);
|
|
48
|
+
const flow = await core_1.__(Flow_1.default.findOne({ where: { flowId: n.flowId } }));
|
|
49
|
+
if (flow.vendorId == resExecuteView[0].vendor_id &&
|
|
50
|
+
(await this.checkConditions(resExecuteView[0], n.flowId, newEvent.actionId))) {
|
|
51
|
+
//now check all conditions
|
|
52
|
+
let flowInstance = new FlowInstance_1.default();
|
|
53
|
+
flowInstance.flowId = n.flowId;
|
|
54
|
+
flowInstance.dataId = newEvent.dataId;
|
|
55
|
+
flowInstance.originName = originName;
|
|
56
|
+
flowInstance.originKey = originKey;
|
|
57
|
+
flowInstance.actionId = newEvent.actionId;
|
|
58
|
+
flowInstance.status = "pending";
|
|
59
|
+
flowInstance = await event.manager.save(FlowInstance_1.default, flowInstance);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
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
|
+
let res = true;
|
|
67
|
+
if (action.eventConfig && node.actionConfigJson) {
|
|
68
|
+
const eventConfig = JSON.parse(action.eventConfig);
|
|
69
|
+
const actionConfigJson = JSON.parse(node.actionConfigJson);
|
|
70
|
+
if (eventConfig.filters) {
|
|
71
|
+
eventConfig.filters.forEach((filter) => {
|
|
72
|
+
if (actionConfigJson[filter.nodeField] &&
|
|
73
|
+
viewData[filter.originField] != actionConfigJson[filter.nodeField]) {
|
|
74
|
+
res = false;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return res;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
Event = __decorate([
|
|
83
|
+
typeorm_1.EventSubscriber()
|
|
84
|
+
], Event);
|
|
85
|
+
exports.Event = Event;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Event as EventSubscriber } from './Event';
|
|
2
|
-
export { EventSubscriber };
|
|
3
|
-
export declare const subscribers: (typeof EventSubscriber)[];
|
|
1
|
+
import { Event as EventSubscriber } from './Event';
|
|
2
|
+
export { EventSubscriber };
|
|
3
|
+
export declare const subscribers: (typeof EventSubscriber)[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.subscribers = exports.EventSubscriber = void 0;
|
|
4
|
-
const Event_1 = require("./Event");
|
|
5
|
-
Object.defineProperty(exports, "EventSubscriber", { enumerable: true, get: function () { return Event_1.Event; } });
|
|
6
|
-
exports.subscribers = [Event_1.Event];
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribers = exports.EventSubscriber = void 0;
|
|
4
|
+
const Event_1 = require("./Event");
|
|
5
|
+
Object.defineProperty(exports, "EventSubscriber", { enumerable: true, get: function () { return Event_1.Event; } });
|
|
6
|
+
exports.subscribers = [Event_1.Event];
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pxp-nd/flow",
|
|
3
|
-
"version": "1.0.
|
|
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.34",
|
|
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
|
+
}
|