Compare commits

...

9 Commits

Author SHA1 Message Date
d08a35fbbb Merge feat/process-modeler 阶段1: Modeler 前端骨架(moddle保真+/process-modeler页)
Some checks failed
ci / build-test (push) Has been cancelled
- vendored activiti/flowable moddle 描述符+语料双门测试(1512/1512 零丢失扫描工具,加固版回归门)
- /process-modeler 页:bpmn-js Modeler+标准属性面板(显式attachTo)+admin门+存量打开器(by-id/by-key双参)
- 设计中心「流程设计」入口;红线守住(只载activiti/无Camunda provider)
- 全量 vitest 118 例+tsc+build 绿;live 验收「总包合同交底」画布/palette/Multi-instance面板全渲染

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 11:08:27 +08:00
dffd1f32ef fix(modeler): 属性面板显式 attachTo 修挂载时序(live 实证)+canvas 分支错误提示
live 复验:画布/palette/选中/context pad 正常,但标准属性面板从不挂载
(document 中 .bio-properties-panel 为 0,容器 children=0)。

根因(本次修时 attachTo 测试逼出):属性面板宿主 <div data-testid=process-modeler-props>
**从未挂 ref={panelRef}** → 构造参数 propertiesPanel.parent 恒为 null,面板无处渲染。
- 补 ref={panelRef} 到 props 容器 div(真根因)。
- 构造后显式 (modeler.get('propertiesPanel')).attachTo(panelRef.current)——
  bpmn-js-properties-panel 规范补救,放 importXML 前、alive 检查内、panelRef 存在时。
- 顺带修 T1.5 评审 M-2:canvasRef 为 null 分支改为 setError(原停 loading 无提示)。

测试:ProcessModelerPage.test.tsx +1(Modeler stub get('propertiesPanel')→{attachTo},
断言 attachTo 恰调一次且实参是 props 容器 DOM)。stub get 改按 service 分派
(propertiesPanel/canvas)。全量 vitest 22 文件 118 例绿;tsc -b 干净;npm run build 成功。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 11:05:23 +08:00
ae097f2a9c fix(modeler): 打开器改 by-key 载入(修 options source=model 语义缺口)
live 验收发现:本库 /api/process-select/options 的 143 个选项 source 全为 'model',
option.id 是 act_re_model id(非 procDefId)→ 按 id 载入永远 found:false;option.key 才是流程 key。

- processModeler.ts:加 fetchProcDefSourceByKey(key) → GET
  /api/workflow/process-definitions/by-key/{key}/source(key 常纯中文,encodeURIComponent;
  返回形状同 fetchProcDefSource,共用 normalizeProcDefSource:found:false 不解构 bpmnXml/idMap)。
  ProcessOption 加 source 字段。
- ProcessModelerPage:打开器双参分派——source==='processDefinition' 用 ?procDefId=<id>,
  其余(model/history)用 ?procKey=<key>;loadEffect 按参数派 by-id / by-key;
  过滤规则 !!o.id 改为 source==='processDefinition' ? !!o.id : !!o.key;
  选择器用索引取回选项对象避免路由二义。

测试:processModeler.test.ts +2(纯中文 key 编码 / by-key found:false)+ source 映射断言;
ProcessModelerPage.test.tsx +3(?procKey= 走 by-key 并 importXML / 选 model 选项派 by-key /
选 processDefinition 选项派 by-id)。全量 vitest 22 文件 117 例绿;tsc -b 干净;npm run build 成功。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:59:24 +08:00
e131b8dee9 feat(modeler): /process-modeler 页骨架(Modeler+标准属性面板+存量载入+设计中心入口)
阶段1 T1.5:admin 门 + 三栏布局(左画布/右上 EIP4 侧板占位/右下标准属性面板)
+ bpmn-js lib/Modeler 挂载(只载 activiti moddle、只引标准 BpmnPropertiesProvider,
严禁 Camunda provider)+ ?procDefId= 时 fetchProcDefSource→importXML(idMap 存 ref)
+ 无参时 process-select 存量流程选择器 + 设计中心「流程设计」入口。

api: processModeler.ts(fetchProcDefSource / fetchProcessOptions,裸 JSON 防御性默认)。
- procDefId 用 encodeURIComponent 进 path(真实库 id 形如「总包合同交底:3:<uuid>」中文+冒号)。
- found:false 先判后返,不解构 bpmnXml/idMap(后端此分支省略这些键)。
tsconfig.app.json 开 resolveJsonModule(首个 app 代码 import json)。
bpmn-js-properties-panel 补 ambient d.ts(包未发布类型)。

测试:ProcessModelerPage.test.tsx 5 例 + processModeler.test.ts 6 例(含中文+冒号
procDefId 断言 URL 已编码 / found:false 只返 found 键 / amis 信封解包);
DesignCenterPage.entrances 加 dc-process-modeler admin-only 断言。
全量 vitest 22 文件 112 例绿;tsc -b 干净;npm run build 成功(bpmn-js 进主 bundle)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:37:36 +08:00
b391ee9f16 fix(modeler): 保真扫描回归加固——refs袋+unresolved入门+规模门+stderr(评审I1/M1/M2/M5)
- I1 引用回归盲区:surface() 新增 refs 袋(sourceRef/targetRef/bpmnElement/
  processRef/attachedToRef/default,与 sanitizeIds 同覆盖面)并入比对键;normWarn
  的 unresolved reference 类 warning 计入硬门 failures(净化/往返破坏连线的直接信号)。
- M1:删除未使用的 realFail。
- M2:新增 EXPECTED_TOTAL 环境变量(默认 1512),实际语料数不符即判失败;
  decodeFailures.length 并入硬门(过滤集内本应 100% 干净 UTF8)。
- M5:崩溃分支透出子进程 e.stderr。
- M3/M4:命名空间字面前缀识别的语料前提、extElemText trim 口径各加注释声明。

重跑实测(node tools/modeler-fidelity-sweep.mjs):匹配 1512/1512 零丢失,
解析异常 0,解码失败 0,warnings=0,exit 0;EXPECTED_TOTAL=9999 时 exit 1
(规模门生效)。npx vitest run src/modeler 12/12 绿;npx tsc -b 干净(exit 0)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:15:49 +08:00
bd7c7fc697 fix(modeler): 描述符补 formProperty.value(sweep 0-warning 收口)
activiti.json formProperty 补 value isAttr(对齐 D6 完整描述符)。此前 4 例
unknown attribute <value> warning(均 Activiti 自带 demo 流程的 formProperty
value= 属性,如 VacationRequest)靠 lax $attrs 保留、本无数据丢失,补声明后消除。

重跑实测(node tools/modeler-fidelity-sweep.mjs,5433/eip4/eip3):
- 匹配 1512/1512 零丢失,解析异常 0,解码失败 0,warnings=0。
- 命名空间 activiti 1509 / flowable 3。
- npx vitest run src/modeler 12/12 绿;npx tsc -b 干净(exit 0)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:02:09 +08:00
6eb856bb75 feat(modeler): 全量真实流程 moddle round-trip 保真扫描工具(实测 1512/1512 零丢失)
对本地 eip4 库(5433,search_path=eip3) act_ge_bytearray 全部真实 BPMN
(name_ like %.bpmn%/%.xml,共 1512)逐条 bpmn-moddle fromXML→toXML,
数据级(实体解码归一后)校验「activiti/flowable 扩展属性+扩展元素结构
+全部 bpmn 元素 id 集合」多重集往返一致。

- psql 子进程取数(不引 pg 依赖);命名空间嗅探后单载 activiti 或 flowable
  (T1.1 实证双载丢 userTask);进 moddle 前净化非法 id(镜像后端
  sanitizeBpmnIds,1445/1512 文档 process id 为中文,moddle 拒非 ASCII-NCName)。
- 实测: 匹配 1512/1512 零丢失(activiti 1509 / flowable 3);解析异常 0;
  解码失败 0。warnings 仅 4 例 unknown attribute <value>(formProperty
  value= 属性未声明,均 Activiti 自带 demo 流程,lax $attrs 保留,零丢失)。
- 解码守卫: 校验 base64→UTF8 无损,单列非 UTF8 文档。全表探明解码失败仅
  出现在非 BPMN 二进制资源(.png 1504 / var-* 87524),被 name 过滤器正确排除;
  真实 BPMN 语料 0 解码失败。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 09:59:54 +08:00
a2aeeba296 fix(modeler): T1.1 评审收口——bpmn-moddle 显式devDep+$attrs断言+类型声明
评审 I-1 / M-1 / TS7016 收口(承接 8fdfe68):
- I-1 幻影依赖:devDependencies 显式声明 bpmn-moddle ^8.1.0(npm dedupe 到与
  bpmn-js 同一份 8.1.0),保真测试不再依赖传递提升、与 Modeler 运行时同版本。
- M-1 断言意图纠偏:fidelity.test.ts 原注释「未声明时 .get() 返 undefined」实证有误——
  moddle .get() 对未声明属性会回落 $attrs 返原值(已实证:flowable:assignee 未声明时
  .get() 返 "X")。改注释 + 增 `expect($attrs?.['activiti:candidateUsers']).toBeUndefined()`
  直接断言值未落 lax $attrs(=真 typed 化,声明属性确不在 $attrs)。
- TS7016:新增 src/modeler/moddle/bpmn-moddle.d.ts(最小 ambient 声明)消编辑器诊断。

验证:npx vitest run src/modeler 12/12 绿;npx tsc -b 干净(exit 0)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 09:47:02 +08:00
8fdfe688f8 feat(modeler): activiti/flowable moddle 描述符 + 语料覆盖/round-trip 保真测试
在线流程 Modeler 阶段1 Task 1.1(P1 双门验收)。为 bpmn-js Modeler 载入
存量 activiti BPMN 提供 vendored moddle 描述符,并以合成 fixture 验证零丢失。

依赖(与 bpmn-js 17.11.1 兼容,实际解析版本):
- bpmn-js-properties-panel 5.60.0(package.json ^5.23.0)
- @bpmn-io/properties-panel 3.47.0(package.json ^3.23.0)
- bpmn-moddle 8.1.0(bpmn-js 传递依赖,直接 import)

交付:
- src/modeler/moddle/activiti.json:完整 activiti 命名空间描述符,覆盖 §0 实测
  全集——属性 formKey/candidateUsers/exclusive/assignee/collection/elementVariable/
  candidateGroups/autoStoreVariables/initiator/dueDate(按宿主 extends 到 UserTask/
  StartEvent/Process/ScriptTask/MultiInstanceLoopCharacteristics 等)+ 元素
  taskListener/formProperty/field/string/value/executionListener/in/out。
- src/modeler/moddle/flowable.json:flowable 命名空间镜像描述符(覆盖 flowable:assignee 等)。
- src/modeler/moddle/fixtures/synthetic-full-surface.bpmn.ts:合成 fixture,形态逐字
  对照真实流程「总包合同交底」——含全角【】办理人 JSON、多实例、taskListener+field/
  string、formProperty+value、boundaryEvent+timer、conditionExpression、完整 DI。
- src/modeler/moddle/fidelity.test.ts:12 用例(语料覆盖 + round-trip 零丢失)。

fixture 关键形态发现(实证):
- 办理人/会签 JSON 用**全角【】**包裹对象,方括号 [] 半角,引号在属性内以 &quot; 转义;
  content 尾部有 CHAR 补白空格(如 "4028...0f7d    ")——均需零丢失。
- candidateUsers 表达式解析后 byte-exact 等于原文;moddle 序列化把 '/" 输出为
  数字实体 &#39;/&#34;,全角【】原样保留(XML 语义等价、模型层零丢失)。

勘探实证并固化为回归测试的两条 moddle 约束:
- moddle-xml 拒绝中文 id(illegal ID,须 NCName ASCII)→ 这正是 D7 BpmnIdSanitizer
  在进 moddle 前净化、发布时还原的根本原因;fixture 用 ASCII id、中文仅留在 name。
- activiti+flowable 双包同载会因跨包同名 extends 属性(如 exclusive)冲突而丢弃 userTask
  → 按命名空间隔离加载;已验证 Modeler 单载 activiti 时 flowable 属性经 lax $attrs 零丢失
  往返(Task 1.5 Modeler 应单载 activiti)。

验证:npx vitest run src/modeler 12/12 绿;全量 101/101 绿;tsc -b 干净;npm run build 成功。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 09:35:23 +08:00
17 changed files with 2208 additions and 1 deletions

627
package-lock.json generated
View File

