@steedos/process 2.2.52-beta.6 → 2.2.53-beta.2
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/LICENSE.txt +2 -5
- package/lib/approve.js +70 -24
- package/lib/approve.js.map +1 -1
- package/lib/express-middleware.js +9 -9
- package/lib/express-middleware.js.map +1 -1
- package/lib/index.js +13 -2
- package/lib/index.js.map +1 -1
- package/lib/notifications.js +93 -42
- package/lib/notifications.js.map +1 -1
- package/lib/permission.js +111 -50
- package/lib/permission.js.map +1 -1
- package/lib/permission_manager.js +102 -40
- package/lib/permission_manager.js.map +1 -1
- package/lib/platform_action_manager.js +185 -91
- package/lib/platform_action_manager.js.map +1 -1
- package/lib/process_manager.js +770 -398
- package/lib/process_manager.js.map +1 -1
- package/lib/reassign.js +69 -23
- package/lib/reassign.js.map +1 -1
- package/lib/recall.js +73 -30
- package/lib/recall.js.map +1 -1
- package/lib/reject.js +68 -22
- package/lib/reject.js.map +1 -1
- package/lib/submit.js +68 -22
- package/lib/submit.js.map +1 -1
- package/package.json +6 -5
|
@@ -1,54 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
17
36
|
}
|
|
18
|
-
return false;
|
|
19
37
|
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.allowApprover = exports.allowRecall = exports.allowSubmit = void 0;
|
|
40
|
+
var process_manager_1 = require("./process_manager");
|
|
41
|
+
var objectql = require('@steedos/objectql');
|
|
42
|
+
var allowSubmit = function (objectName, recordId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var pendingInstances, processDefinition;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0: return [4 /*yield*/, (0, process_manager_1.getReocrdProcessInstance)(objectName, recordId, 'pending', userSession)];
|
|
47
|
+
case 1:
|
|
48
|
+
pendingInstances = _a.sent();
|
|
49
|
+
if (!(pendingInstances.length > 0)) return [3 /*break*/, 2];
|
|
50
|
+
return [2 /*return*/, false];
|
|
51
|
+
case 2: return [4 /*yield*/, (0, process_manager_1.getObjectProcessDefinition)(objectName, recordId, userSession)];
|
|
52
|
+
case 3:
|
|
53
|
+
processDefinition = _a.sent();
|
|
54
|
+
if (processDefinition) {
|
|
55
|
+
//TODO 提交权限 https://help.salesforce.com/articleView?err=1&id=approvals_create_submitters.htm&type=5
|
|
56
|
+
return [2 /*return*/, true];
|
|
57
|
+
}
|
|
58
|
+
_a.label = 4;
|
|
59
|
+
case 4: return [2 /*return*/, false];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); };
|
|
20
63
|
exports.allowSubmit = allowSubmit;
|
|
21
64
|
//调回:对象管理员或者提交者
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
65
|
+
var allowRecall = function (processInstanceId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
+
var processInstance, objectPermission, processDefinition;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0: return [4 /*yield*/, objectql.getObject("process_instance").findOne(processInstanceId)];
|
|
70
|
+
case 1:
|
|
71
|
+
processInstance = _a.sent();
|
|
72
|
+
return [4 /*yield*/, objectql.getObject(processInstance.target_object.o).getUserObjectPermission(userSession)];
|
|
73
|
+
case 2:
|
|
74
|
+
objectPermission = _a.sent();
|
|
75
|
+
if (objectPermission.modifyAllRecords) {
|
|
76
|
+
return [2 /*return*/, true];
|
|
77
|
+
}
|
|
78
|
+
if (processInstance.submitted_by != userSession.userId) {
|
|
79
|
+
return [2 /*return*/, false];
|
|
80
|
+
}
|
|
81
|
+
return [4 /*yield*/, objectql.getObject("process_definition").findOne(processInstance.process_definition)];
|
|
82
|
+
case 3:
|
|
83
|
+
processDefinition = _a.sent();
|
|
84
|
+
if (processDefinition.allow_recall) {
|
|
85
|
+
return [2 /*return*/, true];
|
|
86
|
+
}
|
|
87
|
+
return [2 /*return*/, false];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); };
|
|
37
91
|
exports.allowRecall = allowRecall;
|
|
38
92
|
/**
|
|
39
93
|
* 包括 批准、拒绝、重新分配
|
|
40
94
|
* TODO 代理
|
|
41
95
|
* TODO 对象管理员(对象权限为修改所有)可以处理所有的待审核请求
|
|
42
96
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
var allowApprover = function (instanceHistoryId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
var workitem;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, (0, process_manager_1.getProcessInstanceWorkitem)(instanceHistoryId, userSession)];
|
|
102
|
+
case 1:
|
|
103
|
+
workitem = _a.sent();
|
|
104
|
+
if (workitem && workitem._id) {
|
|
105
|
+
return [2 /*return*/, true];
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return [2 /*return*/, false];
|
|
109
|
+
}
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); };
|
|
52
114
|
exports.allowApprover = allowApprover;
|
|
53
115
|
// export const allowEditRecord = async (objectName, recordId, userSession: any)=>{
|
|
54
116
|
// let processInstance = await objectql.getObject("process_instance").count({filters: [['target_object.o', '=', objectName],['target_object.ids', '=', recordId]]});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission_manager.js","sourceRoot":"","sources":["../src/permission_manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"permission_manager.js","sourceRoot":"","sources":["../src/permission_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAoH;AACpH,IAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAGvC,IAAM,WAAW,GAAG,UAAO,UAAkB,EAAE,QAAgB,EAAE,WAAgB;;;;oBAC3D,qBAAM,IAAA,0CAAwB,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,EAAA;;gBAA/F,gBAAgB,GAAG,SAA4E;qBAClG,CAAA,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAA,EAA3B,wBAA2B;gBAC1B,sBAAO,KAAK,EAAC;oBAEa,qBAAM,IAAA,4CAA0B,EAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAA;;gBAAvF,iBAAiB,GAAG,SAAmE;gBAC7F,IAAG,iBAAiB,EAAC;oBACjB,mGAAmG;oBACnG,sBAAO,IAAI,EAAC;iBACf;;oBAGL,sBAAO,KAAK,EAAC;;;KAChB,CAAA;AAbY,QAAA,WAAW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|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const wnfilters = [];
|
|
11
|
-
switch (when) {
|
|
12
|
-
case 'approval':
|
|
13
|
-
if (!_.isEmpty(processNode.approval_updates_field_actions) && _.isArray(processNode.approval_updates_field_actions)) {
|
|
14
|
-
filters.push(['name', 'in', processNode.approval_updates_field_actions]);
|
|
15
|
-
}
|
|
16
|
-
if (!_.isEmpty(processNode.approval_workflow_notifications_actions) && _.isArray(processNode.approval_workflow_notifications_actions)) {
|
|
17
|
-
wnfilters.push(['name', 'in', processNode.approval_workflow_notifications_actions]);
|
|
18
|
-
}
|
|
19
|
-
break;
|
|
20
|
-
case 'rejection':
|
|
21
|
-
if (!_.isEmpty(processNode.rejection_updates_field_actions) && _.isArray(processNode.rejection_updates_field_actions)) {
|
|
22
|
-
filters.push(['name', 'in', processNode.rejection_updates_field_actions]);
|
|
23
|
-
}
|
|
24
|
-
if (!_.isEmpty(processNode.rejection_workflow_notifications_actions) && _.isArray(processNode.rejection_workflow_notifications_actions)) {
|
|
25
|
-
wnfilters.push(['name', 'in', processNode.rejection_workflow_notifications_actions]);
|
|
26
|
-
}
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
throw new objectql_1.SteedosError(`无效的参数when: ${when}`);
|
|
30
|
-
}
|
|
31
|
-
if (!_.isEmpty(filters)) {
|
|
32
|
-
const actions = await objectql.getObject("action_field_updates").find({ filters: filters });
|
|
33
|
-
for (const action of actions) {
|
|
34
|
-
await objectql.runFieldUpdateAction(action, recordId, userSession);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!_.isEmpty(wnfilters)) {
|
|
38
|
-
const notifications = await objectql.getObject("workflow_notifications").find({ filters: wnfilters });
|
|
39
|
-
for (const wn of notifications) {
|
|
40
|
-
await objectql.runWorkflowNotifyAction(wn, recordId, userSession);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
43
10
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
56
32
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
filters.push(['name', 'in', process.final_approval_updates_field_actions]);
|
|
61
|
-
}
|
|
62
|
-
if (!_.isEmpty(process.final_approval_workflow_notifications_actions) && _.isArray(process.final_approval_workflow_notifications_actions)) {
|
|
63
|
-
wnfilters.push(['name', 'in', process.final_approval_workflow_notifications_actions]);
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case 'final_rejection':
|
|
67
|
-
if (!_.isEmpty(process.final_rejection_updates_field_actions) && _.isArray(process.final_rejection_updates_field_actions)) {
|
|
68
|
-
filters.push(['name', 'in', process.final_rejection_updates_field_actions]);
|
|
69
|
-
}
|
|
70
|
-
if (!_.isEmpty(process.final_rejection_workflow_notifications_actions) && _.isArray(process.final_rejection_workflow_notifications_actions)) {
|
|
71
|
-
wnfilters.push(['name', 'in', process.final_rejection_workflow_notifications_actions]);
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
case 'recall':
|
|
75
|
-
if (!_.isEmpty(process.recall_updates_field_actions) && _.isArray(process.recall_updates_field_actions)) {
|
|
76
|
-
filters.push(['name', 'in', process.recall_updates_field_actions]);
|
|
77
|
-
}
|
|
78
|
-
if (!_.isEmpty(process.recall_workflow_notifications_actions) && _.isArray(process.recall_workflow_notifications_actions)) {
|
|
79
|
-
wnfilters.push(['name', 'in', process.recall_workflow_notifications_actions]);
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
throw new objectql_1.SteedosError(`无效的参数when: ${when}`);
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
84
36
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
37
|
+
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.runProcessAction = exports.runProcessNodeAction = void 0;
|
|
40
|
+
var objectql_1 = require("@steedos/objectql");
|
|
41
|
+
var objectql = require('@steedos/objectql');
|
|
42
|
+
var _ = require("underscore");
|
|
43
|
+
var runProcessNodeAction = function (processNodeId, when, recordId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var processNode, filters, wnfilters, actions, _i, actions_1, action, notifications, _a, notifications_1, wn;
|
|
45
|
+
return __generator(this, function (_b) {
|
|
46
|
+
switch (_b.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, objectql.getObject("process_node").findOne(processNodeId)];
|
|
48
|
+
case 1:
|
|
49
|
+
processNode = _b.sent();
|
|
50
|
+
filters = [];
|
|
51
|
+
wnfilters = [];
|
|
52
|
+
switch (when) {
|
|
53
|
+
case 'approval':
|
|
54
|
+
if (!_.isEmpty(processNode.approval_updates_field_actions) && _.isArray(processNode.approval_updates_field_actions)) {
|
|
55
|
+
filters.push(['name', 'in', processNode.approval_updates_field_actions]);
|
|
56
|
+
}
|
|
57
|
+
if (!_.isEmpty(processNode.approval_workflow_notifications_actions) && _.isArray(processNode.approval_workflow_notifications_actions)) {
|
|
58
|
+
wnfilters.push(['name', 'in', processNode.approval_workflow_notifications_actions]);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'rejection':
|
|
62
|
+
if (!_.isEmpty(processNode.rejection_updates_field_actions) && _.isArray(processNode.rejection_updates_field_actions)) {
|
|
63
|
+
filters.push(['name', 'in', processNode.rejection_updates_field_actions]);
|
|
64
|
+
}
|
|
65
|
+
if (!_.isEmpty(processNode.rejection_workflow_notifications_actions) && _.isArray(processNode.rejection_workflow_notifications_actions)) {
|
|
66
|
+
wnfilters.push(['name', 'in', processNode.rejection_workflow_notifications_actions]);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw new objectql_1.SteedosError("\u65E0\u6548\u7684\u53C2\u6570when: ".concat(when));
|
|
71
|
+
}
|
|
72
|
+
if (!!_.isEmpty(filters)) return [3 /*break*/, 6];
|
|
73
|
+
return [4 /*yield*/, objectql.getObject("action_field_updates").find({ filters: filters })];
|
|
74
|
+
case 2:
|
|
75
|
+
actions = _b.sent();
|
|
76
|
+
_i = 0, actions_1 = actions;
|
|
77
|
+
_b.label = 3;
|
|
78
|
+
case 3:
|
|
79
|
+
if (!(_i < actions_1.length)) return [3 /*break*/, 6];
|
|
80
|
+
action = actions_1[_i];
|
|
81
|
+
return [4 /*yield*/, objectql.runFieldUpdateAction(action, recordId, userSession)];
|
|
82
|
+
case 4:
|
|
83
|
+
_b.sent();
|
|
84
|
+
_b.label = 5;
|
|
85
|
+
case 5:
|
|
86
|
+
_i++;
|
|
87
|
+
return [3 /*break*/, 3];
|
|
88
|
+
case 6:
|
|
89
|
+
if (!!_.isEmpty(wnfilters)) return [3 /*break*/, 11];
|
|
90
|
+
return [4 /*yield*/, objectql.getObject("workflow_notifications").find({ filters: wnfilters })];
|
|
91
|
+
case 7:
|
|
92
|
+
notifications = _b.sent();
|
|
93
|
+
_a = 0, notifications_1 = notifications;
|
|
94
|
+
_b.label = 8;
|
|
95
|
+
case 8:
|
|
96
|
+
if (!(_a < notifications_1.length)) return [3 /*break*/, 11];
|
|
97
|
+
wn = notifications_1[_a];
|
|
98
|
+
return [4 /*yield*/, objectql.runWorkflowNotifyAction(wn, recordId, userSession)];
|
|
99
|
+
case 9:
|
|
100
|
+
_b.sent();
|
|
101
|
+
_b.label = 10;
|
|
102
|
+
case 10:
|
|
103
|
+
_a++;
|
|
104
|
+
return [3 /*break*/, 8];
|
|
105
|
+
case 11: return [2 /*return*/];
|
|
89
106
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
107
|
+
});
|
|
108
|
+
}); };
|
|
109
|
+
exports.runProcessNodeAction = runProcessNodeAction;
|
|
110
|
+
var runProcessAction = function (processId, when, recordId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var process, filters, wnfilters, actions, _i, actions_2, action, notifications, _a, notifications_2, wn;
|
|
112
|
+
return __generator(this, function (_b) {
|
|
113
|
+
switch (_b.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, objectql.getObject("process_definition").findOne(processId)];
|
|
115
|
+
case 1:
|
|
116
|
+
process = _b.sent();
|
|
117
|
+
filters = [];
|
|
118
|
+
wnfilters = [];
|
|
119
|
+
switch (when) {
|
|
120
|
+
case 'initial_submission':
|
|
121
|
+
if (!_.isEmpty(process.initial_submission_updates_field_actions) && _.isArray(process.initial_submission_updates_field_actions)) {
|
|
122
|
+
filters.push(['name', 'in', process.initial_submission_updates_field_actions]);
|
|
123
|
+
}
|
|
124
|
+
if (!_.isEmpty(process.initial_submission_workflow_notifications_actions) && _.isArray(process.initial_submission_workflow_notifications_actions)) {
|
|
125
|
+
wnfilters.push(['name', 'in', process.initial_submission_workflow_notifications_actions]);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case 'final_approval':
|
|
129
|
+
if (!_.isEmpty(process.final_approval_updates_field_actions) && _.isArray(process.final_approval_updates_field_actions)) {
|
|
130
|
+
filters.push(['name', 'in', process.final_approval_updates_field_actions]);
|
|
131
|
+
}
|
|
132
|
+
if (!_.isEmpty(process.final_approval_workflow_notifications_actions) && _.isArray(process.final_approval_workflow_notifications_actions)) {
|
|
133
|
+
wnfilters.push(['name', 'in', process.final_approval_workflow_notifications_actions]);
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case 'final_rejection':
|
|
137
|
+
if (!_.isEmpty(process.final_rejection_updates_field_actions) && _.isArray(process.final_rejection_updates_field_actions)) {
|
|
138
|
+
filters.push(['name', 'in', process.final_rejection_updates_field_actions]);
|
|
139
|
+
}
|
|
140
|
+
if (!_.isEmpty(process.final_rejection_workflow_notifications_actions) && _.isArray(process.final_rejection_workflow_notifications_actions)) {
|
|
141
|
+
wnfilters.push(['name', 'in', process.final_rejection_workflow_notifications_actions]);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case 'recall':
|
|
145
|
+
if (!_.isEmpty(process.recall_updates_field_actions) && _.isArray(process.recall_updates_field_actions)) {
|
|
146
|
+
filters.push(['name', 'in', process.recall_updates_field_actions]);
|
|
147
|
+
}
|
|
148
|
+
if (!_.isEmpty(process.recall_workflow_notifications_actions) && _.isArray(process.recall_workflow_notifications_actions)) {
|
|
149
|
+
wnfilters.push(['name', 'in', process.recall_workflow_notifications_actions]);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
throw new objectql_1.SteedosError("\u65E0\u6548\u7684\u53C2\u6570when: ".concat(when));
|
|
154
|
+
}
|
|
155
|
+
if (!!_.isEmpty(filters)) return [3 /*break*/, 6];
|
|
156
|
+
return [4 /*yield*/, objectql.getObject("action_field_updates").find({ filters: filters })];
|
|
157
|
+
case 2:
|
|
158
|
+
actions = _b.sent();
|
|
159
|
+
_i = 0, actions_2 = actions;
|
|
160
|
+
_b.label = 3;
|
|
161
|
+
case 3:
|
|
162
|
+
if (!(_i < actions_2.length)) return [3 /*break*/, 6];
|
|
163
|
+
action = actions_2[_i];
|
|
164
|
+
return [4 /*yield*/, objectql.runFieldUpdateAction(action, recordId, userSession)];
|
|
165
|
+
case 4:
|
|
166
|
+
_b.sent();
|
|
167
|
+
_b.label = 5;
|
|
168
|
+
case 5:
|
|
169
|
+
_i++;
|
|
170
|
+
return [3 /*break*/, 3];
|
|
171
|
+
case 6:
|
|
172
|
+
if (!!_.isEmpty(wnfilters)) return [3 /*break*/, 11];
|
|
173
|
+
return [4 /*yield*/, objectql.getObject("workflow_notifications").find({ filters: wnfilters })];
|
|
174
|
+
case 7:
|
|
175
|
+
notifications = _b.sent();
|
|
176
|
+
_a = 0, notifications_2 = notifications;
|
|
177
|
+
_b.label = 8;
|
|
178
|
+
case 8:
|
|
179
|
+
if (!(_a < notifications_2.length)) return [3 /*break*/, 11];
|
|
180
|
+
wn = notifications_2[_a];
|
|
181
|
+
return [4 /*yield*/, objectql.runWorkflowNotifyAction(wn, recordId, userSession)];
|
|
182
|
+
case 9:
|
|
183
|
+
_b.sent();
|
|
184
|
+
_b.label = 10;
|
|
185
|
+
case 10:
|
|
186
|
+
_a++;
|
|
187
|
+
return [3 /*break*/, 8];
|
|
188
|
+
case 11: return [2 /*return*/];
|
|
95
189
|
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
190
|
+
});
|
|
191
|
+
}); };
|
|
98
192
|
exports.runProcessAction = runProcessAction;
|
|
99
193
|
//# sourceMappingURL=platform_action_manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform_action_manager.js","sourceRoot":"","sources":["../src/platform_action_manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform_action_manager.js","sourceRoot":"","sources":["../src/platform_action_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgD;AAChD,IAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC9C,IAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEzB,IAAM,oBAAoB,GAAG,UAAO,aAAqB,EAAE,IAAY,EAAE,QAAgB,EAAE,WAAgB;;;;oBAC1F,qBAAM,QAAQ,CAAC,SAA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