@mldong/jeeflow 1.8.1 → 1.8.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.
Files changed (2) hide show
  1. package/dist/engine.js +30 -2
  2. package/package.json +1 -1
package/dist/engine.js CHANGED
@@ -81,6 +81,11 @@ export class EngineImpl {
81
81
  // ─── Execute ───────────────────────────────────────────────────────────────
82
82
  async executeProcessTask(taskId, operator, args = {}) {
83
83
  const { task, inst } = await this.loadAndCheck(taskId, operator);
84
+ // issues/26:办理提交的 f_ 字段按任务节点字段权限过滤(只读/隐藏不入变量)——
85
+ // 被拒值无法经流程变量落到下游节点写入,上游只读声明不可被绕过
86
+ const def = await this.repo.findDefineById(inst.defineId);
87
+ const flow = JSON.parse(typeof def.content === 'string' ? def.content : new TextDecoder().decode(def.content));
88
+ args = filterFieldByPerm(args, findNode(flow, task.taskName));
84
89
  const vars = { ...inst.variables, ...task.variables, ...args };
85
90
  await this.addUserInfo(operator, vars);
86
91
  const now = new Date();
@@ -91,8 +96,6 @@ export class EngineImpl {
91
96
  // completeTask 改的是外部任务对象,需同步回聚合根
92
97
  syncTaskToAggregate(inst, task);
93
98
  await this.fireEvent({ type: EventType.TaskComplete, instanceId: inst.id, taskId: task.id, nodeId: task.taskName, operator });
94
- const def = await this.repo.findDefineById(inst.defineId);
95
- const flow = JSON.parse(typeof def.content === 'string' ? def.content : new TextDecoder().decode(def.content));
96
99
  inst.variables = vars;
97
100
  await this.repo.updateInstance(inst);
98
101
  const curNode = findNode(flow, task.taskName);
@@ -472,3 +475,28 @@ function isTruthy(v) {
472
475
  return v !== 0;
473
476
  return v != null;
474
477
  }
478
+ /** 办理提交的 f_ 字段按任务节点 field 权限过滤(issues/26)——
479
+ * 任务节点 properties.field 声明 PERMISSION_f_{全名}(前端约定,优先)或
480
+ * PERMISSION_{去前缀名}(兼容)的字段,值非 EDIT(2)(只读 1/隐藏 3 等)→ 剔除不入变量。
481
+ * 键格式双兼容(issues/25),与 persist 拦截器 isEditable 同契约。 */
482
+ function filterFieldByPerm(args, node) {
483
+ if (Object.keys(args).length === 0 || !node || (node.type !== TypeTask && node.type !== TypeCustom))
484
+ return args;
485
+ const field = node.properties?.field;
486
+ if (!field || typeof field !== 'object' || Object.keys(field).length === 0)
487
+ return args;
488
+ const fieldPerm = field;
489
+ const out = {};
490
+ for (const [k, v] of Object.entries(args)) {
491
+ if (k.startsWith('f_') && k.length > 2) {
492
+ const name = k.slice(2);
493
+ let perm = fieldPerm[`PERMISSION_f_${name}`];
494
+ if (perm == null)
495
+ perm = fieldPerm[`PERMISSION_${name}`];
496
+ if (perm != null && Number(perm) !== 2)
497
+ continue; // 只读/隐藏:剔除(不入变量)
498
+ }
499
+ out[k] = v;
500
+ }
501
+ return out;
502
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mldong/jeeflow",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "jeeflow workflow engine — Node.js / TypeScript implementation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",