@@ -8,8 +8,10 @@
"name": "eip4-web",
"version": "0.1.0",
"dependencies": {
"@bpmn-io/properties-panel": "^3.47.0",
"axios": "1.7.9",
"bpmn-js": "^17.11.1",
"bpmn-js-properties-panel": "^5.60.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.28.0"
@@ -29,6 +31,7 @@
"amis-formula": "^6.13.0",
"amis-theme-editor-helper": "^6.12.0-ab.1",
"amis-ui": "^6.13.0",
"bpmn-moddle": "^8.1.0",
"i18n-runtime": "^1.0.13",
"jsdom": "^29.1.1",
"typescript": "5.6.3",
@@ -386,6 +389,24 @@
"node": ">=6.9.0"
}
},
"node_modules/@bpmn-io/cm-theme": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@bpmn-io/cm-theme/-/cm-theme-0.2.2.tgz",
"integrity": "sha512-9mD7fzzNDNBgseOUC6iRX4mi17LIO2es4zkcHt4e4owQC2Q3YPvqJTJaXqc7kkItloSFsqG2j/1iMJkpvjLv2A==",
"license": "MIT",
"peer": true,
"dependencies": {
"@codemirror/language": "^6.12.3",
"@lezer/highlight": "^1.2.3"
},
"engines": {
"node": ">= 20.12.0"
},
"peerDependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"node_modules/@bpmn-io/diagram-js-ui": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@bpmn-io/diagram-js-ui/-/diagram-js-ui-0.2.4.tgz",
@@ -396,6 +417,307 @@
"preact": "^10.29.2"
}
},
"node_modules/@bpmn-io/extract-process-variables": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@bpmn-io/extract-process-variables/-/extract-process-variables-2.2.1.tgz",
"integrity": "sha512-1E5ydNzTqgx513NxA1nxk2CqDb9OkusfU9Tf6WejD1BiY+5u130XnZOFE/FQX0JB6ZmPOeFMx4IDEuHjrGhOzw==",
"license": "MIT",
"dependencies": {
"min-dash": "^5.0.0"
}
},
"node_modules/@bpmn-io/extract-process-variables/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/feel-editor": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/feel-editor/-/feel-editor-2.6.0.tgz",
"integrity": "sha512-rI7vFBATeKJVi/KpkfxnclTObAvQGYda0l5eKhNwGIJ8D3+aPQlgdNtxJATX1keXVkqsA1Q/+Yn8Ih+dnC0NMw==",
"license": "MIT",
"dependencies": {
"@bpmn-io/feel-lint": "^3.1.0",
"@bpmn-io/lang-feel": "^4.0.2",
"@camunda/feel-builtins": "^1.2.0",
"@codemirror/autocomplete": "^6.20.0",
"@codemirror/commands": "^6.10.3",
"@codemirror/language": "^6.11.3",
"@codemirror/lint": "^6.9.7",
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.43.1",
"@lezer/highlight": "^1.2.3",
"min-dom": "^5.3.0",
"mitt": "^3.0.1"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"@bpmn-io/cm-theme": "^0.2.0"
}
},
"node_modules/@bpmn-io/feel-editor/node_modules/domify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/domify/-/domify-3.0.0.tgz",
"integrity": "sha512-bs2yO68JDFOm6rKv8f0EnrM2cENduhRkpqOtt/s5l5JBA/eqGBZCzLPmdYoHtJ6utgLGgcBajFsEQbl12pT0lQ==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@bpmn-io/feel-editor/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/feel-editor/node_modules/min-dom": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/min-dom/-/min-dom-5.3.0.tgz",
"integrity": "sha512-0w5FEBgPAyHhmFojW3zxd7we3D+m5XYS3E/06OyvxmbHJoiQVa4Nagj6RWvoAKYRw5xth6cP5TMePc5cR1M9hA==",
"license": "MIT",
"dependencies": {
"domify": "^3.0.0",
"min-dash": "^5.0.0"
}
},
"node_modules/@bpmn-io/feel-lint": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/feel-lint/-/feel-lint-3.1.0.tgz",
"integrity": "sha512-nOCYWMXgwR0joU4XKhu4f3P5f4/AsmuyiV1e+fzcXTCh7iMLU8VYdHXSIzZuJ0zxz3Gsnp7A8S8lt+HJ43H6IA==",
"license": "MIT",
"dependencies": {
"@bpmn-io/lezer-feel": "^2.1.0",
"@codemirror/language": "^6.12.1"
},
"engines": {
"node": "*"
}
},
"node_modules/@bpmn-io/feelers-editor": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@bpmn-io/feelers-editor/-/feelers-editor-1.1.1.tgz",
"integrity": "sha512-HNvssf1nb/OohOgFxxR0hWIpIb8JBvmr2CQ28GD/5WLPKe3uvu9mpItIjNTCpLxLuVHlsJLNDtLkf2B6tvmt9Q==",
"license": "MIT",
"dependencies": {
"@bpmn-io/feelers-lint": "^1.0.0",
"@bpmn-io/lang-feelers": "^1.0.0",
"@codemirror/autocomplete": "^6.20.0",
"@codemirror/commands": "^6.10.1",
"@codemirror/language": "^6.12.1",
"@codemirror/lint": "^6.9.3",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.39.12",
"@lezer/common": "^1.5.1",
"@lezer/html": "^1.3.13",
"@lezer/markdown": "^1.6.3",
"min-dom": "^5.2.0",
"mitt": "^3.0.1"
},
"peerDependencies": {
"@bpmn-io/cm-theme": "^0.2.1"
}
},
"node_modules/@bpmn-io/feelers-editor/node_modules/domify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/domify/-/domify-3.0.0.tgz",
"integrity": "sha512-bs2yO68JDFOm6rKv8f0EnrM2cENduhRkpqOtt/s5l5JBA/eqGBZCzLPmdYoHtJ6utgLGgcBajFsEQbl12pT0lQ==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@bpmn-io/feelers-editor/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/feelers-editor/node_modules/min-dom": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/min-dom/-/min-dom-5.3.0.tgz",
"integrity": "sha512-0w5FEBgPAyHhmFojW3zxd7we3D+m5XYS3E/06OyvxmbHJoiQVa4Nagj6RWvoAKYRw5xth6cP5TMePc5cR1M9hA==",
"license": "MIT",
"dependencies": {
"domify": "^3.0.0",
"min-dash": "^5.0.0"
}
},
"node_modules/@bpmn-io/feelers-lint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/feelers-lint/-/feelers-lint-1.0.0.tgz",
"integrity": "sha512-9McPCub8NBSD3gbAM9fu6laGVvb6U/D8Y5Ar/GGvOaAuJ6W34yP5jaV/on4MALTwmmXTDadZjO2RJJNub3JmwQ==",
"license": "MIT",
"dependencies": {
"@bpmn-io/feel-lint": "^3.1.0",
"@codemirror/language": "^6.12.1",
"@codemirror/lint": "^6.9.3"
}
},
"node_modules/@bpmn-io/lang-feel": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@bpmn-io/lang-feel/-/lang-feel-4.0.2.tgz",
"integrity": "sha512-rTPeJ77/2nYKbJXpvDmrNXy+opoIpD3Rsch0grCUZAO6xF68r41QeV8SqOdr2yZxD/4gI6YXlQhqh4rqFRDJXA==",
"license": "MIT",
"dependencies": {
"@bpmn-io/lezer-feel": "^3.0.1",
"@codemirror/autocomplete": "^6.20.3",
"@codemirror/language": "^6.12.3",
"@lezer/common": "^1.5.2"
},
"engines": {
"node": ">= 20.12.0"
}
},
"node_modules/@bpmn-io/lang-feel/node_modules/@bpmn-io/lezer-feel": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@bpmn-io/lezer-feel/-/lezer-feel-3.0.1.tgz",
"integrity": "sha512-+wWg4DP2h8WOEQx2Bz51blsw9dCqKj3kIDKYccABuoAEhzZeDhmm0A2k4ANmm9lf0w5pJmVSYz2djtrbzOvzzA==",
"license": "MIT",
"dependencies": {
"@lezer/highlight": "^1.2.3",
"@lezer/lr": "^1.4.10",
"min-dash": "^5.0.0"
},
"engines": {
"node": ">= 20.12.0"
}
},
"node_modules/@bpmn-io/lang-feel/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/lang-feelers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/lang-feelers/-/lang-feelers-1.0.0.tgz",
"integrity": "sha512-VgBDw9cXr62e6Qs6LixQyLiBxxv7Kh8fxKFkYCmHPf/cO8beLQGjnF789wRlhK05yh/CuHi7oN7EYChrFQOHwg==",
"license": "MIT",
"dependencies": {
"@bpmn-io/lezer-feel": "^3.0.0",
"@bpmn-io/lezer-feelers": "^1.0.0",
"@codemirror/language": "^6.12.1",
"@lezer/common": "^1.5.1"
}
},
"node_modules/@bpmn-io/lang-feelers/node_modules/@bpmn-io/lezer-feel": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@bpmn-io/lezer-feel/-/lezer-feel-3.0.1.tgz",
"integrity": "sha512-+wWg4DP2h8WOEQx2Bz51blsw9dCqKj3kIDKYccABuoAEhzZeDhmm0A2k4ANmm9lf0w5pJmVSYz2djtrbzOvzzA==",
"license": "MIT",
"dependencies": {
"@lezer/highlight": "^1.2.3",
"@lezer/lr": "^1.4.10",
"min-dash": "^5.0.0"
},
"engines": {
"node": ">= 20.12.0"
}
},
"node_modules/@bpmn-io/lang-feelers/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/lezer-feel": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/lezer-feel/-/lezer-feel-2.5.0.tgz",
"integrity": "sha512-09JlwNYeD5YYeFrl0dIFfgQKEL+NNiTyUwEtdcPhfftz1mYa7z+ylOPCv/8Z0GqG7X81uyMFvRZDFCRBFTiUPg==",
"license": "MIT",
"dependencies": {
"@lezer/highlight": "^1.2.3",
"@lezer/lr": "^1.4.10",
"min-dash": "^5.0.0"
},
"engines": {
"node": ">= 20.12.0"
}
},
"node_modules/@bpmn-io/lezer-feel/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/lezer-feelers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/lezer-feelers/-/lezer-feelers-1.0.0.tgz",
"integrity": "sha512-P0znH2SY85O7RmOr/FgveFiTREet9DSCf3nH3J/StkI5i7Q384o+GEeTmv58n91FlUknS20KE3T8Yk5Qmab+hg==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.5.1",
"@lezer/highlight": "^1.1.6",
"@lezer/lr": "^1.4.8"
}
},
"node_modules/@bpmn-io/properties-panel": {
"version": "3.47.0",
"resolved": "https://registry.npmjs.org/@bpmn-io/properties-panel/-/properties-panel-3.47.0.tgz",
"integrity": "sha512-tZQRM0x9KLUEFU2FyHCwnYjSq1lbxpY8oCwABFA00IcuyeEDQFDV5DFg7ytTv2qOyWgncZ2xNXPRQ9pydkN2gg==",
"license": "MIT",
"dependencies": {
"@bpmn-io/feel-editor": "^2.6.0",
"@bpmn-io/feelers-editor": "^1.0.0",
"@codemirror/autocomplete": "^6.18.6",
"@codemirror/commands": "^6.10.3",
"@codemirror/lang-json": "^6.0.2",
"@codemirror/language": "^6.11.0",
"@codemirror/lint": "^6.9.5",
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.28.1",
"classnames": "^2.5.1",
"focus-trap": "^8.0.0",
"min-dash": "^5.0.0",
"min-dom": "^5.3.0"
},
"engines": {
"node": "*"
}
},
"node_modules/@bpmn-io/properties-panel/node_modules/classnames": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
"integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==",
"license": "MIT"
},
"node_modules/@bpmn-io/properties-panel/node_modules/domify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/domify/-/domify-3.0.0.tgz",
"integrity": "sha512-bs2yO68JDFOm6rKv8f0EnrM2cENduhRkpqOtt/s5l5JBA/eqGBZCzLPmdYoHtJ6utgLGgcBajFsEQbl12pT0lQ==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@bpmn-io/properties-panel/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/@bpmn-io/properties-panel/node_modules/min-dom": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/min-dom/-/min-dom-5.3.0.tgz",
"integrity": "sha512-0w5FEBgPAyHhmFojW3zxd7we3D+m5XYS3E/06OyvxmbHJoiQVa4Nagj6RWvoAKYRw5xth6cP5TMePc5cR1M9hA==",
"license": "MIT",
"dependencies": {
"domify": "^3.0.0",
"min-dash": "^5.0.0"
}
},
"node_modules/@bramus/specificity": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz",
@@ -409,6 +731,92 @@
"specificity": "bin/cli.js"
}
},
"node_modules/@camunda/feel-builtins": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@camunda/feel-builtins/-/feel-builtins-1.3.0.tgz",
"integrity": "sha512-ZahpLTeBUjnZEMI6Hu/n9e/oTPcJ8DpWmIyJ00tgVNWM1kqAEcMhARK0GthSrD5NXiSVICNHZ7VRTERMq2FmnA==",
"license": "MIT"
},
"node_modules/@codemirror/autocomplete": {
"version": "6.20.3",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz",
"integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==",
"license": "MIT",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.17.0",
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/commands": {
"version": "6.10.4",
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.4.tgz",
"integrity": "sha512-Ryk9y9T0FFVF0cUGhAknveAyUOl/A1qReTFi+qPKtOh2Z9F4AUBz3XOrYD4ZEgZirdugVzHvd/2/Wcwy5OliTg==",
"license": "MIT",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.7.0",
"@codemirror/view": "^6.27.0",
"@lezer/common": "^1.1.0"
}
},
"node_modules/@codemirror/lang-json": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz",
"integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==",
"license": "MIT",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/json": "^1.0.0"
}
},
"node_modules/@codemirror/language": {
"version": "6.12.4",
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz",
"integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.23.0",
"@lezer/common": "^1.5.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"style-mod": "^4.0.0"
}
},
"node_modules/@codemirror/lint": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",
"integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.42.0",
"crelt": "^1.0.5"
}
},
"node_modules/@codemirror/state": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.0.tgz",
"integrity": "sha512-Zbl9NyscLMZkfXPQnNAIIAFftidrA1UbcJEIMp24C0Bukc2I5T8wJS0wsXYsnDOqCFJUeJ1BITGNs5CqPDSmSg==",
"license": "MIT",
"dependencies": {
"@marijn/find-cluster-break": "^1.0.0"
}
},
"node_modules/@codemirror/view": {
"version": "6.43.4",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.4.tgz",
"integrity": "sha512-YImu23iyKfncJzT7sRy+rEqEhSc8RhOHqDxwy4WzXRKJwYm6iwf/9OJk5ctCAdZ6yi2ZqaGEvmf55fSVqMDrgg==",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.7.0",
"crelt": "^1.0.6",
"style-mod": "^4.1.0",
"w3c-keyname": "^2.2.4"
}
},
"node_modules/@csstools/color-helpers": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.0.2.tgz",
@@ -1063,6 +1471,62 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@lezer/common": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz",
"integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==",
"license": "MIT"
},
"node_modules/@lezer/highlight": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz",
"integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.3.0"
}
},
"node_modules/@lezer/html": {
"version": "1.3.13",
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.2.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/json": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz",
"integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.2.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/lr": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz",
"integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.0.0"
}
},
"node_modules/@lezer/markdown": {
"version": "1.6.4",
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.4.tgz",
"integrity": "sha512-N0SxazMj4k65DBfaf1azqtMZd6u7MqluP84/NZnB/io8Td9aleFmAhz9hcbvSfsxT5tdYlJ5qgv5aMJGY4zEtA==",
"license": "MIT",
"dependencies": {
"@lezer/common": "^1.5.0",
"@lezer/highlight": "^1.0.0"
}
},
"node_modules/@mapbox/node-pre-gyp": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz",
@@ -1099,6 +1563,12 @@
"node": ">=10"
}
},
"node_modules/@marijn/find-cluster-break": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.3.tgz",
"integrity": "sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==",
"license": "MIT"
},
"node_modules/@playwright/test": {
"version": "1.60.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0.tgz",
@@ -2298,6 +2768,18 @@
"dequal": "^2.0.3"
}
},
"node_modules/array-move": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/array-move/-/array-move-4.0.0.tgz",
"integrity": "sha512-+RY54S8OuVvg94THpneQvFRmqWdAHeqtMzgMW6JNurHxe8rsS07cHQdfGkXnTUXiBcyZ0j3SiDIxxj0RPiqCkQ==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
@@ -2475,6 +2957,65 @@
"node": "*"
}
},
"node_modules/bpmn-js-properties-panel": {
"version": "5.60.0",
"resolved": "https://registry.npmjs.org/bpmn-js-properties-panel/-/bpmn-js-properties-panel-5.60.0.tgz",
"integrity": "sha512-/+bi7pYR/aLUFS4VpCP96oDtWcMk+2dAjmHUYLbuk91/Cpn+6RYSzvXrl5USQRUH43Ng1xKfXyLYDTcr0P6e/Q==",
"license": "MIT",
"dependencies": {
"@bpmn-io/extract-process-variables": "^2.2.1",
"array-move": "^4.0.0",
"ids": "^3.0.2",
"min-dash": "^5.0.0",
"min-dom": "^5.3.0"
},
"engines": {
"node": "*"
},
"peerDependencies": {
"@bpmn-io/properties-panel": ">= 3.40.6",
"bpmn-js": ">= 11.5",
"camunda-bpmn-js-behaviors": ">= 0.4",
"diagram-js": ">= 11.9"
}
},
"node_modules/bpmn-js-properties-panel/node_modules/domify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/domify/-/domify-3.0.0.tgz",
"integrity": "sha512-bs2yO68JDFOm6rKv8f0EnrM2cENduhRkpqOtt/s5l5JBA/eqGBZCzLPmdYoHtJ6utgLGgcBajFsEQbl12pT0lQ==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/bpmn-js-properties-panel/node_modules/ids": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/ids/-/ids-3.0.2.tgz",
"integrity": "sha512-t6YJP4mdC+GHF96Nbis/4FEANhP/8VWmYMvUuYpXvSdrhg5hpIVbq2XZlOA3UWTbtdwPCi0q7jEXOdHkAnqOnw==",
"license": "MIT",
"engines": {
"node": ">= 20.12"
}
},
"node_modules/bpmn-js-properties-panel/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT"
},
"node_modules/bpmn-js-properties-panel/node_modules/min-dom": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/min-dom/-/min-dom-5.3.0.tgz",
"integrity": "sha512-0w5FEBgPAyHhmFojW3zxd7we3D+m5XYS3E/06OyvxmbHJoiQVa4Nagj6RWvoAKYRw5xth6cP5TMePc5cR1M9hA==",
"license": "MIT",
"dependencies": {
"domify": "^3.0.0",
"min-dash": "^5.0.0"
}
},
"node_modules/bpmn-moddle": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-8.1.0.tgz",
@@ -2608,6 +3149,46 @@
"node": ">= 0.4"
}
},
"node_modules/camunda-bpmn-js-behaviors": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/camunda-bpmn-js-behaviors/-/camunda-bpmn-js-behaviors-1.18.0.tgz",
"integrity": "sha512-ozmC9Btz7l6x0edBZaRxCUxF28mVbnTHO+v8ve8xGfhVRI0y8fFN/enAAILGk/eT2e+87BMx7uIUHGaxQBzbjQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"ids": "^3.0.1",
"min-dash": "^5.0.0"
},
"peerDependencies": {
"bpmn-js": ">= 9",
"camunda-bpmn-moddle": ">= 7",
"zeebe-bpmn-moddle": ">= 0.18"
}
},
"node_modules/camunda-bpmn-js-behaviors/node_modules/ids": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/ids/-/ids-3.0.2.tgz",
"integrity": "sha512-t6YJP4mdC+GHF96Nbis/4FEANhP/8VWmYMvUuYpXvSdrhg5hpIVbq2XZlOA3UWTbtdwPCi0q7jEXOdHkAnqOnw==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">= 20.12"
}
},
"node_modules/camunda-bpmn-js-behaviors/node_modules/min-dash": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.0.0.tgz",
"integrity": "sha512-EGuoBnVL7/Fnv2sqakpX5WGmZehZ3YMmLayT7sM8E9DRU74kkeyMg4Rik1lsOkR2GbFNeBca4/L+UfU6gF0Edw==",
"license": "MIT",
"peer": true
},
"node_modules/camunda-bpmn-moddle": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/camunda-bpmn-moddle/-/camunda-bpmn-moddle-7.0.1.tgz",
"integrity": "sha512-Br8Diu6roMpziHdpl66Dhnm0DTnCFMrSD9zwLV08LpD52QA0UsXxU87XfHf08HjuB7ly0Hd1bvajZRpf9hbmYQ==",
"license": "MIT",
"peer": true
},
"node_modules/caniuse-lite": {
"version": "1.0.30001797",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001797.tgz",
@@ -2850,6 +3431,12 @@
"node": ">= 10"
}
},
"node_modules/crelt": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
"integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
"license": "MIT"
},
"node_modules/cropperjs": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.2.tgz",
@@ -3573,6 +4160,15 @@
"react": "^15.0.2 || ^16.0.0 || ^17.0.0"
}
},
"node_modules/focus-trap": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-8.2.2.tgz",
"integrity": "sha512-qV0g8hRYBqgACcFOH3f9wXc4zPKhr/0z9RI2a6ZijZ72EeBi4g8oBy8zAWuUR1TsMpOzwpUMFvjdasrC41Joug==",
"license": "MIT",
"dependencies": {
"tabbable": "^6.5.0"
}
},
"node_modules/follow-redirects": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
@@ -4786,6 +5382,12 @@
"license": "ISC",
"optional": true
},
"node_modules/mitt": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
"license": "MIT"
},
"node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
@@ -6469,6 +7071,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/style-mod": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==",
"license": "MIT"
},
"node_modules/symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@@ -6476,6 +7084,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/tabbable": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.5.0.tgz",
"integrity": "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==",
"license": "MIT"
},
"node_modules/tar": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
@@ -7103,6 +7717,12 @@
}
}
},
"node_modules/w3c-keyname": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
"license": "MIT"
},
"node_modules/w3c-xmlserializer": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
@@ -7284,6 +7904,13 @@
"dev": true,
"license": "ISC"
},
"node_modules/zeebe-bpmn-moddle": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/zeebe-bpmn-moddle/-/zeebe-bpmn-moddle-1.16.0.tgz",
"integrity": "sha512-dsblK7DYgu4e3E4Vp9pSWjWpVrw+WtzLEMb82ak4FHL3FI7arWcTfIE/CviAS7iWD/UOl5YniQgee1LEJDdvaA==",
"license": "MIT",
"peer": true
},
"node_modules/zip-stream": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-4.1.1.tgz",

