@mldong/jeeflow 1.8.35 → 1.8.37
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.d.ts +69 -5
- package/dist/engine.js +263 -124
- package/dist/facade.d.ts +47 -0
- package/dist/facade.js +323 -21
- package/dist/index.d.ts +1 -1
- package/dist/jdbc/shared.d.ts +18 -0
- package/dist/jdbc/shared.js +83 -10
- package/dist/memory.d.ts +38 -1
- package/dist/memory.js +102 -19
- package/dist/model.d.ts +38 -0
- package/dist/model.js +42 -0
- package/dist/registry.d.ts +27 -1
- package/dist/registry.js +21 -1
- package/dist/spi.d.ts +217 -0
- package/dist/spi.js +188 -0
- package/package.json +1 -1
package/dist/facade.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
// 集成方只实现一个转发端点:把 body JSON 转成对象传入 flow(),所有流程能力按
|
|
4
4
|
// action(boot2/boot3 端点短名)路由。返回统一结构 {code, msg, data}
|
|
5
5
|
// (code=0 成功 / 99999999 失败)。操作人约定:args.operator 显式传入。
|
|
6
|
+
import { dirname as pathDirname, join as pathJoin, sep as pathSep } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
6
8
|
import { TaskState, } from './model.js';
|
|
7
|
-
|
|
9
|
+
// issues/142 B 批(spec 06 §2.11):transfer 的 fromActor/toActor 用 cc 侧已落地的那一枚单值判据归一
|
|
10
|
+
// (旧名 normalizeCcActorValue = 新名 normalizeActorValue,同一函数),不在此另写一份 trim+判空
|
|
11
|
+
import { normalizeActorValue } from './spi.js';
|
|
12
|
+
import { KeyAutoExecute, KeyAdminID, KeyCcActorsStart, KeyNextNodeOperator, KeyProcessStartNextNodeOperator, isCountersign, parseActorIds } from './engine.js';
|
|
8
13
|
import { EventType } from './extensions.js';
|
|
9
14
|
// submitType 枚举(对齐 boot3)
|
|
10
15
|
const SUBMIT_APPLY = 0;
|
|
@@ -15,6 +20,179 @@ const SUBMIT_JUMP = 4;
|
|
|
15
20
|
const SUBMIT_ROLLBACK_TO_OPERATOR = 6;
|
|
16
21
|
const SUBMIT_TRANSFER = 7;
|
|
17
22
|
const SUBMIT_COUNTERSIGN_DISAGREE = 20;
|
|
23
|
+
// ═══ issues/137 §3-1(spec 06 §2.12)· 门面内部异常出口:固定文案 +「谁写的这段文案」判别式 ═══
|
|
24
|
+
//
|
|
25
|
+
// 门面顶层 catch 捕获到的异常**不是都能把 message 原样放进 msg**。判据是「这段文案是谁写的」:
|
|
26
|
+
// 引擎自己写的中文契约文案(八栈、十三个集成壳与前端 toast 都按原文逐字对齐)必须照旧透出;
|
|
27
|
+
// 运行时/驱动/JSON 解析器/集成方 provider 写的原文属**内部实现细节**,透出去就是泄漏
|
|
28
|
+
// (`Cannot read properties of undefined (reading 'x')`、`Expected property name or '}' in JSON at
|
|
29
|
+
// position 1`、`ER_LOCK_WAIT_TIMEOUT: …`、`ENOENT: no such file or directory` 一类),对外一律只给
|
|
30
|
+
// 下面这一句固定文案;原文只进**日志与错误对象的 cause**,不得拼进 msg 或任何其它对外字段。
|
|
31
|
+
/** 内部异常对外只说这一句(八栈逐字同串,措辞不许改——owner 2026-10-02 第 3 问拍 A) */
|
|
32
|
+
export const INTERNAL_FAILURE_MSG = '流程处理失败';
|
|
33
|
+
/**
|
|
34
|
+
* 第 4 条的异常族清单(java 12 类 → node 等价类型)。实测映射:
|
|
35
|
+
* - `NullPointerException` / `ClassCastException` / `ReflectiveOperationException` → **TypeError**
|
|
36
|
+
* (空引用解引用在 node 就是 TypeError:`Cannot read properties of undefined (reading 'x')`)
|
|
37
|
+
* - `NumberFormatException` / `IndexOutOfBoundsException` / `ArithmeticException` / `StackOverflowError`
|
|
38
|
+
* → **RangeError**(`Invalid array length`、`Maximum call stack size exceeded`)
|
|
39
|
+
* - JSON 解析器与数字解析(`JSON.parse` 的 `Expected property name or '}' …`、`BigInt('12x')` 的
|
|
40
|
+
* `Cannot convert 12x to a BigInt`)→ **SyntaxError**
|
|
41
|
+
* - 未声明标识符 → **ReferenceError**;另含 node 自带的 `EvalError` / `URIError` / `AggregateError`
|
|
42
|
+
*
|
|
43
|
+
* ⚠️ **裸 `Error` 不在这一族**:本栈引擎的契约文案一律是裸 `new Error(中文文案)` 形状(现读全仓
|
|
44
|
+
* 81 处 throw 全是这个形状、零 `class *Error extends`),把 `Error` 加进来等于把整个契约面静默换成
|
|
45
|
+
* 固定文案——正是 spec §2.12「⚠️ 因此不能简单收窄」点名的事故。
|
|
46
|
+
* ⚠️ IO/驱动(java 的 `IOException` / `SQLException`)在 node 里 ctor 名**恰好也是 `Error`**
|
|
47
|
+
* (实测 fs 的 ENOENT、mysql2/pg 的查询错都这样),族清单抓不到 ⇒ 由第 5 条按抛出点归属兜住。
|
|
48
|
+
*/
|
|
49
|
+
const FOREIGN_ERROR_CTORS = new Set([
|
|
50
|
+
'TypeError', 'RangeError', 'SyntaxError', 'ReferenceError', 'EvalError', 'URIError', 'AggregateError',
|
|
51
|
+
]);
|
|
52
|
+
/**
|
|
53
|
+
* 第 3 条「裸包装」的 node 补充形状:`new Error(innerErr)` 会把 `String(innerErr)` 塞进 message
|
|
54
|
+
* 且**不保留** `.cause`(实测 `String(e.cause) === 'undefined'`),所以除了比对 cause 还要认这个
|
|
55
|
+
* `"SomeError: …"` 头部——首个空白前的那一段必须以 `Error`/`Exception` 结尾、紧跟 `": "`。
|
|
56
|
+
* 实测能认出:`Error: …`、`TypeError: …`、`java.lang.IllegalStateException: …`、
|
|
57
|
+
* `com.mysql.cj.jdbc.exceptions.SQLException: …`。
|
|
58
|
+
* 引擎 51 条契约文案没有一条长这样(全仓现读核过,并由测试 A9 那格自动守着:全部中文,或
|
|
59
|
+
* `define not found:` / `persist: …` / `operator … not allowed` 一类小写英文开头,首段都不以
|
|
60
|
+
* Error/Exception 结尾),不会误杀。
|
|
61
|
+
*/
|
|
62
|
+
const STRINGIFIED_ERROR_RE = /^\S*(?:Error|Exception): /;
|
|
63
|
+
const CASE_INSENSITIVE_FS = process.platform === 'win32' || process.platform === 'darwin';
|
|
64
|
+
/** 路径归一:统一分隔符;Windows/macOS 文件系统大小写不敏感 ⇒ 一并折叠 */
|
|
65
|
+
function canonPath(p) {
|
|
66
|
+
const n = p.replace(/\\/g, '/');
|
|
67
|
+
return CASE_INSENSITIVE_FS ? n.toLowerCase() : n;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 引擎自身代码所在目录(第 5 条「抛出点不在引擎包」的归属基准)。从**本模块**的 `import.meta.url`
|
|
71
|
+
* 反推,因此四种运行形态都自洽:tsx 直跑 `src/*.ts`、发版跑 `dist/*.js`、被打包器 bundle、
|
|
72
|
+
* 被集成方装进 `node_modules/@mldong/jeeflow/dist/`(此时基准跟着搬进 node_modules,
|
|
73
|
+
* 驱动仍在**别的** node_modules 目录 ⇒ 判据照样咬得上)。同时收 `file://` URL 形态,
|
|
74
|
+
* 因为部分运行时/打包器把栈帧写成 URL 而不是裸路径。
|
|
75
|
+
*/
|
|
76
|
+
const ENGINE_DIRS = (() => {
|
|
77
|
+
const out = [];
|
|
78
|
+
const push = (d) => {
|
|
79
|
+
if (!d)
|
|
80
|
+
return;
|
|
81
|
+
const c = canonPath(d.endsWith('/') ? d : d + '/');
|
|
82
|
+
if (!out.includes(c))
|
|
83
|
+
out.push(c);
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
const selfPath = fileURLToPath(import.meta.url); // <pkg>/src/facade.ts 或 <pkg>/dist/facade.js
|
|
87
|
+
const selfDir = pathDirname(selfPath); // <pkg>/src 或 <pkg>/dist
|
|
88
|
+
const pkgDir = pathDirname(selfDir); // <pkg>
|
|
89
|
+
push(selfDir);
|
|
90
|
+
push(pathJoin(pkgDir, 'src') + pathSep);
|
|
91
|
+
push(pathJoin(pkgDir, 'dist') + pathSep);
|
|
92
|
+
}
|
|
93
|
+
catch { /* 推不出裸路径形态 ⇒ 只留下面的 URL 形态 */ }
|
|
94
|
+
try {
|
|
95
|
+
const urlDir = import.meta.url.replace(/[^/]*$/, ''); // file://…/src/
|
|
96
|
+
const urlPkg = urlDir.replace(/[^/]*\/$/, ''); // file://…/
|
|
97
|
+
push(urlDir);
|
|
98
|
+
push(urlPkg + 'src/');
|
|
99
|
+
push(urlPkg + 'dist/');
|
|
100
|
+
}
|
|
101
|
+
catch { /* 推不出引擎位置 ⇒ 第 5 条整条失败开放(见 thrownInsideEngine) */ }
|
|
102
|
+
return out;
|
|
103
|
+
})();
|
|
104
|
+
/**
|
|
105
|
+
* 取栈顶帧(=抛出点)的位置串,取不到归属信息时返回 null。
|
|
106
|
+
* 认两种 V8 帧形状:`at fn (path:line:col)` 与 `at path:line:col`;`<anonymous>` / `native`
|
|
107
|
+
* (实测 `JSON.parse` 的 SyntaxError 栈顶就是 `at JSON.parse (<anonymous>)`,压根没有文件路径)
|
|
108
|
+
* 一律当"拿不到归属"。行尾的 `:line:col` 不剥——目录前缀匹配用不上它。
|
|
109
|
+
*/
|
|
110
|
+
function topFrameLocation(stack) {
|
|
111
|
+
if (typeof stack !== 'string' || stack === '')
|
|
112
|
+
return null;
|
|
113
|
+
for (const raw of stack.split('\n')) {
|
|
114
|
+
const line = raw.trim();
|
|
115
|
+
if (!line.startsWith('at '))
|
|
116
|
+
continue; // 跳过首行 `Name: message`
|
|
117
|
+
let loc = line.slice(3).trim();
|
|
118
|
+
const open = loc.lastIndexOf('(');
|
|
119
|
+
if (open >= 0 && loc.endsWith(')'))
|
|
120
|
+
loc = loc.slice(open + 1, -1).trim();
|
|
121
|
+
if (loc === '' || loc === '<anonymous>' || loc === 'native' || loc === 'unknown')
|
|
122
|
+
return null;
|
|
123
|
+
return canonPath(loc);
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 栈顶帧是否落在引擎自身代码里(java `thrownInsideEngine` 的 node 对应件)。
|
|
129
|
+
*
|
|
130
|
+
* ⚠️ **失败方向与 java 相反,是刻意的**:java 在 trace 为空时返回 false(⇒ 判成外来 ⇒ 挡掉),
|
|
131
|
+
* node 这里在"推不出引擎目录"或"栈顶帧拿不到路径"时返回 true(⇒ 判成引擎写的 ⇒ 放行)。
|
|
132
|
+
* 理由:node 的 `stack` 是 V8 私有格式、不是语言标准,`<anonymous>`/`native` 帧、`Error.stackTraceLimit`
|
|
133
|
+
* 截断、跨 worker 序列化丢栈、source-map 与打包器改写路径都会让它拿不到可用归属;而判据一旦误判成
|
|
134
|
+
* "外来",后果是**把引擎契约文案静默换成固定文案**(spec §2.12「⚠️ 因此不能简单收窄」点名的事故,
|
|
135
|
+
* 八栈+十三壳+前端 toast 全按原文对齐,没人会报警)。反过来误判成"引擎写的"只是漏挡一条内部原文,
|
|
136
|
+
* 而那条原文仍被第 1/3/4 条与日志兜着(`JSON.parse` 的 SyntaxError 正是第 4 条抓的,压根不依赖栈)。
|
|
137
|
+
* 两害相权,这条一律失败开放。
|
|
138
|
+
*/
|
|
139
|
+
function thrownInsideEngine(stack) {
|
|
140
|
+
if (ENGINE_DIRS.length === 0)
|
|
141
|
+
return true;
|
|
142
|
+
const loc = topFrameLocation(stack);
|
|
143
|
+
if (loc == null)
|
|
144
|
+
return true;
|
|
145
|
+
return ENGINE_DIRS.some(d => loc.startsWith(d));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 判「这条异常的 message 能不能原样进出口 msg」——抽成**纯函数**(java 参考实现=
|
|
149
|
+
* `JeeflowFacade.isForeignDetail(type, message, cause, trace)`,rust `parse_error_message`/
|
|
150
|
+
* moon `ParseErrorWithCause` + `detail()` 同姿势),文案判据与副作用(日志)各自可测:
|
|
151
|
+
* 本函数不读全局、不打日志、不抛异常,四个入参全是可序列化的裸值。
|
|
152
|
+
*
|
|
153
|
+
* 五条判据(顺序即优先级,返回 true ⇒ 属内部信息 ⇒ 出口只给 {@link INTERNAL_FAILURE_MSG}):
|
|
154
|
+
* 1. `message` 缺失/非字符串/纯空白 ⇒ 内部。兜底会吐 `String(e)` 的类名头部;空白串也不是
|
|
155
|
+
* "失败原因"(§2.1 要求 msg 承载原因)。
|
|
156
|
+
* 2. 属**契约异常族** ⇒ 逐字透出(本条返回 false)。⚠️ **本栈无处落**:node 引擎零
|
|
157
|
+
* `class *Error extends`,契约文案一律是裸 `Error` + 中文文案,没有可判的类型
|
|
158
|
+
* (见 docs/批三-3-1-落地记录 §1.5 node 行)⇒ 判据重心在第 4/5 条,此处**不留空实现假装覆盖**。
|
|
159
|
+
* 3. `message` 恰是 cause 的串化("裸包装",只是搬运下层原文)⇒ 内部。node 两种形状都认:
|
|
160
|
+
* `new Error(String(e), { cause: e })`(有 cause)与 `new Error(e)`(message=`String(e)`、
|
|
161
|
+
* 不保留 cause,靠 {@link STRINGIFIED_ERROR_RE} 认头部)。
|
|
162
|
+
* 4. 类型属运行时/解析器/反射自己抛的族 ⇒ 内部(见 {@link FOREIGN_ERROR_CTORS})。
|
|
163
|
+
* **node 的第 4 条比 java 好落**:`Error` 与 `TypeError`/`RangeError`/`SyntaxError`/
|
|
164
|
+
* `ReferenceError` 是可区分的构造器,而引擎契约文案一律用裸 `new Error(...)`。
|
|
165
|
+
* 5. 抛出点不在引擎包(node 内置模块、驱动 node_modules、集成方 provider、测试桩)⇒ 内部。
|
|
166
|
+
* 这一条是 node 覆盖 IO/驱动/第三方 provider 的**唯一**判据(它们的 ctor 名恰好都是 `Error`),
|
|
167
|
+
* 失败开放,理由见 {@link thrownInsideEngine}。
|
|
168
|
+
*
|
|
169
|
+
* @param ctorName 异常构造器名(`e?.constructor?.name ?? e?.name`)
|
|
170
|
+
* @param message 异常文案(可为 null/undefined/非字符串)
|
|
171
|
+
* @param cause 异常原因(可为 null;node 的 `{ cause }` 选项)
|
|
172
|
+
* @param stack 栈串(可为 null/undefined;格式不稳,见第 5 条)
|
|
173
|
+
* @returns true ⇒ 属内部信息,出口只给固定文案
|
|
174
|
+
*/
|
|
175
|
+
export function isForeignDetail(ctorName, message, cause, stack) {
|
|
176
|
+
// 1) message 缺失/非字符串/纯空白
|
|
177
|
+
if (typeof message !== 'string' || message.trim() === '')
|
|
178
|
+
return true;
|
|
179
|
+
// 2) 契约异常族:本栈无此类型(引擎契约文案=裸 Error),无处落 ⇒ 直接进第 3 条
|
|
180
|
+
// 3) 裸包装
|
|
181
|
+
if (cause != null) {
|
|
182
|
+
if (message === String(cause))
|
|
183
|
+
return true;
|
|
184
|
+
const cm = cause.message;
|
|
185
|
+
if (typeof cm === 'string' && cm !== '' && message === cm)
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
if (STRINGIFIED_ERROR_RE.test(message))
|
|
189
|
+
return true;
|
|
190
|
+
// 4) 运行时/解析器/反射族
|
|
191
|
+
if (typeof ctorName === 'string' && FOREIGN_ERROR_CTORS.has(ctorName))
|
|
192
|
+
return true;
|
|
193
|
+
// 5) 抛出点不在引擎包
|
|
194
|
+
return !thrownInsideEngine(stack);
|
|
195
|
+
}
|
|
18
196
|
export class JeeflowFacade {
|
|
19
197
|
engine;
|
|
20
198
|
repo;
|
|
@@ -54,6 +232,16 @@ export class JeeflowFacade {
|
|
|
54
232
|
return { code: 0, msg: '成功', data: data ?? null };
|
|
55
233
|
}
|
|
56
234
|
catch (e) {
|
|
235
|
+
// issues/137 §3-1(spec 06 §2.12):判别规则与理由见 isForeignDetail——引擎写的中文契约文案
|
|
236
|
+
// 照旧逐字透出(八栈+十三壳+前端 toast 都按原文对齐,不能在这条上收窄),只把**外来/内部
|
|
237
|
+
// 异常**(运行时/驱动/JSON 解析器/集成方 provider)的原文换成固定文案。
|
|
238
|
+
// 原文只进日志:console.error 把整个错误对象交出去,node 会连栈带 `[cause]:` 一起打出来
|
|
239
|
+
// ⇒ 批二 issues/139 挂在 `{ cause }` 里的解析器原文也在日志里,且**绝不**进 msg 或其它对外字段
|
|
240
|
+
// (实测 `String(err)` / `err.toString()` / `JSON.stringify(err)` 都不含 cause,不会顺带带出去)。
|
|
241
|
+
if (isForeignDetail(e?.constructor?.name ?? e?.name, e?.message, e?.cause, e?.stack)) {
|
|
242
|
+
console.error(`[jeeflow] action 执行失败: action=${action}`, e);
|
|
243
|
+
return { code: 99999999, msg: INTERNAL_FAILURE_MSG };
|
|
244
|
+
}
|
|
57
245
|
return { code: 99999999, msg: e?.message ?? String(e) };
|
|
58
246
|
}
|
|
59
247
|
}
|
|
@@ -140,6 +328,8 @@ export class JeeflowFacade {
|
|
|
140
328
|
return this.taskAddActor(args);
|
|
141
329
|
case 'processTask/transfer': // issues/115:转办(摘原人 + 换新人)
|
|
142
330
|
return this.taskTransfer(args);
|
|
331
|
+
case 'processTask/removeTaskActor': // issues/115 残留:门面第 47 个 action(只摘不加、零留痕)
|
|
332
|
+
return this.taskRemoveActor(args);
|
|
143
333
|
case 'processTask/latest':
|
|
144
334
|
return this.taskLatest(args);
|
|
145
335
|
case 'processInstance/stats/overview':
|
|
@@ -209,8 +399,12 @@ export class JeeflowFacade {
|
|
|
209
399
|
try {
|
|
210
400
|
flow = JSON.parse(content);
|
|
211
401
|
}
|
|
212
|
-
catch {
|
|
213
|
-
|
|
402
|
+
catch (e) {
|
|
403
|
+
// issues/139:八栈同一条腿用 java 逐字原文(ModelParser.java:47「读取流程定义 JSON 失败」),
|
|
404
|
+
// 原始异常只作 cause。issues/137 §3-1 之后门面顶层带判别式(isForeignDetail):这条是引擎自己
|
|
405
|
+
// 写的契约文案 ⇒ 仍逐字送进出口 msg;cause 里的 SyntaxError 原文只进日志,不会被带进 msg
|
|
406
|
+
// (`String(err)`/`err.toString()` 都不含 cause,见 flow() 顶层 catch 的注释)。
|
|
407
|
+
throw new Error('读取流程定义 JSON 失败', { cause: e });
|
|
214
408
|
}
|
|
215
409
|
const name = flow?.name;
|
|
216
410
|
if (!name)
|
|
@@ -235,8 +429,12 @@ export class JeeflowFacade {
|
|
|
235
429
|
try {
|
|
236
430
|
flow = JSON.parse(content);
|
|
237
431
|
}
|
|
238
|
-
catch {
|
|
239
|
-
|
|
432
|
+
catch (e) {
|
|
433
|
+
// issues/139:八栈同一条腿用 java 逐字原文(ModelParser.java:47「读取流程定义 JSON 失败」),
|
|
434
|
+
// 原始异常只作 cause。issues/137 §3-1 之后门面顶层带判别式(isForeignDetail):这条是引擎自己
|
|
435
|
+
// 写的契约文案 ⇒ 仍逐字送进出口 msg;cause 里的 SyntaxError 原文只进日志,不会被带进 msg
|
|
436
|
+
// (`String(err)`/`err.toString()` 都不含 cause,见 flow() 顶层 catch 的注释)。
|
|
437
|
+
throw new Error('读取流程定义 JSON 失败', { cause: e });
|
|
240
438
|
}
|
|
241
439
|
await this.repo.updateDefine({
|
|
242
440
|
id: defineId, name: flow?.name ?? '', displayName: flow?.displayName ?? '',
|
|
@@ -494,7 +692,10 @@ export class JeeflowFacade {
|
|
|
494
692
|
flow = JSON.parse(content);
|
|
495
693
|
}
|
|
496
694
|
catch (e) {
|
|
497
|
-
|
|
695
|
+
// issues/139(回到 issues/121 口径):出口 msg 只出 Java 参考实现的逐字固定文案
|
|
696
|
+
// (jeeflow-java ModelParser「读取流程定义 JSON 失败」,原始异常作为 cause 挂在错误对象上、
|
|
697
|
+
// 不进 msg)。此前拼 String(e) 会把 SyntaxError 文本连同内容片段透给前端与日志。
|
|
698
|
+
throw new Error('读取流程定义 JSON 失败', { cause: e });
|
|
498
699
|
}
|
|
499
700
|
if (!flow?.name)
|
|
500
701
|
throw new Error('流程定义缺少 name');
|
|
@@ -858,7 +1059,12 @@ export class JeeflowFacade {
|
|
|
858
1059
|
async createCCInstance(args) {
|
|
859
1060
|
const instanceId = toId(args.processInstanceId);
|
|
860
1061
|
const operator = operatorArg(args);
|
|
861
|
-
|
|
1062
|
+
// issues/141 G10「空不创建行」(spec 06 §2.10):手动腿与引擎两条腿走**同一个**归一函数
|
|
1063
|
+
// (`engine.parseActorIds` → `spi.normalizeActors`,逗号串与数组两形同判据;
|
|
1064
|
+
// `parseCcActors` 是 parseActorIds 的旧名,issues/142 B 批把它升为任务侧共用同一枚)——
|
|
1065
|
+
// 空串/纯空白/数组里的空元素(含 null,`String(null)` 会变成字面量 "null" 那条假归属人)一律丢弃;
|
|
1066
|
+
// 丢完为空 ⇒ 与上面那条"空集合=actorIds 缺失"同档(沿用既有文案,不新造错误码/文案)。
|
|
1067
|
+
const actors = parseActorIds(args.actorIds);
|
|
862
1068
|
if (actors.length === 0)
|
|
863
1069
|
throw new Error('actorIds 缺失');
|
|
864
1070
|
// issues/102 + issues/127/132:手动 CC 与发起/办理两条腿同码同漏斗——§11.2 原则 1
|
|
@@ -1026,8 +1232,16 @@ export class JeeflowFacade {
|
|
|
1026
1232
|
return result;
|
|
1027
1233
|
}
|
|
1028
1234
|
async taskAddActor(args) {
|
|
1235
|
+
// 主键档(spec 06 §2.11 末段):processTaskId 缺失/空串/0 由 toId() 响亮报错,
|
|
1236
|
+
// 不新造文案、更不许拿 ''/0 当 id 往下落库——归属值可有可无,主键没有就是调用方写错了。
|
|
1029
1237
|
const taskId = toId(args.processTaskId);
|
|
1030
|
-
|
|
1238
|
+
// issues/142 B 批(spec 06 §2.11):`processTask/addCandidate` 与 `processTask/surrogate` 两条
|
|
1239
|
+
// action 同落这一支 ⇒ 同一枚判据。改前的 `toStringList2` 两形两样(逗号串腿 trim+filter、
|
|
1240
|
+
// 数组腿 `v.map(String)` ⇒ null→"null"、undefined→"undefined"、不 trim、不折叠),
|
|
1241
|
+
// 现换成 cc 侧 issues/141 G10 已落地的那一枚单点(engine.parseActorIds → spi.normalizeActors),
|
|
1242
|
+
// 空串/纯空白/null/undefined 丢弃、trim、同次折叠,反向哨兵 "0" 照落。
|
|
1243
|
+
// 丢完为空 ⇒ 沿用本仓既有"空集合"档文案('actorIds 缺失',§2.11 硬要求③不新造错误码/文案)。
|
|
1244
|
+
const actors = parseActorIds(args.actorIds);
|
|
1031
1245
|
if (actors.length === 0)
|
|
1032
1246
|
throw new Error('actorIds 缺失');
|
|
1033
1247
|
await this.repo.addTaskActor(taskId, actors);
|
|
@@ -1039,15 +1253,21 @@ export class JeeflowFacade {
|
|
|
1039
1253
|
* 四类明确报错(msg 跨栈统一)。
|
|
1040
1254
|
*/
|
|
1041
1255
|
async taskTransfer(args) {
|
|
1256
|
+
// 主键档与 taskAddActor 同一条:processTaskId 缺失/空串/0 ⇒ toId() 响亮报错,不许拿 ''/0 往下落库
|
|
1042
1257
|
const taskId = toId(args.processTaskId);
|
|
1043
|
-
|
|
1044
|
-
|
|
1258
|
+
// issues/142 B 批(spec 06 §2.11 表第二行):fromActor/toActor **归一后再用**——落库值与
|
|
1259
|
+
// "与既有参与者的比较"都取 trim 后的串(改前比较的是未归一的形态:addCandidate 落了 " 8812 "
|
|
1260
|
+
// 之后,转办给 "8812" 判不出是同一个人,同人能再落一行)。
|
|
1261
|
+
// 判空一律用归一后的 `=== ''`(归一只剩空串这一种空形),**严禁** `if (!x)` 这类 JS 假值判据
|
|
1262
|
+
// ——`'0'` 是正常的人;必填档文案沿用既有三条,不新造错误码/文案(§2.11 硬要求③)。
|
|
1263
|
+
const operator = normalizeActorValue(args.operator);
|
|
1264
|
+
if (operator === '')
|
|
1045
1265
|
throw new Error('operator 必填');
|
|
1046
|
-
const fromActor =
|
|
1047
|
-
const toActor =
|
|
1048
|
-
if (
|
|
1266
|
+
const fromActor = normalizeActorValue(args.fromActor);
|
|
1267
|
+
const toActor = normalizeActorValue(args.toActor);
|
|
1268
|
+
if (fromActor === '')
|
|
1049
1269
|
throw new Error('fromActor 必填');
|
|
1050
|
-
if (
|
|
1270
|
+
if (toActor === '')
|
|
1051
1271
|
throw new Error('toActor 必填');
|
|
1052
1272
|
// 归属判据:只能转自己那一条待办;flow.auto/flow.admin 放行(对齐 isAllowed 既有约定)
|
|
1053
1273
|
const lower = operator.toLowerCase();
|
|
@@ -1102,6 +1322,95 @@ export class JeeflowFacade {
|
|
|
1102
1322
|
operator, fromActor, toActor,
|
|
1103
1323
|
});
|
|
1104
1324
|
}
|
|
1325
|
+
/**
|
|
1326
|
+
* 摘除参与人(issues/115 残留 · 门面第 <b>47</b> 个 action,spec 06 §processTask/removeTaskActor)。
|
|
1327
|
+
* SPI 侧 `removeTaskActor` 早就是必选方法(两仓都实现),只是没上门面 ⇒ 摘人只能靠 `transfer`
|
|
1328
|
+
* (摘 A **并**加 B),本 action 补的就是这一段(八栈同批)。
|
|
1329
|
+
*
|
|
1330
|
+
* <p>三个兄弟 action 的分工,免得后来人混用:
|
|
1331
|
+
* ① `processTask/surrogate`/`addCandidate` = <b>只加</b>;② `processTask/transfer` = <b>换人</b>
|
|
1332
|
+
* (摘 A 加 B,写 submitType=7 + tf_transferHistory 留痕);③ 本 action = <b>只摘不加、零留痕</b>:
|
|
1333
|
+
* 删掉 `actorIds` 在本任务的参与者行,不新建任务、不写任何任务变量、不覆写任务 `actorId`/`operator`
|
|
1334
|
+
* 列、<b>不 fire 事件</b>(issues/132 §11.3 定稿的事件集没有"摘人"这一码,码 7 的语义是"参与者被替换",
|
|
1335
|
+
* 只摘不加却发码 7 等于把没发生的转办写进事件流)。
|
|
1336
|
+
*
|
|
1337
|
+
* <p>守卫次序逐栈一致(spec 同节钉死,门禁按此断言 msg):operator 必填 → 缺参数 → 任务不存在 →
|
|
1338
|
+
* 权限 → 非进行中 → 摘空下限 → 落库。
|
|
1339
|
+
*/
|
|
1340
|
+
async taskRemoveActor(args) {
|
|
1341
|
+
// operator 先判必填(必填档在前):参数全缺时若先报主键缺失,会把鉴权缺口藏进"缺参数"报错里。
|
|
1342
|
+
// 硬必填、严禁回落 user1(与 transfer/withdraw 同口径,issues/114);归一在入口就做,
|
|
1343
|
+
// 判空一律 `=== ''`(`'0'` 是正常 id,严禁 JS 假值判据)。
|
|
1344
|
+
const operator = normalizeActorValue(args.operator);
|
|
1345
|
+
if (operator === '')
|
|
1346
|
+
throw new Error('operator 必填');
|
|
1347
|
+
// 主键档与归属值档一起判"缺参数"(spec 语义 8:与 surrogate 同族同文案)。
|
|
1348
|
+
// ⚠️ 本栈 surrogate/addCandidate 现有的两档文案是分开的(`'actorIds 缺失'` + `toId()` 的
|
|
1349
|
+
// `'id 缺失或非法'`),与本 action 的跨栈统一文案**不**同:新增 action 一律按 spec 出
|
|
1350
|
+
// `'processTaskId/actorIds 缺失'`;既有两档不改(改它们的 msg 会破已有门禁格,属另一件事)。
|
|
1351
|
+
// `toId()` 的超 2^53 那条(issues/82 精度护栏)是另一种事实,原样透出、不改写成"缺参数",
|
|
1352
|
+
// 否则会把"精度已丢"伪装成"参数没传"。
|
|
1353
|
+
let taskId;
|
|
1354
|
+
try {
|
|
1355
|
+
taskId = toId(args.processTaskId);
|
|
1356
|
+
}
|
|
1357
|
+
catch (e) {
|
|
1358
|
+
if (String(e?.message ?? '') === 'id 缺失或非法')
|
|
1359
|
+
throw new Error('processTaskId/actorIds 缺失');
|
|
1360
|
+
throw e;
|
|
1361
|
+
}
|
|
1362
|
+
// 逗号串与数组两形同判据:过本栈既有归一单点 `parseActorIds`(→ spi.normalizeActors)。
|
|
1363
|
+
// 空串/纯空白/null 在这一步就被丢掉 ⇒ 它们永远不会成为 DELETE 的实参(历史 `actor_id=''` 脏行安全)。
|
|
1364
|
+
const actors = parseActorIds(args.actorIds);
|
|
1365
|
+
if (actors.length === 0)
|
|
1366
|
+
throw new Error('processTaskId/actorIds 缺失');
|
|
1367
|
+
const task = await this.repo.findTaskById(taskId);
|
|
1368
|
+
if (!task)
|
|
1369
|
+
throw new Error('任务不存在');
|
|
1370
|
+
// 归属判据同 transfer(语义 3):operator ∈ 被摘集合(两侧都取归一后的串,比较才咬得上),
|
|
1371
|
+
// 或 flow.auto/flow.admin(大小写不敏感沿用 transfer 既有写法)。真实超管不命中这两个哨兵,
|
|
1372
|
+
// 超管可操作性归集成层权限码。transfer 能"摘 A 加 B"是因为 A 就是操作人本人,
|
|
1373
|
+
// 本 action 同理不得成为借道摘他人的口子。
|
|
1374
|
+
const lower = operator.toLowerCase();
|
|
1375
|
+
if (lower !== KeyAutoExecute && lower !== KeyAdminID && !actors.includes(operator)) {
|
|
1376
|
+
throw new Error('无权限摘除该任务参与人');
|
|
1377
|
+
}
|
|
1378
|
+
// 前置态:仅进行中(DOING=10)任务可摘人(语义 4)。已办结/废弃/撤回的历史参与人行是
|
|
1379
|
+
// approvalRecord 的取证依据(它读全状态任务行),摘它等于改写审批历史。
|
|
1380
|
+
if (task.taskState !== TaskState.Doing)
|
|
1381
|
+
throw new Error('任务非进行中,不可摘除参与人');
|
|
1382
|
+
// 以参与者表为判据(聚合副本可能滞后于加签/转办的增量写入,与 transfer 同源)。
|
|
1383
|
+
// ⚠️ 内存仓 `findTaskActors` 返回的是内部**活列表引用** ⇒ 先取副本,否则后面的过滤会读到半路数据。
|
|
1384
|
+
const current = [...(await this.repo.findTaskActors(taskId))];
|
|
1385
|
+
const targets = new Set(actors);
|
|
1386
|
+
// 语义 6「匹配取归一值、DELETE 取行上的原值」(§2.11 硬要求②的删除腿):库里的行可能是修复前
|
|
1387
|
+
// 落下的未 trim 原值 `" leader "`,入参 `leader` 必须**判成同一个人并真删掉它**。
|
|
1388
|
+
// 反面形状=拿归一值去 DELETE:本栈两仓的删除腿都是**列值精确比较**(内存仓 `Set.has(row)`、
|
|
1389
|
+
// SQL 仓 `actor_id IN (?)`),归一值打不中未 trim 的原值 ⇒ "判成同一人却一条没删",
|
|
1390
|
+
// 门面报成功而被摘的人待办还在,是**假成功**(go 栈实测形状)。
|
|
1391
|
+
const toDelete = [];
|
|
1392
|
+
let remaining = 0;
|
|
1393
|
+
for (const row of current) {
|
|
1394
|
+
const normalized = normalizeActorValue(row);
|
|
1395
|
+
// 归一后为空的历史脏行(`actor_id=''`/纯空白)既不匹配、也**不算"一个人"**(见下面下限那一句)
|
|
1396
|
+
if (normalized === '')
|
|
1397
|
+
continue;
|
|
1398
|
+
if (targets.has(normalized))
|
|
1399
|
+
toDelete.push(row); // 删的是 row 原值,不是归一值
|
|
1400
|
+
else
|
|
1401
|
+
remaining++;
|
|
1402
|
+
}
|
|
1403
|
+
// 语义 5「不得摘空」按**能办单的人数**判:脏行谁也办不了,拿它撑住下限等于让"摘空"伪装成成功。
|
|
1404
|
+
// 判据取集合差(上面的 remaining),不是"入参条数"——actorIds 里混非参与者 id 也绕不过这一条。
|
|
1405
|
+
// 摘空会造出无人可办又无法撤回重派的死单,比"配错表达式落 NULL"更难恢复。
|
|
1406
|
+
if (toDelete.length > 0 && remaining === 0)
|
|
1407
|
+
throw new Error('至少需保留一名参与人');
|
|
1408
|
+
// 语义 7「幂等」:actorIds 里不属于本任务参与者的人静默忽略;一个都没命中 ⇒ 空操作、成功信封
|
|
1409
|
+
// (前端双点/集成层重放第二次不再报错)。要"人不在任务里就报错"请用 transfer。
|
|
1410
|
+
// 落库后就结束:**不 updateTask、不写变量、不置 submitType、不 fire 事件**(语义 2)。
|
|
1411
|
+
if (toDelete.length > 0)
|
|
1412
|
+
await this.repo.removeTaskActor(taskId, toDelete);
|
|
1413
|
+
}
|
|
1105
1414
|
async taskLatest(args) {
|
|
1106
1415
|
const instanceId = toId(args.processInstanceId);
|
|
1107
1416
|
const doing = await this.repo.findDoingTasks(instanceId);
|
|
@@ -1661,13 +1970,6 @@ function idListArgs(args) {
|
|
|
1661
1970
|
}
|
|
1662
1971
|
return [toId(args.id)];
|
|
1663
1972
|
}
|
|
1664
|
-
function toStringList2(v) {
|
|
1665
|
-
if (Array.isArray(v))
|
|
1666
|
-
return v.map(String);
|
|
1667
|
-
if (typeof v === 'string')
|
|
1668
|
-
return v.split(',').map(s => s.trim()).filter(Boolean);
|
|
1669
|
-
return [];
|
|
1670
|
-
}
|
|
1671
1973
|
function toInt(v) {
|
|
1672
1974
|
const n = Number(v);
|
|
1673
1975
|
if (!Number.isFinite(n))
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { EngineImpl, type Engine, type EngineOptions, type SurrogateLookup } from './engine.js';
|
|
2
2
|
export { MemoryRepository } from './memory.js';
|
|
3
3
|
export { MemoryExtRepository } from './memory-ext.js';
|
|
4
|
-
export { HandlerRegistry, type IAssignmentHandler, type IDecisionHandler, type HandlerMeta, type HandlerType } from './registry.js';
|
|
4
|
+
export { HandlerRegistry, type IAssignmentHandler, type IDecisionHandler, type ICustomHandler, type HandlerMeta, type HandlerType } from './registry.js';
|
|
5
5
|
export { enumDict, enumDictKeys, type DictItem } from './metadata.js';
|
|
6
6
|
export * from './model.js';
|
|
7
7
|
export type { ProcessRepository, ProcessExtRepository, UserProvider, OrgUserProvider, IDGenerator, ExpressionEvaluator, QueryCondition } from './spi.js';
|
package/dist/jdbc/shared.d.ts
CHANGED
|
@@ -61,11 +61,29 @@ export declare class JdbcRepository implements ProcessRepository {
|
|
|
61
61
|
findHistoryTasks(instanceId: string): Promise<ProcessTask[]>;
|
|
62
62
|
private mapTask;
|
|
63
63
|
private replaceTaskActors;
|
|
64
|
+
/**
|
|
65
|
+
* `wf_process_task_actor` 的**唯一 INSERT 腿**(`saveTask`/`updateInstance` 级联的
|
|
66
|
+
* `replaceTaskActors` 与 `addTaskActor` 两条路都从这里下库)。
|
|
67
|
+
*
|
|
68
|
+
* <p>issues/142 B 批(spec 06 §2.11「归属值写侧归一」):绑定进 `actor_id` 的值先过
|
|
69
|
+
* `spi.normalizeActors` **那一枚**单点——逐元素 trim、空串/纯空白/`null`/`undefined` 丢弃、
|
|
70
|
+
* 同一次调用内的重复折叠。判据落在这一层而不是只落门面腿:绕过
|
|
71
|
+
* `processTask/addCandidate`/`surrogate`/`transfer` 直连仓储的调用方(集成层、第三方仓储消费者)
|
|
72
|
+
* 同样不得把空归属值灌进归属列——那正是 issues/129 那族"空归属值读全库"的上游进水口。
|
|
73
|
+
* ⚠️ 与内存仓 `MemoryRepository.writeActors` 同一判据、同一份实现,两仓必须同答案。
|
|
74
|
+
*/
|
|
64
75
|
private insertTaskActors;
|
|
65
76
|
findTaskActors(taskId: string): Promise<string[]>;
|
|
66
77
|
addTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
67
78
|
removeTaskActor(taskId: string, actors: string[]): Promise<void>;
|
|
68
79
|
createCcInstance(instanceId: string, creator: string, ...actorIds: string[]): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* issues/141 G2:某实例已有的 cc 行 actor id(写侧判重的读侧,对齐 java `findCcActorIds`)。
|
|
82
|
+
* 排序按 id ASC 与本仓 `findTaskActors` 同形,让"既有集合"在两仓/跨驱动都稳定可断言。
|
|
83
|
+
* ⚠️ 查询侧不带 DISTINCT:判重在写侧,历史重复行原样返回(owner 拍为接受既成事实)。
|
|
84
|
+
*/
|
|
85
|
+
findCcActorIds(instanceId: string): Promise<string[]>;
|
|
86
|
+
createCcInstanceIfAbsent(instanceId: string, creator: string, ...actorIds: string[]): Promise<string[]>;
|
|
69
87
|
updateCcStatus(instanceId: string, actorId: string): Promise<void>;
|
|
70
88
|
pageDefines(pageNum: number, pageSize: number, conditions?: QueryCondition[]): Promise<{
|
|
71
89
|
rows: DefineRow[];
|
package/dist/jdbc/shared.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
12
12
|
import { ProcessInstance, ProcessTask } from '../model.js';
|
|
13
13
|
import { TaskState } from '../model.js';
|
|
14
|
-
import { isBlankOwnership, isBlankValue } from '../spi.js';
|
|
14
|
+
import { isBlankOwnership, isBlankValue, hasEffectiveCcOwnership, defaultCreateCcInstanceIfAbsent, normalizeActorValue, normalizeActors, actorDeleteForms } from '../spi.js';
|
|
15
15
|
// ═══ 列白名单(issues/05-5,与 mldong-boot2 别名一致) ═══
|
|
16
16
|
const TASK_WHITELIST = new Set([
|
|
17
17
|
't.id', 't.task_name', 't.display_name', 't.task_type', 't.perform_type', 't.task_state',
|
|
@@ -369,9 +369,20 @@ export class JdbcRepository {
|
|
|
369
369
|
await conn.execute(this.sql('DELETE FROM wf_process_task_actor WHERE process_task_id = ?'), [taskId]);
|
|
370
370
|
await this.insertTaskActors(conn, taskId, actors);
|
|
371
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* `wf_process_task_actor` 的**唯一 INSERT 腿**(`saveTask`/`updateInstance` 级联的
|
|
374
|
+
* `replaceTaskActors` 与 `addTaskActor` 两条路都从这里下库)。
|
|
375
|
+
*
|
|
376
|
+
* <p>issues/142 B 批(spec 06 §2.11「归属值写侧归一」):绑定进 `actor_id` 的值先过
|
|
377
|
+
* `spi.normalizeActors` **那一枚**单点——逐元素 trim、空串/纯空白/`null`/`undefined` 丢弃、
|
|
378
|
+
* 同一次调用内的重复折叠。判据落在这一层而不是只落门面腿:绕过
|
|
379
|
+
* `processTask/addCandidate`/`surrogate`/`transfer` 直连仓储的调用方(集成层、第三方仓储消费者)
|
|
380
|
+
* 同样不得把空归属值灌进归属列——那正是 issues/129 那族"空归属值读全库"的上游进水口。
|
|
381
|
+
* ⚠️ 与内存仓 `MemoryRepository.writeActors` 同一判据、同一份实现,两仓必须同答案。
|
|
382
|
+
*/
|
|
372
383
|
async insertTaskActors(conn, taskId, actors) {
|
|
373
384
|
const now = new Date();
|
|
374
|
-
for (const a of actors) {
|
|
385
|
+
for (const a of normalizeActors(actors)) {
|
|
375
386
|
await conn.execute(this.sql('INSERT INTO wf_process_task_actor (id, process_task_id, actor_id, create_time, create_user) VALUES (?,?,?,?,?)'), [this.idGen.nextId(), taskId, a, now, 'jeeflow']);
|
|
376
387
|
}
|
|
377
388
|
}
|
|
@@ -386,12 +397,17 @@ export class JdbcRepository {
|
|
|
386
397
|
}
|
|
387
398
|
}
|
|
388
399
|
async addTaskActor(taskId, actors) {
|
|
389
|
-
|
|
400
|
+
// issues/142 B 批(spec 06 §2.11):写侧兜底——改前这里**判重不判空不 trim**,
|
|
401
|
+
// `""`/`" "`/`"null"`(门面数组腿串化出来的假归属人)全放行。
|
|
402
|
+
// 归一交给 `insertTaskActors` 那一枚单点(与内存仓 writeActors 同一份实现),本方法只多一道
|
|
403
|
+
// "与库里既有行判重":判重两侧取的都是 trim 后的值,`" 123 "` 与 `"123"` 是同一个人。
|
|
404
|
+
const normalized = normalizeActors(actors);
|
|
405
|
+
if (normalized.length === 0)
|
|
390
406
|
return;
|
|
391
407
|
// 追加语义(对齐 boot2/boot3,issues/03):查已有参与者,去重后仅插入新增,不清空原参与者
|
|
392
408
|
const existing = await this.findTaskActors(taskId);
|
|
393
409
|
const seen = new Set(existing);
|
|
394
|
-
const toAdd =
|
|
410
|
+
const toAdd = normalized.filter(a => !seen.has(a));
|
|
395
411
|
if (toAdd.length === 0)
|
|
396
412
|
return;
|
|
397
413
|
const conn = await this.c();
|
|
@@ -403,11 +419,20 @@ export class JdbcRepository {
|
|
|
403
419
|
}
|
|
404
420
|
}
|
|
405
421
|
async removeTaskActor(taskId, actors) {
|
|
406
|
-
|
|
422
|
+
// issues/137 §3-6(spec 06 §processTask/removeTaskActor 语义 6 · owner 2026-10-02 拍「两形并集」):
|
|
423
|
+
// 删除值先过 spi.actorDeleteForms **那一枚**单点 —— ① 空值(null/undefined/''/纯空白)一律不喂 DELETE
|
|
424
|
+
// (否则历史 actor_id='' 脏行被批量误删);② 非空值同时以「原值」与「trim 值」两形进 IN:只取 trim 形
|
|
425
|
+
// ⇒ 门面按语义 6 交出的脏行原值 " 9101 " 被削成 9101,真库 NO PAD 排序规则下那一行删不掉而门面报成功
|
|
426
|
+
// (假成功);只取原值 ⇒ 绕过门面直连仓储传 " 8601 " 删不掉写侧归一后的规范行(issues/142 §9.2)。
|
|
427
|
+
// ③ 展开后为空 ⇒ 早退,一条 DELETE 都不发(不得退化成"清空该任务全部参与者")。
|
|
428
|
+
// 占位符数量按 forms 长度算(repeatPh 复用);⚠️ 与内存仓 MemoryRepository.removeTaskActor 同一枚判据
|
|
429
|
+
// (spi.actorDeleteForms),两仓同答案(issues/117 场景 27);判据只在 spi 那一处,本方法不抄第二份。
|
|
430
|
+
const forms = actorDeleteForms(actors);
|
|
431
|
+
if (forms.length === 0)
|
|
407
432
|
return;
|
|
408
433
|
const conn = await this.c();
|
|
409
434
|
try {
|
|
410
|
-
await conn.execute(this.sql(`DELETE FROM wf_process_task_actor WHERE process_task_id = ? AND actor_id IN (${repeatPh(
|
|
435
|
+
await conn.execute(this.sql(`DELETE FROM wf_process_task_actor WHERE process_task_id = ? AND actor_id IN (${repeatPh(forms.length)})`), [taskId, ...forms]);
|
|
411
436
|
}
|
|
412
437
|
finally {
|
|
413
438
|
await this.done(conn);
|
|
@@ -415,22 +440,64 @@ export class JdbcRepository {
|
|
|
415
440
|
}
|
|
416
441
|
// ── CcInstance(抄送)─────────────────────────────────────────────────────
|
|
417
442
|
async createCcInstance(instanceId, creator, ...actorIds) {
|
|
443
|
+
// issues/141 G2 写侧判重=幂等空操作(spec 06 §4),与内存仓同一条判据:同一 (实例, 被抄送人)
|
|
444
|
+
// 已有 cc 行 ⇒ 直接跳过——①不新增行、②不重置未读(state 保持原值)、③不更新原行时间
|
|
445
|
+
// (不碰 UPDATE,create_time/update_time 逐字不变)。判重放在**写侧**而不是查询侧:
|
|
446
|
+
// 查询不引入 DISTINCT(owner 2026-09-29 拍),历史重复行也不清理。
|
|
447
|
+
//
|
|
448
|
+
// issues/141 G10「空不创建行」(spec 06 §2.10):入参先过 `spi.normalizeActorValue`
|
|
449
|
+
// (旧名 normalizeCcActorValue 是它的别名,同一枚函数)——
|
|
450
|
+
// 空串/纯空白/null 一律丢弃,绑进 actor_id 的值取 trim 后的串(`" 123 "` 与 `"123"` 是同一个人,
|
|
451
|
+
// 与上面的写侧判重同一条尺子)。绕过引擎/门面直连仓储的第三方调用方也建不出 actor_id='' 的行,
|
|
452
|
+
// 那正是 issues/129 那族"空 operator 读全库"的病根。⚠️ 与内存仓共用一份判据,两仓必须同答案。
|
|
453
|
+
const existing = await this.findCcActorIds(instanceId);
|
|
418
454
|
const conn = await this.c();
|
|
419
455
|
try {
|
|
420
456
|
const now = new Date();
|
|
421
|
-
for (const
|
|
457
|
+
for (const rawActorId of actorIds) {
|
|
458
|
+
const actorId = normalizeActorValue(rawActorId);
|
|
459
|
+
if (actorId === '' || existing.includes(actorId))
|
|
460
|
+
continue;
|
|
422
461
|
await conn.execute(this.sql('INSERT INTO wf_process_cc_instance (id, process_instance_id, actor_id, state, ' +
|
|
423
462
|
'create_time, create_user, update_time, update_user) VALUES (?,?,?,0,?,?,?,?)'), [this.idGen.nextId(), instanceId, actorId, now, creator, now, creator]);
|
|
463
|
+
// 同一次调用内的重复也算"已存在",只落一行
|
|
464
|
+
existing.push(actorId);
|
|
424
465
|
}
|
|
425
466
|
}
|
|
426
467
|
finally {
|
|
427
468
|
await this.done(conn);
|
|
428
469
|
}
|
|
429
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* issues/141 G2:某实例已有的 cc 行 actor id(写侧判重的读侧,对齐 java `findCcActorIds`)。
|
|
473
|
+
* 排序按 id ASC 与本仓 `findTaskActors` 同形,让"既有集合"在两仓/跨驱动都稳定可断言。
|
|
474
|
+
* ⚠️ 查询侧不带 DISTINCT:判重在写侧,历史重复行原样返回(owner 拍为接受既成事实)。
|
|
475
|
+
*/
|
|
476
|
+
async findCcActorIds(instanceId) {
|
|
477
|
+
const conn = await this.c();
|
|
478
|
+
try {
|
|
479
|
+
const rows = await conn.fetchAll(this.sql('SELECT actor_id FROM wf_process_cc_instance WHERE process_instance_id = ? ORDER BY id ASC'), [instanceId]);
|
|
480
|
+
return rows.map(r => String(r.actor_id));
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
await this.done(conn);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
async createCcInstanceIfAbsent(instanceId, creator, ...actorIds) {
|
|
487
|
+
// spi 里那份 java default 的对应物(本仓的 findCcActorIds/createCcInstance 已自带判重,
|
|
488
|
+
// 本方法只负责把"实际新建的子集"回传给调用方去 fire)
|
|
489
|
+
return defaultCreateCcInstanceIfAbsent(this, instanceId, creator, actorIds);
|
|
490
|
+
}
|
|
430
491
|
async updateCcStatus(instanceId, actorId) {
|
|
492
|
+
// issues/142 B 批(spec 06 §2.11 表第四行):归属值入参**归一后再比**——比较值取 trim 后的串
|
|
493
|
+
// (`" 123 "` 打不中行里的 `"123"` 就是"点了已读没反应"),归一后为空 ⇒ **一条 UPDATE 都不发**
|
|
494
|
+
// (空 operator 会把 state=1 打到历史 `actor_id=''` 的脏行上)。与内存仓同一枚判据。
|
|
495
|
+
const actor = normalizeActorValue(actorId);
|
|
496
|
+
if (actor === '')
|
|
497
|
+
return;
|
|
431
498
|
const conn = await this.c();
|
|
432
499
|
try {
|
|
433
|
-
await conn.execute(this.sql('UPDATE wf_process_cc_instance SET state=1, update_time=? WHERE process_instance_id=? AND actor_id=?'), [new Date(), instanceId,
|
|
500
|
+
await conn.execute(this.sql('UPDATE wf_process_cc_instance SET state=1, update_time=? WHERE process_instance_id=? AND actor_id=?'), [new Date(), instanceId, actor]);
|
|
434
501
|
}
|
|
435
502
|
finally {
|
|
436
503
|
await this.done(conn);
|
|
@@ -631,8 +698,14 @@ export class JdbcRepository {
|
|
|
631
698
|
}
|
|
632
699
|
// pageCcInstances 我的抄送分页(v1.3.0):cc 表 join 实例 + 定义,按抄送人过滤(对齐 Java pageCcInstances)
|
|
633
700
|
async pageCcInstances(pageNum, pageSize, actorId, conditions) {
|
|
634
|
-
// issues/
|
|
635
|
-
|
|
701
|
+
// issues/141 G1 归属条件必填(spec 06 §2.5):cc.actor_id 上没有有效归属证据 ⇒ 空页。
|
|
702
|
+
// 这一格补的是 issues/129 那把尺子的**延长档**:129 收了"归属列给了空值"(下面 buildWhere 的
|
|
703
|
+
// OWNERSHIP_COLUMNS ⇒ `AND 1=0`,位置参空值那一路也一并由 hasEffectiveCcOwnership 覆盖),
|
|
704
|
+
// G1 收的是"空集合也算没填"(`[]`/空 IN ⇒ 空页,而不是让数组下库或整条条件静默消失)。
|
|
705
|
+
// 旧形状在这一侧是 `FROM wf_process_instance t LEFT JOIN wf_process_cc_instance cc` 不带条件
|
|
706
|
+
// 返回**全部实例**(php PDO 那面反面教材),而它自家内存仓只放"有 cc 行的实例"——同一栈两仓
|
|
707
|
+
// 两个答案正是 issues/117 场景 27 立过法的形状,所以判据两仓共用 hasEffectiveCcOwnership 一份实现。
|
|
708
|
+
if (!hasEffectiveCcOwnership(actorId, conditions))
|
|
636
709
|
return { rows: [], total: 0 };
|
|
637
710
|
const cond = this.buildWhere(conditions ?? [], CC_WHITELIST);
|
|
638
711
|
const where = ' FROM wf_process_instance t' +
|