P1-6 修复: workflow parseFlowXml 跨行匹配 + 4 种 gateway 节点 (2026-07-02)
FINDING-F3: parseFlowXml 解析不完整 - 单行正则 \s+ 不匹配跨行 id 属性 → JNPF FlowXmlUtil 输出带换行缩进时漏解析 - 不匹配 parallelGateway/inclusiveGateway/exclusiveGateway/eventGateway - 复杂流程 (含条件分支) 网关节点全丢, launch 条件路由失效 修复: - 正则改 [\s\S]*? 跨行匹配 - 加 4 种 gateway 节点 (parallel/inclusive/exclusive/event) - 类型映射: parallelGateway → type='parallel', inclusiveGateway → 'inclusive', etc. testspace 验证 (3 单元测试): - Test 1 单行 BPMN: 3 nodes (start + task + end) ✓ - Test 2 跨行 BPMN: 2 nodes (旧版 0) ✓ - Test 3 含网关: 6 nodes (旧版 4, 漏 g1/g2) ✓ - 网关类型映射: exclusive/parallel 正确 ✓ 审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §4.1 F3
This commit is contained in:
1 parent
fdd591a9cf
commit
cfd1fa9211
1 file changed
+27
-3
@@ -95,12 +95,36 @@ export const defaultGlobalForm: Record<string, unknown> = {
|
||||
export function parseFlowXml(flowXml: string): Record<string, Record<string, unknown>> {
|
||||
const nodes: Record<string, Record<string, unknown>> = {}
|
||||
|
||||
// 匹配 bpmn2:startEvent / userTask / endEvent 节点
|
||||
// 形如: <bpmn2:startEvent id="Event_xxx" name="流程发起">
|
||||
const nodeRegex = /<bpmn2:(startEvent|userTask|endEvent)\s+id="([^"]+)"(?:\s+name="([^"]*)")?[^>]*>/g
|
||||
// v0.15+ (P1-6): 跨行匹配 + 加 4 种 gateway 节点
|
||||
// 旧版 [\s\S]*? 改 [\s\S]* (单行) → 跨行也匹配 (JNPF FlowXmlUtil 输出 BPMN 经常带换行缩进)
|
||||
// 旧版仅 startEvent|userTask|endEvent → 加 parallelGateway/inclusiveGateway/exclusiveGateway/eventGateway
|
||||
// 网关节点类型: 'gateway' (web FlowXmlUtil 不细分, 后端 save 时 flowable 启动器按 type 区分)
|
||||
// parallelGateway → type='parallel' (并行, 全部通过)
|
||||
// inclusiveGateway → type='inclusive' (包容, 至少一个)
|
||||
// exclusiveGateway → type='exclusive' (排他, 唯一一个)
|
||||
// eventGateway → type='event' (事件网关)
|
||||
// 形如: <bpmn2:startEvent id="Event_xxx"\n name="流程发起"\n flowable:xxx="...">
|
||||
const nodeRegex = /<bpmn2:(startEvent|userTask|endEvent|parallelGateway|inclusiveGateway|exclusiveGateway|eventGateway)\s+id="([^"]+)"[\s\S]*?(?:\s+name="([^"]*)")?[^>]*>/g
|
||||
let match: RegExpExecArray | null
|
||||
while ((match = nodeRegex.exec(flowXml)) !== null) {
|
||||
const [, tagType, nodeId, nodeName = ''] = match
|
||||
// 网关节点特殊处理 (P1-6)
|
||||
if (tagType === 'parallelGateway') {
|
||||
nodes[nodeId] = { nodeId, type: 'parallel', nodeName: nodeName || '并行网关' }
|
||||
continue
|
||||
}
|
||||
if (tagType === 'inclusiveGateway') {
|
||||
nodes[nodeId] = { nodeId, type: 'inclusive', nodeName: nodeName || '包容网关' }
|
||||
continue
|
||||
}
|
||||
if (tagType === 'exclusiveGateway') {
|
||||
nodes[nodeId] = { nodeId, type: 'exclusive', nodeName: nodeName || '排他网关' }
|
||||
continue
|
||||
}
|
||||
if (tagType === 'eventGateway') {
|
||||
nodes[nodeId] = { nodeId, type: 'event', nodeName: nodeName || '事件网关' }
|
||||
continue
|
||||
}
|
||||
if (tagType === 'startEvent') {
|
||||
nodes[nodeId] = {
|
||||
nodeId,
|
||||
|
||||
Reference in new issue
Block a user