View File

@@ -11,8 +11,10 @@
"test": "vitest run"
},
"dependencies": {
"@bpmn-io/properties-panel": "^3.47.0",
"axios": "1.7.9",
"bpmn-js": "^17.11.1",
"bpmn-js-properties-panel": "^5.60.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.28.0"
@@ -32,6 +34,7 @@
"amis-formula": "^6.13.0",
"amis-theme-editor-helper": "^6.12.0-ab.1",
"amis-ui": "^6.13.0",
"bpmn-moddle": "^8.1.0",
"i18n-runtime": "^1.0.13",
"jsdom": "^29.1.1",
"typescript": "5.6.3",

View File

@@ -11,6 +11,7 @@ import { DesignCenterPage } from './pages/DesignCenterPage';
import { NewFeatureShell } from './pages/NewFeatureShell';
import { AiFeatureForm } from './pages/AiFeatureForm';
import { ModelerPage } from './pages/ModelerPage';
import { ProcessModelerPage } from './pages/ProcessModelerPage';
// 把 401 跳登录的 handler 注入 http 层(在路由上下文内,可用 navigate)
function UnauthorizedBridge() {
@@ -48,6 +49,8 @@ export default function App() {
<Route path="/ai-feature" element={<AiFeatureForm />} />
{/* 建模器(五环第①环·元数据→表,仅管理员)*/}
<Route path="/modeler" element={<ModelerPage />} />
{/* 在线流程 Modeler(可编辑 BPMN 设计器,仅管理员)*/}
<Route path="/process-modeler" element={<ProcessModelerPage />} />
{/* 根路径默认跳工作台 */}
<Route index element={<Navigate to="/workbench" replace />} />
</Route>

View File

@@ -0,0 +1,101 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
vi.mock('./http', () => ({ http: { get: vi.fn() } }));
import { http } from './http';
import { fetchProcDefSource, fetchProcDefSourceByKey, fetchProcessOptions } from './processModeler';
const mGet = vi.mocked(http.get);
beforeEach(() => {
mGet.mockReset();
});
describe('fetchProcDefSource', () => {
it('中文+冒号 procDefId 必须 encodeURIComponent 进 path', async () => {
mGet.mockResolvedValue({
data: { found: true, bpmnXml: '<x/>', idMap: {}, procDefKey: '总包合同交底', version: 3 },
});
// 真实库形态:中文流程名 + 冒号 + uuid
await fetchProcDefSource('总包合同交底:3:9b2f-uuid');
expect(mGet).toHaveBeenCalledTimes(1);
const url = mGet.mock.calls[0][0] as string;
expect(url).toBe(
'/api/workflow/process-definitions/' + encodeURIComponent('总包合同交底:3:9b2f-uuid') + '/source',
);
// 未编码的中文与裸冒号不得出现在 path segment 里
expect(url).not.toContain('总包合同交底');
expect(url).toContain('%E6%80%BB'); // 「总」的编码
});
it('found:false(后端省略 bpmnXml/idMap 键)不抛,只返回 found:false', async () => {
mGet.mockResolvedValue({ data: { found: false } });
const r = await fetchProcDefSource('PD-x');
expect(r).toEqual({ found: false });
expect('bpmnXml' in r).toBe(false);
});
it('found:true 时解构五字段', async () => {
mGet.mockResolvedValue({
data: { found: true, bpmnXml: '<def/>', idMap: { '总包合同交底': 'Proc_zbht' }, procDefKey: '总包合同交底', version: 5 },
});
const r = await fetchProcDefSource('PD-1');
expect(r).toEqual({
found: true,
bpmnXml: '<def/>',
idMap: { '总包合同交底': 'Proc_zbht' },
procDefKey: '总包合同交底',
version: 5,
});
});
});
describe('fetchProcDefSourceByKey', () => {
it('纯中文 key 必须 encodeURIComponent 进 by-key path', async () => {
mGet.mockResolvedValue({
data: { found: true, bpmnXml: '<x/>', idMap: {}, procDefKey: '总包合同交底', version: 4 },
});
await fetchProcDefSourceByKey('总包合同交底');
expect(mGet).toHaveBeenCalledTimes(1);
const url = mGet.mock.calls[0][0] as string;
expect(url).toBe('/api/workflow/process-definitions/by-key/' + encodeURIComponent('总包合同交底') + '/source');
expect(url).not.toContain('总包合同交底');
expect(url).toContain('%E6%80%BB');
});
it('found:false(省略键)不抛,只返回 found:false', async () => {
mGet.mockResolvedValue({ data: { found: false } });
const r = await fetchProcDefSourceByKey('无此流程');
expect(r).toEqual({ found: false });
expect('bpmnXml' in r).toBe(false);
});
});
describe('fetchProcessOptions', () => {
it('解 amis 信封 data.options 并映射 source/id/key 字段', async () => {
mGet.mockResolvedValue({
data: {
status: 0,
msg: '',
data: {
options: [{ label: '总包合同交底', value: '总包合同交底', source: 'model', id: 'PD:3:u', key: 'zbht', type: 'process' }],
},
},
});
const opts = await fetchProcessOptions();
expect(opts).toEqual([{ label: '总包合同交底', value: '总包合同交底', source: 'model', id: 'PD:3:u', key: 'zbht' }]);
});
it('history 来源 id 为空时 id=undefined(前端据此过滤不可载入项)', async () => {
mGet.mockResolvedValue({
data: { data: { options: [{ label: '历史流程', value: '历史流程', id: null, key: null }] } },
});
const opts = await fetchProcessOptions();
expect(opts[0].id).toBeUndefined();
});
it('缺 options / 非数组时返回空数组不抛', async () => {
mGet.mockResolvedValue({ data: {} });
expect(await fetchProcessOptions()).toEqual([]);
});
});

116
src/api/processModeler.ts Normal file
View File

@@ -0,0 +1,116 @@
import { http } from './http';
/**
* 流程 Modeler(在线 BPMN 设计器)后端契约。
*
* 阶段 1 只用到「按 procDefId 取净化源 XML」。裸 JSON 派,防御性默认 found:false,
* 与 diagram.ts 同风格。网关端点由 T1.6 上线,本层照 design 契约先写。
*/
/** GET /api/workflow/process-definitions/{id}/source 的返回体。 */
export interface ProcDefSource {
/** 是否命中流程定义(无则 found:false,不抛)。 */
found: boolean;
/** BpmnIdSanitizer 净化后的 BPMN 2.0 XML(中文 id 已替换为 ASCII,供 moddle/Modeler 载入)。 */
bpmnXml?: string;
/** 净化映射 原id→净化id(发布时逆向还原用,本 task 仅存 ref,后续 task 用)。 */
idMap?: Record<string, string>;
/** 流程定义 key(存量多为中文,如「总包合同交底」)。 */
procDefKey?: string;
/** 流程定义版本号。 */
version?: number;
}
/**
* source 端点返回体归一:found:false 时后端省略 bpmnXml/idMap 键——先判 found 再解构,
* 不在 false 分支碰这些键。
*/
function normalizeProcDefSource(data: ProcDefSource | undefined): ProcDefSource {
if (!data?.found) {
return { found: false };
}
return {
found: true,
bpmnXml: data.bpmnXml ?? undefined,
idMap: data.idMap ?? undefined,
procDefKey: data.procDefKey ?? undefined,
version: data.version ?? undefined,
};
}
/**
* 按 procDefId 取净化后的存量流程源 XML(含可逆 idMap)。
*
* ⚠️ procDefId 必须编码进 path:真实库 1445 个流程的 id 形如「总包合同交底:3:<uuid>」
* (中文 + 冒号),不 encodeURIComponent 会破坏 path segment。
*/
export async function fetchProcDefSource(procDefId: string): Promise<ProcDefSource> {
const { data } = await http.get<ProcDefSource>(
`/api/workflow/process-definitions/${encodeURIComponent(procDefId)}/source`,
);
return normalizeProcDefSource(data);
}
/**
* 按流程 key 取净化后的最新版存量流程源 XML。
*
* ⚠️ 本库 process-select 选项 source 全为 'model'——option.id 是 act_re_model id(非
* procDefId,按 id 载入必 found:false),只有 option.key 是流程 key。故 model 来源的打开
* 走本端点按 key 载入。key 常为纯中文(如「总包合同交底」),必须 encodeURIComponent 进 path。
*/
export async function fetchProcDefSourceByKey(key: string): Promise<ProcDefSource> {
const { data } = await http.get<ProcDefSource>(
`/api/workflow/process-definitions/by-key/${encodeURIComponent(key)}/source`,
);
return normalizeProcDefSource(data);
}
/**
* 存量流程选择器的一条选项。复用旧 ProcessSelectDialog 的数据源
* `/api/process-select/options`(amis 信封 {status,data:{options}})。
*
* - {@link source} 决定用哪个参数打开:'processDefinition'→id 即 procDefId;'model'/'history'→用 key。
* - {@link id} 为 procDefId(仅 source=processDefinition 可信;source=model 时 id 是 act_re_model id,
* 非 procDefId,不能按 id 载入)。
* - {@link value}/{@link label} 均为流程名称(沿用旧口径 value==label==流程名)。
*/
export interface ProcessOption {
label: string;
value: string;
source?: string;
id?: string;
key?: string;
}
interface ProcessSelectEnvelope {
data?: { options?: unknown[] };
options?: unknown[];
}
interface RawOption {
label?: unknown;
value?: unknown;
source?: unknown;
id?: unknown;
key?: unknown;
}
/** GET /api/process-select/options —— 取存量流程选项(解 amis 信封,防御性返回数组)。 */
export async function fetchProcessOptions(q?: string): Promise<ProcessOption[]> {
const { data } = await http.get<ProcessSelectEnvelope>('/api/process-select/options', {
params: q ? { q } : undefined,
});
const raw = data?.data?.options ?? data?.options ?? [];
if (!Array.isArray(raw)) return [];
return raw.map((o) => {
const opt = (o ?? {}) as RawOption;
const label = opt.label != null ? String(opt.label) : opt.value != null ? String(opt.value) : '';
return {
label,
value: opt.value != null ? String(opt.value) : label,
source: opt.source != null ? String(opt.source) : undefined,
id: opt.id != null && String(opt.id) !== '' ? String(opt.id) : undefined,
key: opt.key != null && String(opt.key) !== '' ? String(opt.key) : undefined,
};
});
}

View File

@@ -0,0 +1,6 @@
// bpmn-js-properties-panel 未随包发布类型声明(无 dist/*.d.ts、无 package.json types 字段)。
// 只声明本项目用到的两个标准模块(severe: 严禁引 Camunda provider,见 ProcessModelerPage)。
declare module 'bpmn-js-properties-panel' {
export const BpmnPropertiesPanelModule: unknown;
export const BpmnPropertiesProviderModule: unknown;
}

View File

@@ -0,0 +1,177 @@
{
"name": "Activiti",
"uri": "http://activiti.org/bpmn",
"prefix": "activiti",
"associations": [],
"types": [
{
"name": "ActivityExtension",
"isAbstract": true,
"extends": ["bpmn:Activity"],
"properties": [
{ "name": "exclusive", "isAttr": true, "type": "String" },
{ "name": "async", "isAttr": true, "type": "String" },
{ "name": "asyncBefore", "isAttr": true, "type": "String" },
{ "name": "asyncAfter", "isAttr": true, "type": "String" }
]
},
{
"name": "UserTaskExtension",
"isAbstract": true,
"extends": ["bpmn:UserTask"],
"properties": [
{ "name": "assignee", "isAttr": true, "type": "String" },
{ "name": "candidateUsers", "isAttr": true, "type": "String" },
{ "name": "candidateGroups", "isAttr": true, "type": "String" },
{ "name": "formKey", "isAttr": true, "type": "String" },
{ "name": "dueDate", "isAttr": true, "type": "String" },
{ "name": "priority", "isAttr": true, "type": "String" },
{ "name": "category", "isAttr": true, "type": "String" },
{ "name": "skipExpression", "isAttr": true, "type": "String" }
]
},
{
"name": "StartEventExtension",
"isAbstract": true,
"extends": ["bpmn:StartEvent"],
"properties": [
{ "name": "formKey", "isAttr": true, "type": "String" },
{ "name": "initiator", "isAttr": true, "type": "String" }
]
},
{
"name": "ProcessExtension",
"isAbstract": true,
"extends": ["bpmn:Process"],
"properties": [
{ "name": "candidateStarterUsers", "isAttr": true, "type": "String" },
{ "name": "candidateStarterGroups", "isAttr": true, "type": "String" },
{ "name": "versionTag", "isAttr": true, "type": "String" },
{ "name": "historyTimeToLive", "isAttr": true, "type": "String" }
]
},
{
"name": "ScriptTaskExtension",
"isAbstract": true,
"extends": ["bpmn:ScriptTask"],
"properties": [
{ "name": "autoStoreVariables", "isAttr": true, "type": "String" },
{ "name": "resultVariable", "isAttr": true, "type": "String" }
]
},
{
"name": "ServiceTaskExtension",
"isAbstract": true,
"extends": ["bpmn:ServiceTask", "bpmn:SendTask", "bpmn:BusinessRuleTask"],
"properties": [
{ "name": "class", "isAttr": true, "type": "String" },
{ "name": "expression", "isAttr": true, "type": "String" },
{ "name": "delegateExpression", "isAttr": true, "type": "String" },
{ "name": "resultVariableName", "isAttr": true, "type": "String" },
{ "name": "type", "isAttr": true, "type": "String" }
]
},
{
"name": "CallActivityExtension",
"isAbstract": true,
"extends": ["bpmn:CallActivity"],
"properties": [
{ "name": "calledElementBinding", "isAttr": true, "type": "String" },
{ "name": "calledElementVersion", "isAttr": true, "type": "String" }
]
},
{
"name": "MultiInstanceExtension",
"isAbstract": true,
"extends": ["bpmn:MultiInstanceLoopCharacteristics"],
"properties": [
{ "name": "collection", "isAttr": true, "type": "String" },
{ "name": "elementVariable", "isAttr": true, "type": "String" }
]
},
{
"name": "taskListener",
"superClass": ["Element"],
"meta": { "allowedIn": ["bpmn:UserTask"] },
"properties": [
{ "name": "event", "isAttr": true, "type": "String" },
{ "name": "class", "isAttr": true, "type": "String" },
{ "name": "expression", "isAttr": true, "type": "String" },
{ "name": "delegateExpression", "isAttr": true, "type": "String" },
{ "name": "fields", "type": "field", "isMany": true }
]
},
{
"name": "executionListener",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "event", "isAttr": true, "type": "String" },
{ "name": "class", "isAttr": true, "type": "String" },
{ "name": "expression", "isAttr": true, "type": "String" },
{ "name": "delegateExpression", "isAttr": true, "type": "String" },
{ "name": "fields", "type": "field", "isMany": true }
]
},
{
"name": "field",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "name", "isAttr": true, "type": "String" },
{ "name": "stringValue", "isAttr": true, "type": "String" },
{ "name": "string", "type": "String" },
{ "name": "expression", "type": "String" }
]
},
{
"name": "formProperty",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "id", "isAttr": true, "type": "String" },
{ "name": "name", "isAttr": true, "type": "String" },
{ "name": "type", "isAttr": true, "type": "String" },
{ "name": "required", "isAttr": true, "type": "String" },
{ "name": "readable", "isAttr": true, "type": "String" },
{ "name": "writable", "isAttr": true, "type": "String" },
{ "name": "variable", "isAttr": true, "type": "String" },
{ "name": "expression", "isAttr": true, "type": "String" },
{ "name": "datePattern", "isAttr": true, "type": "String" },
{ "name": "default", "isAttr": true, "type": "String" },
{ "name": "value", "isAttr": true, "type": "String" },
{ "name": "values", "type": "value", "isMany": true }
]
},
{
"name": "value",
"superClass": ["Element"],
"properties": [
{ "name": "id", "isAttr": true, "type": "String" },
{ "name": "name", "isAttr": true, "type": "String" }
]
},
{
"name": "in",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "source", "isAttr": true, "type": "String" },
{ "name": "sourceExpression", "isAttr": true, "type": "String" },
{ "name": "target", "isAttr": true, "type": "String" },
{ "name": "variables", "isAttr": true, "type": "String" }
]
},
{
"name": "out",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "source", "isAttr": true, "type": "String" },
{ "name": "sourceExpression", "isAttr": true, "type": "String" },
{ "name": "target", "isAttr": true, "type": "String" },
{ "name": "variables", "isAttr": true, "type": "String" }
]
}
]
}

