@mldong/jeeflow 1.8.0 → 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.
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/dist/persist.d.ts CHANGED
@@ -101,6 +101,10 @@ export declare class PersistPostInterceptor implements FlowInterceptor {
101
101
  /** 任务节点字段权限(node.properties.field 的 PERMISSION_x;缺省 null=全部可编辑) */
102
102
  private resolveFieldPermission;
103
103
  /** 字段可编辑判定:无声明或 EDIT(2) 可更新;READ_ONLY(1)/HIDDEN(3) 不更新 */
104
+ /** 字段可编辑判定:无声明或 EDIT(2) 可更新;READ_ONLY(1)/HIDDEN(3) 不更新。
105
+ * 键格式兼容两种(issues/25):
106
+ * - PERMISSION_f_{表单字段全名}——前端 vben5-wf 设计器约定(优先)
107
+ * - PERMISSION_{去前缀名}——后端 1.8.0 首版格式(兼容) */
104
108
  private isEditable;
105
109
  /** 状态字段写入:优先 {节点ID}_{状态码} 列,无则 {节点ID} 列(列探测过滤) */
106
110
  private putStateField;
package/dist/persist.js CHANGED
@@ -332,10 +332,17 @@ export class PersistPostInterceptor {
332
332
  return null;
333
333
  }
334
334
  /** 字段可编辑判定:无声明或 EDIT(2) 可更新;READ_ONLY(1)/HIDDEN(3) 不更新 */
335
+ /** 字段可编辑判定:无声明或 EDIT(2) 可更新;READ_ONLY(1)/HIDDEN(3) 不更新。
336
+ * 键格式兼容两种(issues/25):
337
+ * - PERMISSION_f_{表单字段全名}——前端 vben5-wf 设计器约定(优先)
338
+ * - PERMISSION_{去前缀名}——后端 1.8.0 首版格式(兼容) */
335
339
  isEditable(fieldPerm, fieldName) {
336
340
  if (!fieldPerm)
337
341
  return true;
338
- const perm = fieldPerm[`PERMISSION_${fieldName}`];
342
+ const prefix = this.fieldPrefix || 'f_';
343
+ let perm = fieldPerm[`PERMISSION_${prefix}${fieldName}`];
344
+ if (perm == null)
345
+ perm = fieldPerm[`PERMISSION_${fieldName}`];
339
346
  if (perm == null)
340
347
  return true;
341
348
  return Number(perm) === PermEdit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mldong/jeeflow",
3
- "version": "1.8.0",
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",