3
src/modeler/moddle/bpmn-moddle.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
// bpmn-moddle 8.x 无自带类型声明(TS7016)。最小 ambient 声明消编辑器诊断;
// 运行时行为以 fidelity.test.ts 的 round-trip 断言为准。
declare module 'bpmn-moddle';

View File

@@ -0,0 +1,209 @@
import { describe, it, expect } from 'vitest';
import BpmnModdle from 'bpmn-moddle';
import activiti from './activiti.json';
import flowable from './flowable.json';
import { SYNTHETIC_BPMN } from './fixtures/synthetic-full-surface.bpmn';
// §0 实测扩展面(本地 eip4 库 5433):11 属性 + 5 元素 + 命名空间 activiti/flowable。
const CORPUS_ATTRS = [
'formKey', 'candidateUsers', 'exclusive', 'assignee', 'collection',
'elementVariable', 'candidateGroups', 'autoStoreVariables', 'initiator', 'dueDate',
];
const CORPUS_ELEMENTS = ['taskListener', 'formProperty', 'value', 'field', 'string'];
// 接收交底 userTask 的 candidateUsers 表达式反转义后的真实态:真引号 + 全角【】+ content 尾 4 空格。
const EXPECTED_CANDIDATE_USERS =
`\${candidateUsersHandler.getCandidateUsers(execution,'【"items":[【"type":"position",` +
`"content":"402881343cd50391013d62ccd0c20f7d ","isCandidate":true,"isSendMail":false,` +
`"isSendPhone":false,"isSendMessage":false】],"messageTemplate":"",` +
`"taskSuccessService":"PM_CONTRACTUALREGISTER_UPDATEPROJECTSTATUS",` +
`"isSkipInitiator":false,"isNoUserSkip":false,"isSkipBeforeTask":true】')}`;
// moddle 跨包同名 extends 属性冲突(activiti:exclusive vs flowable:exclusive 均挂 bpmn:Activity),
// 两包同载会丢元素。真实语料每文档只用一个命名空间(1509 activiti / 3 flowable,不混用),
// 故按命名空间隔离加载。见文末「moddle 约束」测试。
const newActiviti = () => new BpmnModdle({ activiti });
const newFlowable = () => new BpmnModdle({ flowable });
function proc(root: any): any {
return root.rootElements.find((e: any) => e.$type === 'bpmn:Process');
}
function findById(root: any, id: string): any {
return (proc(root).flowElements ?? []).find((e: any) => e.id === id);
}
function warns(res: any, re: RegExp): any[] {
return (res.warnings ?? []).filter((w: any) => re.test(String(w?.message ?? w)));
}
describe('activiti/flowable moddle 描述符 — 语料覆盖', () => {
it('§0 全部实测 activiti 属性/元素在 activiti.json 有声明', () => {
const declared = JSON.stringify(activiti);
[...CORPUS_ATTRS, ...CORPUS_ELEMENTS].forEach((n) =>
expect(declared, `activiti:${n} 未声明`).toContain(`"${n}"`));
});
it('flowable.json 声明命名空间与 flowable:assignee', () => {
expect(flowable.uri).toBe('http://flowable.org/bpmn');
expect(flowable.prefix).toBe('flowable');
expect(JSON.stringify(flowable)).toContain('"assignee"');
});
});
describe('activiti round-trip 零丢失(合成 fixture 覆盖全扩展面)', () => {
it('fromXML 干净:无 activiti 未知警告、无未解析引用(=描述符完整)', async () => {
const res = await newActiviti().fromXML(SYNTHETIC_BPMN);
expect(warns(res, /activiti|unparsable|unresolved/i)).toHaveLength(0);
// 全部流元素(含 userTask/scriptTask/boundaryEvent)都解析出来
const types = proc(res.rootElement).flowElements.map((e: any) => e.$type);
expect(types).toContain('bpmn:UserTask');
expect(types).toContain('bpmn:ScriptTask');
expect(types).toContain('bpmn:BoundaryEvent');
});
it('candidateUsers 被识别为 typed 属性且逐字保留(全角【】+ 尾空格 + JSON 原样)', async () => {
const { rootElement } = await newActiviti().fromXML(SYNTHETIC_BPMN);
const receive = findById(rootElement, 't_receive');
// 逐字保真:解析值 byte-exact 等于原文。
expect(receive.get('activiti:candidateUsers')).toBe(EXPECTED_CANDIDATE_USERS);
// typed 化的直接证据:值走声明属性、未回落 lax $attrs。
// (moddle .get() 对未声明属性也会回落 $attrs 返原值,故单看 .get() 不足以证明 typed 化。)
expect(receive.$attrs?.['activiti:candidateUsers']).toBeUndefined();
});
it('多实例 collection/elementVariable/completionCondition 解析为结构化模型', async () => {
const { rootElement } = await newActiviti().fromXML(SYNTHETIC_BPMN);
const write = findById(rootElement, 't_write');
const mi = write.loopCharacteristics;
expect(mi.$type).toBe('bpmn:MultiInstanceLoopCharacteristics');
expect(mi.get('activiti:elementVariable')).toBe('assignee');
expect(mi.get('activiti:collection')).toContain('multiInstanceUsersHandler.getUsers');
expect(mi.get('activiti:collection')).toContain('【"items":[');
expect(mi.completionCondition.body).toBe('${nrOfCompletedInstances/nrOfInstances==1}');
});
it('taskListener + field + string + formProperty/value 解析为结构化模型', async () => {
const { rootElement } = await newActiviti().fromXML(SYNTHETIC_BPMN);
const receive = findById(rootElement, 't_receive');
const listener = receive.extensionElements.values.find(
(v: any) => v.$type === 'activiti:taskListener',
);
expect(listener.event).toBe('complete');
expect(listener.class).toBe('com.dsasp.server.wf.user.listener.TaskCompleteListener');
expect(listener.fields[0].name).toBe('mailTemplate');
expect(listener.fields[0].string).toBe('审批完成通知');
const formProp = receive.extensionElements.values.find(
(v: any) => v.$type === 'activiti:formProperty',
);
expect(formProp.id).toBe('fp_remark');
expect(formProp.values.map((v: any) => v.name)).toEqual(['同意', '驳回']);
});
it('import→export 关键片段逐字保留(实体稳定:全角【】/中文 name/formKey/监听器/多实例/timer/条件)', async () => {
const moddle = newActiviti();
const { rootElement } = await moddle.fromXML(SYNTHETIC_BPMN);
const { xml } = await moddle.toXML(rootElement, { format: false });
// 中文 name(moddle 对 name 无 NCName 限制,与 id 不同)+ DI 引用(净化后的 ASCII id)
expect(xml).toContain('name="总包合同交底"');
expect(xml).toContain('bpmnElement="Proc_zbht"');
// 办理人 / 会签 handler 前缀(引号被 moddle 序列化为数字实体 &#39;/&#34;,故断言只取到括号前)
expect(xml).toContain('getCandidateUsers(execution,');
expect(xml).toContain('multiInstanceUsersHandler.getUsers');
// 全角【】原样出现在序列化字节里(不被转义)——JSON 包裹符零丢失的直接证据
expect(xml).toContain('【');
expect(xml).toContain('】');
// 内嵌 JSON 值原样(标识符不受实体化影响)+ content 尾 4 空格(CHAR 补白)
expect(xml).toContain('projectRoleType');
expect(xml).toContain('PM_CONTRACTUALREGISTER_UPDATEPROJECTSTATUS');
expect(xml).toContain('402881343cd50391013d62ccd0c20f7d ');
// 扩展属性
expect(xml).toContain('activiti:formKey="2098ce21-400b-4425-9c22-63e350974b98"');
expect(xml).toContain('activiti:formKey="3eee7644-f51d-4755-9abb-aca7f4dd8516"');
expect(xml).toContain('activiti:exclusive="false"');
expect(xml).toContain('activiti:elementVariable="assignee"');
expect(xml).toContain('activiti:initiator="applyuser"');
expect(xml).toContain('activiti:autoStoreVariables="false"');
// 扩展元素
expect(xml).toContain('activiti:taskListener');
expect(xml).toContain('com.dsasp.server.wf.user.listener.TaskCompleteListener');
expect(xml).toContain('审批完成通知');
expect(xml).toContain('activiti:formProperty');
expect(xml).toContain('activiti:value');
// BPMN 特性:boundary+timer / conditionExpression
expect(xml).toContain('timerEventDefinition');
expect(xml).toContain('PT8H');
expect(xml).toContain('isSave==true');
expect(xml).toContain('completionCondition');
});
it('二次 round-trip 稳定:export 结果再 import,candidateUsers 仍逐字一致', async () => {
const m1 = newActiviti();
const first = await m1.fromXML(SYNTHETIC_BPMN);
const { xml } = await m1.toXML(first.rootElement, { format: true });
const m2 = newActiviti();
const { rootElement } = await m2.fromXML(xml);
expect(findById(rootElement, 't_receive').get('activiti:candidateUsers')).toBe(
EXPECTED_CANDIDATE_USERS,
);
});
});
describe('flowable 命名空间 round-trip', () => {
const FLOWABLE_BPMN = `<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:flowable="http://flowable.org/bpmn" targetNamespace="t">
<process id="p_flowable" isExecutable="true">
<userTask id="u1" name="审批" flowable:assignee="\${assignee}" flowable:formKey="k1"></userTask>
</process>
</definitions>`;
it('flowable-only 加载时 flowable:assignee typed 化并 round-trip 零丢失', async () => {
const moddle = newFlowable();
const res = await moddle.fromXML(FLOWABLE_BPMN);
const u1 = findById(res.rootElement, 'u1');
expect(u1.get('flowable:assignee')).toBe('${assignee}');
const { xml } = await moddle.toXML(res.rootElement, { format: false });
expect(xml).toContain('flowable:assignee="${assignee}"');
expect(warns(res, /flowable/i)).toHaveLength(0);
});
it('activiti-only 加载时 flowable 属性经 lax $attrs 零丢失往返(Task 1.5 Modeler 单载 activiti 的依据)', async () => {
const moddle = newActiviti();
const res = await moddle.fromXML(FLOWABLE_BPMN);
const u1 = findById(res.rootElement, 'u1');
expect(u1.$attrs['flowable:assignee']).toBe('${assignee}');
const { xml } = await moddle.toXML(res.rootElement, { format: false });
expect(xml).toContain('flowable:assignee="${assignee}"');
expect(xml).toContain('flowable:formKey="k1"');
expect(warns(res, /flowable|unparsable/i)).toHaveLength(0);
});
});
describe('moddle 约束(勘探实证,固化为回归事实)', () => {
it('D7 依据:moddle-xml 拒绝中文 id(illegal ID),故进 moddle 前必须 BpmnIdSanitizer 净化', async () => {
const CN_ID = `<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" targetNamespace="t">
<process id="总包合同交底" name="总包合同交底" isExecutable="true">
<startEvent id="s1"></startEvent>
</process>
</definitions>`;
const res = await newActiviti().fromXML(CN_ID);
// 中文 id 的 process 被判 unparsable → 整个 process 丢失(rootElements 无 bpmn:Process)
expect(warns(res, /illegal ID|总包合同交底/)).not.toHaveLength(0);
expect((res.rootElement.rootElements ?? []).some((e: any) => e.$type === 'bpmn:Process')).toBe(false);
});
it('Task 1.5 约束:activiti+flowable 双包同载会因跨包同名 extends 属性冲突丢弃 userTask', async () => {
const BOTH = `<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:flowable="http://flowable.org/bpmn" targetNamespace="t">
<process id="p1" isExecutable="true">
<userTask id="u1" name="审批" activiti:exclusive="false" activiti:assignee="\${a}"></userTask>
</process>
</definitions>`;
const both = new BpmnModdle({ activiti, flowable });
const res = await both.fromXML(BOTH);
expect(warns(res, /redefines|already defined/)).not.toHaveLength(0);
// userTask 被判 unparsable 而丢失 —— 证明不可两包同载,必须按命名空间隔离(见本文件 newActiviti/newFlowable)
const types = proc(res.rootElement).flowElements?.map((e: any) => e.$type) ?? [];
expect(types).not.toContain('bpmn:UserTask');
});
});

View File

@@ -0,0 +1,103 @@
// 合成 fixture:复刻 §0 实测全扩展面 + 中文 name + 全角【】办理人 JSON。
//
// 形态逐字对照真实流程「总包合同交底」(本地 eip4 库 5433 抽取):
// - candidateUsers / multiInstance collection 的内嵌 JSON 用**全角【】**包裹对象,
// 方括号 [] 是半角,引号在 XML 属性里以 &quot; 转义(本文件即真实存储态)。
// - content 尾部的 4 个空格(CHAR 补白)原样保留,用于验证空白零丢失。
// - taskListener/formProperty/field/string、boundaryEvent+timer、conditionExpression、
// startEvent initiator/formKey、scriptTask autoStoreVariables、完整 BPMNDiagram DI。
//
// ⚠️ 关键约束(本任务勘探实证):bpmn-moddle / moddle-xml 会**拒绝中文 id**(报
// `illegal ID`,id 必须是 XSD NCName 的 ASCII 子集),故 moddle 层永远只处理**净化后的
// ASCII id**。真实流程的中文 id(=流程 key,如「总包合同交底」)由 BpmnIdSanitizer(Task 1.3)
// 在进 moddle 前净化、发布时还原——那才是 D7 id 可逆净化存在的根本原因。因此本 fixture 的
// process/节点 id 用 ASCII(模拟净化后态),中文只保留在 name 里(moddle 对 name 无限制)。
// 另有独立测试固化「moddle 拒绝中文 id」这一事实。
//
// 注意:TS 模板字符串里所有引擎表达式的 `${` 均转义为 `\${`,避免被当作插值。
// 不提交任何客户真实 BPMN(P6),仅此合成件覆盖全部扩展语义。
export const SYNTHETIC_BPMN = `<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
<process id="Proc_zbht" name="总包合同交底" isExecutable="true" activiti:candidateStarterGroups="all">
<startEvent id="start_1" name="发起" activiti:initiator="applyuser" activiti:formKey="7c9b-start-form"></startEvent>
<userTask id="t_write" name="编写交底" activiti:exclusive="false" activiti:assignee="\${assignee}" activiti:formKey="2098ce21-400b-4425-9c22-63e350974b98" activiti:dueDate="\${dueDate}" activiti:candidateGroups="managers">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="\${multiInstanceUsersHandler.getUsers(execution,'【&quot;items&quot;:[【&quot;type&quot;:&quot;projectRoleType&quot;,&quot;content&quot;:&quot;true,false,false,false,false,false,false,false,false,false,false&quot;,&quot;isCandidate&quot;:true,&quot;isSendMail&quot;:false,&quot;isSendPhone&quot;:false,&quot;isSendMessage&quot;:false】],&quot;messageTemplate&quot;:&quot;&quot;,&quot;taskSuccessService&quot;:&quot;&quot;,&quot;isSkipInitiator&quot;:false,&quot;isNoUserSkip&quot;:false,&quot;isSkipBeforeTask&quot;:false】')}" activiti:elementVariable="assignee">
<completionCondition>\${nrOfCompletedInstances/nrOfInstances==1}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
<userTask id="t_receive" name="接收交底" activiti:exclusive="false" activiti:candidateUsers="\${candidateUsersHandler.getCandidateUsers(execution,'【&quot;items&quot;:[【&quot;type&quot;:&quot;position&quot;,&quot;content&quot;:&quot;402881343cd50391013d62ccd0c20f7d &quot;,&quot;isCandidate&quot;:true,&quot;isSendMail&quot;:false,&quot;isSendPhone&quot;:false,&quot;isSendMessage&quot;:false】],&quot;messageTemplate&quot;:&quot;&quot;,&quot;taskSuccessService&quot;:&quot;PM_CONTRACTUALREGISTER_UPDATEPROJECTSTATUS&quot;,&quot;isSkipInitiator&quot;:false,&quot;isNoUserSkip&quot;:false,&quot;isSkipBeforeTask&quot;:true】')}" activiti:formKey="3eee7644-f51d-4755-9abb-aca7f4dd8516">
<extensionElements>
<activiti:taskListener event="complete" class="com.dsasp.server.wf.user.listener.TaskCompleteListener">
<activiti:field name="mailTemplate">
<activiti:string>审批完成通知</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:formProperty id="fp_remark" name="备注" type="string" required="true">
<activiti:value id="v1" name="同意"></activiti:value>
<activiti:value id="v2" name="驳回"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
<boundaryEvent id="boundary_1" name="超时" attachedToRef="t_receive" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT8H</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<scriptTask id="script_1" name="自动登记" scriptFormat="juel" activiti:autoStoreVariables="false">
<script>\${execution.setVariable('done', true)}</script>
</scriptTask>
<endEvent id="end_1"></endEvent>
<sequenceFlow id="f1" sourceRef="start_1" targetRef="t_write"></sequenceFlow>
<sequenceFlow id="f2" sourceRef="t_write" targetRef="t_receive"></sequenceFlow>
<sequenceFlow id="f3" sourceRef="t_receive" targetRef="script_1">
<conditionExpression xsi:type="tFormalExpression">\${isSave==true}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="f4" sourceRef="script_1" targetRef="end_1"></sequenceFlow>
<sequenceFlow id="f5" sourceRef="boundary_1" targetRef="end_1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_Proc_zbht">
<bpmndi:BPMNPlane bpmnElement="Proc_zbht" id="BPMNPlane_Proc_zbht">
<bpmndi:BPMNShape bpmnElement="start_1" id="BPMNShape_start_1">
<omgdc:Bounds height="30.0" width="30.0" x="99.0" y="179.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="t_write" id="BPMNShape_t_write">
<omgdc:Bounds height="80.0" width="100.0" x="174.0" y="154.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="t_receive" id="BPMNShape_t_receive">
<omgdc:Bounds height="80.0" width="100.0" x="375.0" y="154.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="boundary_1" id="BPMNShape_boundary_1">
<omgdc:Bounds height="31.0" width="31.0" x="410.0" y="216.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="script_1" id="BPMNShape_script_1">
<omgdc:Bounds height="80.0" width="100.0" x="576.0" y="154.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end_1" id="BPMNShape_end_1">
<omgdc:Bounds height="28.0" width="28.0" x="756.0" y="180.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="f1" id="BPMNEdge_f1">
<omgdi:waypoint x="129.0" y="194.0"></omgdi:waypoint>
<omgdi:waypoint x="174.0" y="194.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="f2" id="BPMNEdge_f2">
<omgdi:waypoint x="274.0" y="194.0"></omgdi:waypoint>
<omgdi:waypoint x="375.0" y="194.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="f3" id="BPMNEdge_f3">
<omgdi:waypoint x="475.0" y="194.0"></omgdi:waypoint>
<omgdi:waypoint x="576.0" y="194.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="f4" id="BPMNEdge_f4">
<omgdi:waypoint x="676.0" y="194.0"></omgdi:waypoint>
<omgdi:waypoint x="756.0" y="194.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="f5" id="BPMNEdge_f5">
<omgdi:waypoint x="425.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="425.0" y="320.0"></omgdi:waypoint>
<omgdi:waypoint x="770.0" y="320.0"></omgdi:waypoint>
<omgdi:waypoint x="770.0" y="208.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>`;

View File

@@ -0,0 +1,90 @@
{
"name": "Flowable",
"uri": "http://flowable.org/bpmn",
"prefix": "flowable",
"associations": [],
"types": [
{
"name": "ActivityExtension",
"isAbstract": true,
"extends": ["bpmn:Activity"],
"properties": [
{ "name": "exclusive", "isAttr": true, "type": "String" },
{ "name": "async", "isAttr": true, "type": "String" }
]
},
{
"name": "UserTaskExtension",
"isAbstract": true,
"extends": ["bpmn:UserTask"],
"properties": [
{ "name": "assignee", "isAttr": true, "type": "String" },
{ "name": "candidateUsers", "isAttr": true, "type": "String" },
{ "name": "candidateGroups", "isAttr": true, "type": "String" },
{ "name": "formKey", "isAttr": true, "type": "String" },
{ "name": "dueDate", "isAttr": true, "type": "String" }
]
},
{
"name": "StartEventExtension",
"isAbstract": true,
"extends": ["bpmn:StartEvent"],
"properties": [
{ "name": "formKey", "isAttr": true, "type": "String" },
{ "name": "initiator", "isAttr": true, "type": "String" }
]
},
{
"name": "MultiInstanceExtension",
"isAbstract": true,
"extends": ["bpmn:MultiInstanceLoopCharacteristics"],
"properties": [
{ "name": "collection", "isAttr": true, "type": "String" },
{ "name": "elementVariable", "isAttr": true, "type": "String" }
]
},
{
"name": "taskListener",
"superClass": ["Element"],
"meta": { "allowedIn": ["bpmn:UserTask"] },
"properties": [
{ "name": "event", "isAttr": true, "type": "String" },
{ "name": "class", "isAttr": true, "type": "String" },
{ "name": "expression", "isAttr": true, "type": "String" },
{ "name": "delegateExpression", "isAttr": true, "type": "String" },
{ "name": "fields", "type": "field", "isMany": true }
]
},
{
"name": "field",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "name", "isAttr": true, "type": "String" },
{ "name": "stringValue", "isAttr": true, "type": "String" },
{ "name": "string", "type": "String" },
{ "name": "expression", "type": "String" }
]
},
{
"name": "formProperty",
"superClass": ["Element"],
"meta": { "allowedIn": ["*"] },
"properties": [
{ "name": "id", "isAttr": true, "type": "String" },
{ "name": "name", "isAttr": true, "type": "String" },
{ "name": "type", "isAttr": true, "type": "String" },
{ "name": "required", "isAttr": true, "type": "String" },
{ "name": "values", "type": "value", "isMany": true }
]
},
{
"name": "value",
"superClass": ["Element"],
"properties": [
{ "name": "id", "isAttr": true, "type": "String" },
{ "name": "name", "isAttr": true, "type": "String" }
]
}
]
}

View File

@@ -30,10 +30,11 @@ describe('DesignCenterPage 入口按钮', () => {
profileMock.mockReset();
});
it('admin 看到 [+ 新建功能] 与 [⚡ AI 建功能]', async () => {
it('admin 看到 [流程设计] [+ 新建功能] 与 [⚡ AI 建功能]', async () => {
profileMock.mockReturnValue({ userId: 'ADMIN', account: 'admin', name: 'x', roles: [] });
renderPage();
await waitFor(() => {
expect(screen.getByTestId('dc-process-modeler')).toBeInTheDocument();
expect(screen.getByTestId('dc-new-feature')).toBeInTheDocument();
expect(screen.getByTestId('dc-ai-feature')).toBeInTheDocument();
});
@@ -42,6 +43,7 @@ describe('DesignCenterPage 入口按钮', () => {
it('非 admin 不渲染入口(整页降级)', () => {
profileMock.mockReturnValue({ userId: 'U1', account: 'zhangsan', name: 'z', roles: [] });
renderPage();
expect(screen.queryByTestId('dc-process-modeler')).not.toBeInTheDocument();
expect(screen.queryByTestId('dc-new-feature')).not.toBeInTheDocument();
expect(screen.queryByTestId('dc-ai-feature')).not.toBeInTheDocument();
});

View File

@@ -73,6 +73,14 @@ export function DesignCenterPage() {
</div>
</div>
<div style={{ flex: 1 }} />
<button
className="btn btn-sm"
data-testid="dc-process-modeler"
onClick={() => navigate('/process-modeler')}
title="在线流程设计器:可视化编辑存量 BPMN 流程 / 新建流程"
>
流程设计
</button>
<button
className="btn btn-sm"
data-testid="dc-new-feature"

View File

@@ -0,0 +1,141 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { SYNTHETIC_BPMN } from '../modeler/moddle/fixtures/synthetic-full-surface.bpmn';
// bpmn-js Modeler:jsdom 跑不动真渲染,stub 成类(可断言 importXML/destroy 调用)。
const { importXMLMock, destroyMock, getMock, onMock, attachToMock, ModelerCtor } = vi.hoisted(() => {
const importXMLMock = vi.fn();
const destroyMock = vi.fn();
const attachToMock = vi.fn();
const getMock = vi.fn((service: string) => {
if (service === 'propertiesPanel') return { attachTo: attachToMock };
if (service === 'canvas') return { zoom: vi.fn() };
return {};
});
const onMock = vi.fn();
const ModelerCtor = vi.fn().mockImplementation(() => ({
importXML: importXMLMock,
destroy: destroyMock,
get: getMock,
on: onMock,
}));
return { importXMLMock, destroyMock, getMock, onMock, attachToMock, ModelerCtor };
});
vi.mock('bpmn-js/lib/Modeler', () => ({ default: ModelerCtor }));
// 标准属性面板模块只作为 additionalModules 配置项传入被 mock 的 Modeler,永不真正执行。
vi.mock('bpmn-js-properties-panel', () => ({
BpmnPropertiesPanelModule: {},
BpmnPropertiesProviderModule: {},
}));
vi.mock('../api/processModeler', () => ({
fetchProcDefSource: vi.fn(),
fetchProcDefSourceByKey: vi.fn(),
fetchProcessOptions: vi.fn(),
}));
vi.mock('../auth/token', async (importOriginal) => ({
...(await importOriginal<typeof import('../auth/token')>()),
getProfile: vi.fn(),
}));
import { ProcessModelerPage } from './ProcessModelerPage';
import { fetchProcDefSource, fetchProcDefSourceByKey, fetchProcessOptions } from '../api/processModeler';
import { getProfile } from '../auth/token';
const mSource = vi.mocked(fetchProcDefSource);
const mSourceByKey = vi.mocked(fetchProcDefSourceByKey);
const mOptions = vi.mocked(fetchProcessOptions);
const mProfile = vi.mocked(getProfile);
function renderPage(initialPath = '/process-modeler') {
return render(
<MemoryRouter initialEntries={[initialPath]}>
<ProcessModelerPage />
</MemoryRouter>,
);
}
beforeEach(() => {
importXMLMock.mockReset().mockResolvedValue(undefined);
destroyMock.mockReset();
attachToMock.mockReset();
getMock.mockClear();
onMock.mockReset();
ModelerCtor.mockClear();
mSource.mockReset().mockResolvedValue({ found: true, bpmnXml: SYNTHETIC_BPMN, idMap: { '总包合同交底': 'Proc_zbht' } });
mSourceByKey.mockReset().mockResolvedValue({ found: true, bpmnXml: SYNTHETIC_BPMN, idMap: { '总包合同交底': 'Proc_zbht' } });
mOptions.mockReset().mockResolvedValue([]);
mProfile.mockReset().mockReturnValue({ userId: 'ADMIN', account: 'admin', name: '管理员', roles: [] });
});
describe('ProcessModelerPage', () => {
it('admin 渲染画布容器与标准属性面板容器', () => {
renderPage();
expect(screen.getByTestId('process-modeler-canvas')).toBeInTheDocument();
expect(screen.getByTestId('process-modeler-props')).toBeInTheDocument();
});
it('非 admin 降级为「仅管理员可用」文案,不渲染画布', () => {
mProfile.mockReturnValue({ userId: 'U9', account: 'zhang', name: '张三', roles: [] });
renderPage();
expect(screen.getByText(/仅管理员可用/)).toBeInTheDocument();
expect(screen.queryByTestId('process-modeler-canvas')).not.toBeInTheDocument();
});
it('?procDefId= 时载入存量流程并把返回的 bpmnXml 交给 Modeler.importXML', async () => {
renderPage('/process-modeler?procDefId=PD-1');
await waitFor(() => expect(mSource).toHaveBeenCalledWith('PD-1'));
await waitFor(() => expect(importXMLMock).toHaveBeenCalledWith(SYNTHETIC_BPMN));
expect(ModelerCtor).toHaveBeenCalledTimes(1);
});
it('构造后显式 attachTo 属性面板容器一次(修 live 面板从不挂载)', async () => {
renderPage('/process-modeler?procDefId=PD-1');
await waitFor(() => expect(attachToMock).toHaveBeenCalledTimes(1));
expect(attachToMock).toHaveBeenCalledWith(screen.getByTestId('process-modeler-props'));
});
it('接口 found:false 时显示未找到文案且不 importXML', async () => {
mSource.mockResolvedValue({ found: false });
renderPage('/process-modeler?procDefId=PD-x');
await waitFor(() => expect(screen.getByText(/未找到|无 BPMN|加载失败/)).toBeInTheDocument());
expect(importXMLMock).not.toHaveBeenCalled();
});
it('无参时展示「打开存量流程」选择器(数据源 process-select)', async () => {
mOptions.mockResolvedValue([{ label: '总包合同交底', value: '总包合同交底', source: 'model', id: 'MDL-1', key: 'zbht' }]);
renderPage();
await waitFor(() => expect(mOptions).toHaveBeenCalled());
expect(screen.getByTestId('process-modeler-open-select')).toBeInTheDocument();
expect(await screen.findByText('总包合同交底')).toBeInTheDocument();
});
it('?procKey= 时走 by-key 载入并 importXML(source=model 语义缺口修复)', async () => {
renderPage('/process-modeler?procKey=' + encodeURIComponent('总包合同交底'));
await waitFor(() => expect(mSourceByKey).toHaveBeenCalledWith('总包合同交底'));
await waitFor(() => expect(importXMLMock).toHaveBeenCalledWith(SYNTHETIC_BPMN));
expect(mSource).not.toHaveBeenCalled(); // 未走 by-id 路径
});
it('选中 source=model 选项 → 派到 by-key(procKey),不走 by-id', async () => {
mOptions.mockResolvedValue([{ label: '模型流程', value: '模型流程', source: 'model', id: 'MDL-9', key: 'MKEY' }]);
renderPage();
const select = await screen.findByTestId('process-modeler-open-select');
await screen.findByText('模型流程');
fireEvent.change(select, { target: { value: '0' } });
await waitFor(() => expect(mSourceByKey).toHaveBeenCalledWith('MKEY'));
expect(mSource).not.toHaveBeenCalled();
});
it('选中 source=processDefinition 选项 → 派到 by-id(procDefId)', async () => {
mOptions.mockResolvedValue([
{ label: '部署流程', value: '部署流程', source: 'processDefinition', id: '部署流程:3:uuid', key: 'k' },
]);
renderPage();
const select = await screen.findByTestId('process-modeler-open-select');
await screen.findByText('部署流程');
fireEvent.change(select, { target: { value: '0' } });
await waitFor(() => expect(mSource).toHaveBeenCalledWith('部署流程:3:uuid'));
expect(mSourceByKey).not.toHaveBeenCalled();
});
});

View File

@@ -0,0 +1,292 @@
// 在线流程 Modeler(B3)——可编辑 BPMN 设计器页骨架。
// 本阶段(T1.5)只做:admin 门 + 三栏布局 + bpmn-js Modeler 挂载 + 存量流程只读载入。
// EIP4 定制侧板(办理人/会签/formKey…)是 T2.4,本页右上只放占位容器;
// 「保存草稿」「发布」是 T2.5/T3.3,本页顶栏先放 disabled 占位按钮。
import { useEffect, useRef, useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import Modeler from 'bpmn-js/lib/Modeler';
import { BpmnPropertiesPanelModule, BpmnPropertiesProviderModule } from 'bpmn-js-properties-panel';
import 'bpmn-js/dist/assets/diagram-js.css';
import 'bpmn-js/dist/assets/bpmn-js.css';
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
import '@bpmn-io/properties-panel/dist/assets/properties-panel.css';
import activitiModdle from '../modeler/moddle/activiti.json';
import { getProfile, isAdminProfile } from '../auth/token';
import {
fetchProcDefSource,
fetchProcDefSourceByKey,
fetchProcessOptions,
type ProcessOption,
} from '../api/processModeler';
// bpmn-js/lib/Modeler 自带类型,但选项对象里的标准面板模块(本项目无类型)与 moddle JSON
// 会与官方选项类型产生摩擦;照 ProcessDiagram 惯例把构造器收窄为本页用到的最小契约再实例化。
interface ModelerLike {
importXML(xml: string): Promise<unknown>;
destroy(): void;
get(service: string): unknown;
on(event: string, cb: (e: unknown) => void): void;
}
const ModelerCtor = Modeler as unknown as new (options: Record<string, unknown>) => ModelerLike;
type LoadState = 'idle' | 'loading' | 'ready' | 'error';
export function ProcessModelerPage() {
const profile = getProfile();
const isAdmin = isAdminProfile(profile);
const navigate = useNavigate();
const [params, setParams] = useSearchParams();
// 打开存量流程两条路:?procDefId=(source=processDefinition,id 即 procDefId)
// 或 ?procKey=(source=model/history,按流程 key 载入最新版)。
const procDefId = params.get('procDefId') ?? '';
const procKey = params.get('procKey') ?? '';
const hasTarget = !!procDefId || !!procKey;
const canvasRef = useRef<HTMLDivElement>(null);
const panelRef = useRef<HTMLDivElement>(null);
const modelerRef = useRef<ModelerLike | null>(null);
// 净化映射 原id→净化id:本阶段仅暂存,发布还原(T3.x)时用。
const idMapRef = useRef<Record<string, string>>({});
const [loadState, setLoadState] = useState<LoadState>('idle');
const [loadError, setLoadError] = useState('');
const [options, setOptions] = useState<ProcessOption[]>([]);
const [optionsError, setOptionsError] = useState('');
// 未打开任何流程时拉存量流程选项(数据源复用旧 ProcessSelectDialog 端点)。
useEffect(() => {
if (!isAdmin || hasTarget) return;
let alive = true;
fetchProcessOptions()
.then((opts) => alive && setOptions(opts))
.catch(() => alive && setOptionsError('存量流程列表加载失败'));
return () => {
alive = false;
};
}, [isAdmin, hasTarget]);
// 有目标(procDefId 或 procKey)时挂载 Modeler 并载入净化后的存量 BPMN。
useEffect(() => {
if (!isAdmin || !hasTarget) return;
let alive = true;
let modeler: ModelerLike | null = null;
setLoadState('loading');
setLoadError('');
(async () => {
try {
// procDefId 优先(source=processDefinition);否则按 key(source=model/history)。
const src = procDefId
? await fetchProcDefSource(procDefId)
: await fetchProcDefSourceByKey(procKey);
if (!alive) return;
if (!src.found || !src.bpmnXml) {
setLoadError('未找到该流程的 BPMN 源(可能未部署或无布局信息)');
setLoadState('error');
return;
}
if (!canvasRef.current) {
// 画布容器缺失(异常时序):明确报错,别停在 loading 无提示(T1.5 评审 M-2)。
setLoadError('画布未就绪,请重试');
setLoadState('error');
return;
}
modeler = new ModelerCtor({
container: canvasRef.current,
propertiesPanel: { parent: panelRef.current },
// ⚠️ 只载标准 BpmnPropertiesProviderModule,严禁引 Camunda provider——它会把
// camunda 描述符注进 moddle,与 activiti 描述符在 bpmn:UserTask 上同名扩展冲突
// (not allowed without redefines) 静默丢弃 userTask(T1.1 评审 M-3 实证)。
additionalModules: [BpmnPropertiesPanelModule, BpmnPropertiesProviderModule],
// ⚠️ moddleExtensions 只声明 activiti:语料 1509/3 两命名空间不混用,双载会因同名
// 扩展属性冲突静默丢弃 userTask;单载 activiti 时 flowable 文档经 moddle lax 往返零丢失。
moddleExtensions: { activiti: activitiModdle },
});
// ⚠️ 显式 attachTo:live 实证——只靠构造参数 propertiesPanel.parent,面板从不挂载
// (.bio-properties-panel 在 document 中为 0;构造时 ref 时序/传对象非 element 皆可致此)。
// attachTo 容器 DOM 是 bpmn-js-properties-panel 的规范补救。放在 importXML 前,alive 内。
if (panelRef.current) {
try {
(modeler.get('propertiesPanel') as { attachTo(el: HTMLElement): void }).attachTo(panelRef.current);
} catch {
/* 面板模块缺失 / stub 时忽略 */
}
}
idMapRef.current = src.idMap ?? {};
await modeler.importXML(src.bpmnXml);
if (!alive) return;
modelerRef.current = modeler;
try {
const canvas = modeler.get('canvas') as { zoom(mode: string, point?: string): void };
canvas.zoom('fit-viewport', 'auto');
} catch {
/* stub / 无布局时忽略 */
}
setLoadState('ready');
} catch {
if (alive) {
setLoadError('流程加载失败');
setLoadState('error');
}
}
})();
return () => {
alive = false;
if (modeler) {
try {
modeler.destroy();
} catch {
/* 视图已卸载 */
}
}
modelerRef.current = null;
};
}, [isAdmin, procDefId, procKey]);
if (!isAdmin) {
return <div style={{ padding: 24, color: 'var(--text-3)' }}>流程设计器仅管理员可用。</div>;
}
// 可载入 = 有可用打开参数:processDefinition 需 id(procDefId);其余(model/history)需 key。
const loadableOptions = options.filter((o) =>
o.source === 'processDefinition' ? !!o.id : !!o.key,
);
// 选择器按 source 分派:processDefinition→?procDefId=<id>;其余→?procKey=<key>。
// 用索引取回选项对象(避免把 id/key 直接塞进 <option value> 造成路由二义)。
function openSelected(indexValue: string) {
if (indexValue === '') return;
const opt = loadableOptions[Number(indexValue)];
if (!opt) return;
if (opt.source === 'processDefinition' && opt.id) {
setParams({ procDefId: opt.id });
} else if (opt.key) {
setParams({ procKey: opt.key });
}
}
return (
<div
data-testid="process-modeler-root"
style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}
>
{/* 顶栏 */}
<div
style={{
height: 48,
display: 'flex',
alignItems: 'center',
gap: 12,
padding: '0 16px',
borderBottom: '1px solid var(--line)',
flexShrink: 0,
}}
>
<span style={{ fontWeight: 600, fontSize: 15 }}>流程设计器</span>
<span className="muted" style={{ fontSize: 12, flex: 1 }}>
{hasTarget ? `已打开:${procDefId || procKey}` : '在线编辑 BPMN 流程定义(可编辑存量 / 新建)'}
</span>
<button className="btn btn-sm" data-testid="process-modeler-save-draft" disabled title="保存草稿(下阶段)">
保存草稿
</button>
<button className="btn btn-sm btn-primary" data-testid="process-modeler-publish" disabled title="发布(下阶段)">
发布
</button>
<button className="btn btn-sm" data-testid="process-modeler-back" onClick={() => navigate('/design-center')}>
返回
</button>
</div>
{/* 主体:左画布 + 右栏(上=EIP4 侧板占位 / 下=标准属性面板) */}
<div style={{ flex: 1, display: 'flex', minHeight: 0 }}>
<div style={{ flex: 1, position: 'relative', minWidth: 0, background: '#fff' }}>
<div ref={canvasRef} data-testid="process-modeler-canvas" style={{ width: '100%', height: '100%' }} />
{/* 未打开任何流程:叠加「打开存量流程」选择器 + 新建占位 */}
{!hasTarget ? (
<div
style={{
position: 'absolute',
inset: 0,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
gap: 12,
background: 'var(--surface, #fff)',
}}
>
<div style={{ color: 'var(--text-3)', fontSize: 13 }}>选择一个存量流程开始编辑</div>
<select
data-testid="process-modeler-open-select"
defaultValue=""
onChange={(e) => openSelected(e.target.value)}
style={{ minWidth: 280, padding: '6px 8px' }}
>
<option value="">打开存量流程…</option>
{loadableOptions.map((o, i) => (
<option key={o.id ?? o.key ?? i} value={i}>
{o.label}
</option>
))}
</select>
{optionsError ? (
<div style={{ color: 'var(--err)', fontSize: 12 }}>{optionsError}</div>
) : null}
<button className="btn btn-sm" data-testid="process-modeler-new" disabled title="新建流程(下阶段)">
+ 新建流程
</button>
</div>
) : null}
{/* 载入中 / 载入失败 */}
{hasTarget && loadState === 'loading' ? (
<div style={overlayMsgStyle('var(--text-3)')} data-testid="process-modeler-loading">
加载流程中…
</div>
) : null}
{hasTarget && loadState === 'error' ? (
<div style={overlayMsgStyle('var(--warn, #d48806)')} data-testid="process-modeler-error">
{loadError}
</div>
) : null}
</div>
<div
style={{
width: 360,
flexShrink: 0,
borderLeft: '1px solid var(--line)',
display: 'flex',
flexDirection: 'column',
minHeight: 0,
}}
>
{/* EIP4 定制侧板占位(办理人/会签/formKey…由 T2.4 接入) */}
<div
data-testid="process-modeler-eip4-panel"
style={{ padding: 12, borderBottom: '1px solid var(--line)', color: 'var(--text-3)', fontSize: 12 }}
>
EIP4 定制控件(办理人 / 会签 / formKey)将在此叠加,下阶段接入。
</div>
{/* 标准属性面板宿主(bpmn-js-properties-panel attachTo 进此容器) */}
<div ref={panelRef} data-testid="process-modeler-props" style={{ flex: 1, overflow: 'auto', minHeight: 0 }} />
</div>
</div>
</div>
);
}
function overlayMsgStyle(color: string): React.CSSProperties {
return {
position: 'absolute',
top: 16,
left: 16,
padding: '8px 12px',
background: 'rgba(255,255,255,0.92)',
borderRadius: 4,
color,
fontSize: 13,
};
}

View File

@@ -0,0 +1,325 @@
#!/usr/bin/env node
/**
* 全量真实流程 moddle round-trip 保真扫描(Task 1.2)
*
* 对本地 eip4 库(5433, search_path=eip3)里 act_ge_bytearray 的全部真实 BPMN
* (name_ like %.bpmn% / %.xml)逐条做 bpmn-moddle fromXML→toXML 往返,验证
* 「所有 activiti / flowable 扩展属性(含值,实体解码归一后) + 扩展元素结构
* + 全部 bpmn 元素 id 集合」在往返前后多重集一致(数据级零丢失,非字节级)。
*
* 取数:psql 子进程(不引 pg 依赖);命名空间嗅探后单载 activiti 或 flowable
* (T1.1 实证:双载会因跨包同名 extends 冲突丢 userTask)。进 moddle 前先净化
* 中文/非法 id(镜像后端 ProcessDiagramController.sanitizeBpmnIds;moddle-xml
* 拒绝非 ASCII-NCName id,1445/1512 文档 process id 为中文)。
*
* 用法:node tools/modeler-fidelity-sweep.mjs
* 环境变量:PG_HOST(localhost) PG_PORT(5433) PG_DB(eip4) PG_SCHEMA(eip3)
*/
import { execFileSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import BpmnModdle from 'bpmn-moddle';
const HERE = dirname(fileURLToPath(import.meta.url));
const activiti = JSON.parse(readFileSync(resolve(HERE, '../src/modeler/moddle/activiti.json'), 'utf8'));
const flowable = JSON.parse(readFileSync(resolve(HERE, '../src/modeler/moddle/flowable.json'), 'utf8'));
const PG_HOST = process.env.PG_HOST || 'localhost';
const PG_PORT = process.env.PG_PORT || '5433';
const PG_DB = process.env.PG_DB || 'eip4';
const PG_SCHEMA = process.env.PG_SCHEMA || 'eip3';
// ── 取数:psql 拉 id|name|base64(base64 去换行,同勘探法)───────────────────
function pullCorpus() {
const sql =
`set search_path=${PG_SCHEMA},public; ` +
`select b.id_||'|'||b.name_||'|'||translate(encode(b.bytes_,'base64'),E'\\n','') ` +
`from act_ge_bytearray b where b.name_ like '%.bpmn%' or b.name_ like '%.xml';`;
const out = execFileSync(
'psql',
['-h', PG_HOST, '-p', PG_PORT, '-d', PG_DB, '-tA', '-c', sql],
{ encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024 },
);
const docs = [];
for (const line of out.split('\n')) {
if (!line) continue;
const i1 = line.indexOf('|');
const i2 = line.indexOf('|', i1 + 1);
if (i1 < 0 || i2 < 0) continue;
docs.push({ id: line.slice(0, i1), name: line.slice(i1 + 1, i2), b64: line.slice(i2 + 1) });
}
return docs;
}
// ── XML 实体解码归一(数据级比对:&quot;→" &#34;→" 全角/中文原样)────────────
function decodeEntities(s) {
return String(s)
.replace(/&#x([0-9a-fA-F]+);/g, (_, h) => String.fromCodePoint(parseInt(h, 16)))
.replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(parseInt(d, 10)))
.replace(/&quot;/g, '"')
.replace(/&apos;/g, "'")
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&'); // amp 最后解,避免 &amp;#34; 被二次解码
}
// ── id 净化:镜像 ProcessDiagramController.sanitizeBpmnIds(可逆非本工具关注)─
// 安全 id = ASCII-NCName(首字符字母/下划线,其余字母/数字/_/-/.)。非法则映射为
// 稳定唯一占位符(本工具用无冲突计数器,隔离 T1.3 哈希碰撞与 moddle 保真两问题)。
const ID_ATTR = /\b(id|bpmnElement|sourceRef|targetRef|attachedToRef|processRef|default)\s*=\s*"([^"]+)"/g;
function isSafeId(v) {
return /^[A-Za-z_][A-Za-z0-9_.-]*$/.test(v);
}
function sanitizeIds(xml) {
const map = new Map();
let n = 0;
let m;
ID_ATTR.lastIndex = 0;
while ((m = ID_ATTR.exec(xml))) {
const val = m[2];
if (!isSafeId(val) && !map.has(val)) map.set(val, `sanid_${n++}`);
}
if (map.size === 0) return { xml, remapped: 0 };
ID_ATTR.lastIndex = 0;
const rewritten = xml.replace(ID_ATTR, (_, attr, val) => `${attr}="${map.get(val) ?? val}"`);
return { xml: rewritten, remapped: map.size };
}
// ── 命名空间嗅探:activiti 优先,其次 flowable,默认 activiti ─────────────────
// M3 前提:靠字面量 uri/前缀识别命名空间,依赖语料使用规范前缀 activiti/flowable。
// §0 实测本库确如此(activiti 1509 / flowable 3,无自定义前缀重映射),故成立;
// 若未来语料出现 xmlns:act="http://activiti.org/bpmn" 之类别名,此处需扩正则。
function sniffModdle(xml) {
const hasActiviti = xml.includes('activiti.org/bpmn') || /\bactiviti:/.test(xml);
const hasFlowable = xml.includes('flowable.org/bpmn') || /\bflowable:/.test(xml);
if (hasActiviti) return { pkg: { activiti }, ns: 'activiti' };
if (hasFlowable) return { pkg: { flowable }, ns: 'flowable' };
return { pkg: { activiti }, ns: 'activiti(default)' };
}
// ── 扩展面「多重集」签名:数据级零丢失的比对基础 ───────────────────────────
// 逐 tag 扫描(well-formed BPMN 下正则足够),区分扩展元素 tag / 原生元素上的
// 扩展属性;文本单独扫;id 全量。所有值实体解码后入袋(顺序无关)。
const TAG_RE = /<([/!?]?)([\w:.-]+)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
const ATTR_RE = /([\w:.-]+)\s*=\s*"([^"]*)"/g;
const EXT_TEXT_RE = /<((?:activiti|flowable):[\w.-]+)((?:[^>"']|"[^"]*"|'[^']*')*)>([^<]*)<\//g;
// I1:引用类属性单独入袋,捕捉 round-trip/净化重写破坏的连线(sourceRef/targetRef/
// bpmnElement/processRef/attachedToRef/default)。与 sanitizeIds 的 ID_ATTR 同覆盖面。
const REF_ATTRS = new Set(['sourceRef', 'targetRef', 'bpmnElement', 'processRef', 'attachedToRef', 'default']);
function surface(xml) {
const extAttrs = []; // 原生元素上的 activiti:/flowable: 属性 p:name=value
const extElemTags = []; // 扩展元素本身 tag
const extElemAttrs = [];// 扩展元素上的属性(含无前缀) tag@attr=value
const extElemText = []; // 扩展叶元素的文本 tag#text=value
const ids = []; // 全部 id="..."(含原生/DI/扩展)
const refs = []; // 引用类属性 an=value(连线/DI 指向完整性,I1)
let m;
TAG_RE.lastIndex = 0;
while ((m = TAG_RE.exec(xml))) {
const close = m[1];
const name = m[2];
const attrBlob = m[3] || '';
if (close === '/' || close === '!' || close === '?') continue; // 闭合/注释/声明
const isExt = /^(activiti|flowable):/.test(name);
let a;
ATTR_RE.lastIndex = 0;
while ((a = ATTR_RE.exec(attrBlob))) {
const an = a[1];
const av = decodeEntities(a[2]);
if (an === 'id') ids.push(av);
else if (REF_ATTRS.has(an)) refs.push(`${an}=${av}`);
if (isExt) {
extElemAttrs.push(`${name}@${an}=${av}`);
} else if (/^(activiti|flowable):/.test(an)) {
extAttrs.push(`${an}=${av}`);
}
}
if (isExt) extElemTags.push(name);
}
// M4:extElemText 对叶元素文本做 trim 归一(去两端空白),故不比对纯空白/缩进差异。
// 扩展叶文本(监听器 field 值、表单选项 name 等)非空白敏感,且前后同样 trim,对称无偏。
EXT_TEXT_RE.lastIndex = 0;
while ((m = EXT_TEXT_RE.exec(xml))) {
const t = decodeEntities(m[3]).trim();
if (t) extElemText.push(`${m[1]}#text=${t}`);
}
return { extAttrs, extElemTags, extElemAttrs, extElemText, ids, refs };
}
function bag(arr) {
const b = new Map();
for (const v of arr) b.set(v, (b.get(v) || 0) + 1);
return b;
}
// 多重集差异:返回 {missing:[...], added:[...]}(before→after)
function diffBag(before, after) {
const b = bag(before);
const a = bag(after);
const missing = [];
const added = [];
for (const [k, c] of b) {
const ac = a.get(k) || 0;
if (ac < c) missing.push(`${k} (×${c - ac})`);
}
for (const [k, c] of a) {
const bc = b.get(k) || 0;
if (bc < c) added.push(`${k} (×${c - bc})`);
}
return { missing, added };
}
// ── 主流程 ───────────────────────────────────────────────────────────────
async function main() {
process.stdout.write(`连库拉取语料 (${PG_HOST}:${PG_PORT}/${PG_DB}, schema=${PG_SCHEMA}) ...\n`);
const docs = pullCorpus();
process.stdout.write(`取到 ${docs.length} 个 .bpmn/.xml 文档,开始 round-trip 扫描 ...\n\n`);
let ok = 0;
const failures = [];
const decodeFailures = [];
const parseErrors = [];
const warnCounts = new Map(); // 归一 warning key → 次数
const nsCounts = new Map();
for (const doc of docs) {
// 1) base64 → UTF8,并校验解码无损(非法 UTF8 会 toString 回落 U+FFFD)
const buf = Buffer.from(doc.b64, 'base64');
const xml = buf.toString('utf8');
if (!Buffer.from(xml, 'utf8').equals(buf)) {
decodeFailures.push({ id: doc.id, name: doc.name, bytes: buf.length });
continue;
}
// 2) 命名空间嗅探 → 单载
const { pkg, ns } = sniffModdle(xml);
nsCounts.set(ns, (nsCounts.get(ns) || 0) + 1);
// 3) 净化非法 id(否则中文 id 文档被 moddle 整体拒收)
const { xml: sanitized } = sanitizeIds(xml);
// 4) round-trip
let out;
let warnings = [];
try {
const moddle = new BpmnModdle(pkg);
const parsed = await moddle.fromXML(sanitized);
warnings = parsed.warnings || [];
const exported = await moddle.toXML(parsed.rootElement, { format: false });
out = exported.xml;
} catch (e) {
parseErrors.push({ id: doc.id, name: doc.name, error: String(e && e.message || e) });
continue;
}
const unresolvedRefs = [];
for (const w of warnings) {
const msg = String(w && w.message || w);
const key = normWarn(msg);
warnCounts.set(key, (warnCounts.get(key) || 0) + 1);
if (key === 'unresolved reference') {
const mr = msg.match(/unresolved reference <([^>]+)>/i);
unresolvedRefs.push(mr ? mr[1] : msg.slice(0, 60));
}
}
// 5) 数据级零丢失比对:sanitized(前) vs out(后)
const before = surface(sanitized);
const after = surface(out);
const diffs = {};
let lost = false;
for (const k of ['extAttrs', 'extElemTags', 'extElemAttrs', 'extElemText', 'ids', 'refs']) {
const d = diffBag(before[k], after[k]);
if (d.missing.length || d.added.length) {
diffs[k] = d;
lost = true;
}
}
// I1②:未解析引用计入硬门(净化/往返破坏连线的直接信号,不再只当 warning)
if (lost || unresolvedRefs.length) {
failures.push({ id: doc.id, name: doc.name, ns, diffs, unresolved: unresolvedRefs });
} else {
ok++;
}
}
const expectedTotal = Number(process.env.EXPECTED_TOTAL || 1512);
report({ total: docs.length, ok, failures, decodeFailures, parseErrors, warnCounts, nsCounts, expectedTotal });
// 硬门:真实 BPMN 全部零丢失 + 无解析异常 + 无解码失败 + 语料规模符合预期。
// (M2:解码失败与规模不符均判失败——过滤集内本应 100% 干净 UTF8,且恒 EXPECTED_TOTAL 篇)
const gateOk =
failures.length === 0 &&
parseErrors.length === 0 &&
decodeFailures.length === 0 &&
docs.length === expectedTotal;
process.exit(gateOk ? 0 : 1);
}
// warning 归一:抽取属性/元素名做聚合键
function normWarn(msg) {
const mAttr = msg.match(/unknown (?:type|attribute) <([^>]+)>/i);
if (mAttr) return `unknown <${mAttr[1]}>`;
const mUn = msg.match(/unparsable content <([^>]+)>/i);
if (mUn) return `unparsable <${mUn[1]}>`;
const mRef = msg.match(/unresolved reference <([^>]+)>/i);
if (mRef) return 'unresolved reference';
return msg.replace(/<[^>]*>/g, '<…>').slice(0, 80);
}
function report(r) {
const line = '─'.repeat(60);
process.stdout.write(`${line}\n保真扫描结果\n${line}\n`);
process.stdout.write(`匹配 ${r.ok}/${r.total} 零丢失(真实 BPMN)\n`);
process.stdout.write(`总文档 ${r.total}(预期 ${r.expectedTotal})|零丢失 ${r.ok}|丢失 ${r.failures.length}|解析异常 ${r.parseErrors.length}|解码失败 ${r.decodeFailures.length}\n`);
if (r.total !== r.expectedTotal) {
process.stdout.write(`⚠ 语料规模 ${r.total} ≠ 预期 ${r.expectedTotal}(EXPECTED_TOTAL)→ 判失败\n`);
}
process.stdout.write(`\n命名空间加载分布:\n`);
for (const [ns, c] of [...r.nsCounts].sort((a, b) => b[1] - a[1])) {
process.stdout.write(` ${ns}: ${c}\n`);
}
process.stdout.write(`\nfromXML warnings(按归一键聚合,仅描述符覆盖信号,不判失败):\n`);
const ws = [...r.warnCounts].sort((a, b) => b[1] - a[1]);
if (!ws.length) process.stdout.write(' (无)\n');
for (const [k, c] of ws.slice(0, 40)) process.stdout.write(` ${c.toString().padStart(6)} ${k}\n`);
if (ws.length > 40) process.stdout.write(` … 另有 ${ws.length - 40} 类\n`);
if (r.decodeFailures.length) {
process.stdout.write(`\nbase64→UTF8 解码失败文档(单列,非 UTF8 BPMN):\n`);
for (const d of r.decodeFailures) process.stdout.write(` id=${d.id} name=${d.name} bytes=${d.bytes}\n`);
}
if (r.parseErrors.length) {
process.stdout.write(`\nmoddle 解析/序列化异常:\n`);
for (const e of r.parseErrors.slice(0, 30)) process.stdout.write(` id=${e.id} name=${e.name}\n ${e.error}\n`);
}
if (r.failures.length) {
process.stdout.write(`\n零丢失失败清单(round-trip 前后扩展面差异):\n`);
for (const f of r.failures.slice(0, 30)) {
process.stdout.write(` id=${f.id} name=${f.name} [${f.ns}]\n`);
for (const [k, d] of Object.entries(f.diffs)) {
if (d.missing.length) process.stdout.write(` ${k} 丢失: ${d.missing.slice(0, 6).join(' ; ')}${d.missing.length > 6 ? ' …' : ''}\n`);
if (d.added.length) process.stdout.write(` ${k} 新增: ${d.added.slice(0, 6).join(' ; ')}${d.added.length > 6 ? ' …' : ''}\n`);
}
if (f.unresolved && f.unresolved.length) {
process.stdout.write(` 未解析引用(I1): ${f.unresolved.slice(0, 6).join(' ; ')}${f.unresolved.length > 6 ? ' …' : ''}\n`);
}
}
if (r.failures.length > 30) process.stdout.write(` … 另有 ${r.failures.length - 30} 个失败文档\n`);
}
process.stdout.write(`${line}\n`);
}
main().catch((e) => {
// M5:psql 等子进程失败时把其 stderr 透出来(execFileSync 把 stderr 挂在 e.stderr)
if (e && e.stderr) process.stderr.write(String(e.stderr));
process.stderr.write(`扫描崩溃: ${e && e.stack || e}\n`);
process.exit(2);
});

View File

@@ -8,6 +8,7 @@
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,