From 8fdfe688f817b80462473acd73dfd42b2eb74498 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 09:35:23 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat(modeler):=20activiti/flowable=20moddle?= =?UTF-8?q?=20=E6=8F=8F=E8=BF=B0=E7=AC=A6=20+=20=E8=AF=AD=E6=96=99?= =?UTF-8?q?=E8=A6=86=E7=9B=96/round-trip=20=E4=BF=9D=E7=9C=9F=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在线流程 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 用**全角【】**包裹对象,方括号 [] 半角,引号在属性内以 " 转义; content 尾部有 CHAR 补白空格(如 "4028...0f7d ")——均需零丢失。 - candidateUsers 表达式解析后 byte-exact 等于原文;moddle 序列化把 '/" 输出为 数字实体 '/",全角【】原样保留(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 --- package-lock.json | 626 ++++++++++++++++++ package.json | 2 + src/modeler/moddle/activiti.json | 176 +++++ src/modeler/moddle/fidelity.test.ts | 206 ++++++ .../fixtures/synthetic-full-surface.bpmn.ts | 103 +++ src/modeler/moddle/flowable.json | 90 +++ 6 files changed, 1203 insertions(+) create mode 100644 src/modeler/moddle/activiti.json create mode 100644 src/modeler/moddle/fidelity.test.ts create mode 100644 src/modeler/moddle/fixtures/synthetic-full-surface.bpmn.ts create mode 100644 src/modeler/moddle/flowable.json diff --git a/package-lock.json b/package-lock.json index 100f8ec..58189fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" @@ -386,6 +388,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 +416,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 +730,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 +1470,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 +1562,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 +2767,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 +2956,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 +3148,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 +3430,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 +4159,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 +5381,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 +7070,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 +7083,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 +7716,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 +7903,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", diff --git a/package.json b/package.json index 2d5d5ea..8239497 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/modeler/moddle/activiti.json b/src/modeler/moddle/activiti.json new file mode 100644 index 0000000..c8730f1 --- /dev/null +++ b/src/modeler/moddle/activiti.json @@ -0,0 +1,176 @@ +{ + "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": "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" } + ] + } + ] +} diff --git a/src/modeler/moddle/fidelity.test.ts b/src/modeler/moddle/fidelity.test.ts new file mode 100644 index 0000000..c5b904d --- /dev/null +++ b/src/modeler/moddle/fidelity.test.ts @@ -0,0 +1,206 @@ +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'); + // 若描述符未声明 candidateUsers,值会落进 $attrs 而 .get() 返 undefined —— 该断言同时守住 typed 化。 + expect(receive.get('activiti:candidateUsers')).toBe(EXPECTED_CANDIDATE_USERS); + }); + + 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 序列化为数字实体 '/",故断言只取到括号前) + 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 = ` + + + + +`; + + 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 = ` + + + + +`; + 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 = ` + + + + +`; + 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'); + }); +}); diff --git a/src/modeler/moddle/fixtures/synthetic-full-surface.bpmn.ts b/src/modeler/moddle/fixtures/synthetic-full-surface.bpmn.ts new file mode 100644 index 0000000..e4dbf1b --- /dev/null +++ b/src/modeler/moddle/fixtures/synthetic-full-surface.bpmn.ts @@ -0,0 +1,103 @@ +// 合成 fixture:复刻 §0 实测全扩展面 + 中文 name + 全角【】办理人 JSON。 +// +// 形态逐字对照真实流程「总包合同交底」(本地 eip4 库 5433 抽取): +// - candidateUsers / multiInstance collection 的内嵌 JSON 用**全角【】**包裹对象, +// 方括号 [] 是半角,引号在 XML 属性里以 " 转义(本文件即真实存储态)。 +// - 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 = ` + + + + + + \${nrOfCompletedInstances/nrOfInstances==1} + + + + + + + 审批完成通知 + + + + + + + + + + + PT8H + + + + + + + + + + \${isSave==true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; diff --git a/src/modeler/moddle/flowable.json b/src/modeler/moddle/flowable.json new file mode 100644 index 0000000..acbf045 --- /dev/null +++ b/src/modeler/moddle/flowable.json @@ -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" } + ] + } + ] +} From a2aeeba2967eb48088bf6f4a1a1351f5633c04c9 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 09:47:02 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix(modeler):=20T1.1=20=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E6=94=B6=E5=8F=A3=E2=80=94=E2=80=94bpmn-moddle=20=E6=98=BE?= =?UTF-8?q?=E5=BC=8FdevDep+$attrs=E6=96=AD=E8=A8=80+=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 评审 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 --- package-lock.json | 1 + package.json | 1 + src/modeler/moddle/bpmn-moddle.d.ts | 3 +++ src/modeler/moddle/fidelity.test.ts | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/modeler/moddle/bpmn-moddle.d.ts diff --git a/package-lock.json b/package-lock.json index 58189fe..529224f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,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", diff --git a/package.json b/package.json index 8239497..fbed8c6 100644 --- a/package.json +++ b/package.json @@ -34,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", diff --git a/src/modeler/moddle/bpmn-moddle.d.ts b/src/modeler/moddle/bpmn-moddle.d.ts new file mode 100644 index 0000000..b576946 --- /dev/null +++ b/src/modeler/moddle/bpmn-moddle.d.ts @@ -0,0 +1,3 @@ +// bpmn-moddle 8.x 无自带类型声明(TS7016)。最小 ambient 声明消编辑器诊断; +// 运行时行为以 fidelity.test.ts 的 round-trip 断言为准。 +declare module 'bpmn-moddle'; diff --git a/src/modeler/moddle/fidelity.test.ts b/src/modeler/moddle/fidelity.test.ts index c5b904d..23db2f5 100644 --- a/src/modeler/moddle/fidelity.test.ts +++ b/src/modeler/moddle/fidelity.test.ts @@ -63,8 +63,11 @@ describe('activiti round-trip 零丢失(合成 fixture 覆盖全扩展面)', it('candidateUsers 被识别为 typed 属性且逐字保留(全角【】+ 尾空格 + JSON 原样)', async () => { const { rootElement } = await newActiviti().fromXML(SYNTHETIC_BPMN); const receive = findById(rootElement, 't_receive'); - // 若描述符未声明 candidateUsers,值会落进 $attrs 而 .get() 返 undefined —— 该断言同时守住 typed 化。 + // 逐字保真:解析值 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 () => { From 6eb856bb758bb23bf0dcb7a4739738cb599faec4 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 09:59:54 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat(modeler):=20=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E6=B5=81=E7=A8=8B=20moddle=20round-trip=20?= =?UTF-8?q?=E4=BF=9D=E7=9C=9F=E6=89=AB=E6=8F=8F=E5=B7=A5=E5=85=B7(?= =?UTF-8?q?=E5=AE=9E=E6=B5=8B=201512/1512=20=E9=9B=B6=E4=B8=A2=E5=A4=B1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对本地 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 (formProperty value= 属性未声明,均 Activiti 自带 demo 流程,lax $attrs 保留,零丢失)。 - 解码守卫: 校验 base64→UTF8 无损,单列非 UTF8 文档。全表探明解码失败仅 出现在非 BPMN 二进制资源(.png 1504 / var-* 87524),被 name 过滤器正确排除; 真实 BPMN 语料 0 解码失败。 Co-Authored-By: Claude Fable 5 --- tools/modeler-fidelity-sweep.mjs | 292 +++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 tools/modeler-fidelity-sweep.mjs diff --git a/tools/modeler-fidelity-sweep.mjs b/tools/modeler-fidelity-sweep.mjs new file mode 100644 index 0000000..6d7853d --- /dev/null +++ b/tools/modeler-fidelity-sweep.mjs @@ -0,0 +1,292 @@ +#!/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 实体解码归一(数据级比对:"→" "→" 全角/中文原样)──────────── +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(/"/g, '"') + .replace(/'/g, "'") + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&'); // 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 ───────────────── +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; + +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/扩展) + + 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); + if (isExt) { + extElemAttrs.push(`${name}@${an}=${av}`); + } else if (/^(activiti|flowable):/.test(an)) { + extAttrs.push(`${an}=${av}`); + } + } + if (isExt) extElemTags.push(name); + } + + 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 }; +} + +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; + } + + for (const w of warnings) { + const key = normWarn(String(w && w.message || w)); + warnCounts.set(key, (warnCounts.get(key) || 0) + 1); + } + + // 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']) { + const d = diffBag(before[k], after[k]); + if (d.missing.length || d.added.length) { + diffs[k] = d; + lost = true; + } + } + if (lost) failures.push({ id: doc.id, name: doc.name, ns, diffs }); + else ok++; + } + + report({ total: docs.length, ok, failures, decodeFailures, parseErrors, warnCounts, nsCounts }); + // 硬门:真实 BPMN 全部零丢失(解码失败=非目标语料,单列不计入失败门) + process.exit(failures.length === 0 && parseErrors.length === 0 ? 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`); + const realFail = r.failures.length + r.parseErrors.length; + const realTotal = r.total - r.decodeFailures.length; + process.stdout.write(`匹配 ${r.ok}/${realTotal}(真实 BPMN,已排除 ${r.decodeFailures.length} 解码失败)\n`); + process.stdout.write(`总文档 ${r.total}|零丢失 ${r.ok}|丢失 ${r.failures.length}|解析异常 ${r.parseErrors.length}|解码失败 ${r.decodeFailures.length}\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 (r.failures.length > 30) process.stdout.write(` … 另有 ${r.failures.length - 30} 个失败文档\n`); + } + process.stdout.write(`${line}\n`); +} + +main().catch((e) => { + process.stderr.write(`扫描崩溃: ${e && e.stack || e}\n`); + process.exit(2); +}); From bd7c7fc697663e656a0c6c0580da9bf9deca6c02 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 10:02:09 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix(modeler):=20=E6=8F=8F=E8=BF=B0=E7=AC=A6?= =?UTF-8?q?=E8=A1=A5=20formProperty.value(sweep=200-warning=20=E6=94=B6?= =?UTF-8?q?=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit activiti.json formProperty 补 value isAttr(对齐 D6 完整描述符)。此前 4 例 unknown attribute 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 --- src/modeler/moddle/activiti.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modeler/moddle/activiti.json b/src/modeler/moddle/activiti.json index c8730f1..03777a3 100644 --- a/src/modeler/moddle/activiti.json +++ b/src/modeler/moddle/activiti.json @@ -139,6 +139,7 @@ { "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 } ] }, From b391ee9f169fcdfb59161db93d6ee58325bc8668 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 10:15:49 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix(modeler):=20=E4=BF=9D=E7=9C=9F=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=9B=9E=E5=BD=92=E5=8A=A0=E5=9B=BA=E2=80=94=E2=80=94?= =?UTF-8?q?refs=E8=A2=8B+unresolved=E5=85=A5=E9=97=A8+=E8=A7=84=E6=A8=A1?= =?UTF-8?q?=E9=97=A8+stderr(=E8=AF=84=E5=AE=A1I1/M1/M2/M5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- tools/modeler-fidelity-sweep.mjs | 57 +++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/tools/modeler-fidelity-sweep.mjs b/tools/modeler-fidelity-sweep.mjs index 6d7853d..8b2ffd6 100644 --- a/tools/modeler-fidelity-sweep.mjs +++ b/tools/modeler-fidelity-sweep.mjs @@ -87,6 +87,9 @@ function sanitizeIds(xml) { } // ── 命名空间嗅探: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); @@ -101,6 +104,9 @@ function sniffModdle(xml) { 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 @@ -108,6 +114,7 @@ function surface(xml) { 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; @@ -123,6 +130,7 @@ function surface(xml) { 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)) { @@ -132,13 +140,15 @@ function surface(xml) { 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 }; + return { extAttrs, extElemTags, extElemAttrs, extElemText, ids, refs }; } function bag(arr) { @@ -206,9 +216,15 @@ async function main() { continue; } + const unresolvedRefs = []; for (const w of warnings) { - const key = normWarn(String(w && w.message || w)); + 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(后) @@ -216,20 +232,31 @@ async function main() { const after = surface(out); const diffs = {}; let lost = false; - for (const k of ['extAttrs', 'extElemTags', 'extElemAttrs', 'extElemText', 'ids']) { + 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; } } - if (lost) failures.push({ id: doc.id, name: doc.name, ns, diffs }); - else ok++; + // I1②:未解析引用计入硬门(净化/往返破坏连线的直接信号,不再只当 warning) + if (lost || unresolvedRefs.length) { + failures.push({ id: doc.id, name: doc.name, ns, diffs, unresolved: unresolvedRefs }); + } else { + ok++; + } } - report({ total: docs.length, ok, failures, decodeFailures, parseErrors, warnCounts, nsCounts }); - // 硬门:真实 BPMN 全部零丢失(解码失败=非目标语料,单列不计入失败门) - process.exit(failures.length === 0 && parseErrors.length === 0 ? 0 : 1); + 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 归一:抽取属性/元素名做聚合键 @@ -246,10 +273,11 @@ function normWarn(msg) { function report(r) { const line = '─'.repeat(60); process.stdout.write(`${line}\n保真扫描结果\n${line}\n`); - const realFail = r.failures.length + r.parseErrors.length; - const realTotal = r.total - r.decodeFailures.length; - process.stdout.write(`匹配 ${r.ok}/${realTotal}(真实 BPMN,已排除 ${r.decodeFailures.length} 解码失败)\n`); - process.stdout.write(`总文档 ${r.total}|零丢失 ${r.ok}|丢失 ${r.failures.length}|解析异常 ${r.parseErrors.length}|解码失败 ${r.decodeFailures.length}\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])) { @@ -280,6 +308,9 @@ function report(r) { 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`); } @@ -287,6 +318,8 @@ function report(r) { } 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); }); From e131b8dee9995b34cfe2d16444e0a4c61dd0e891 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 10:34:47 +0800 Subject: [PATCH 6/8] =?UTF-8?q?feat(modeler):=20/process-modeler=20?= =?UTF-8?q?=E9=A1=B5=E9=AA=A8=E6=9E=B6(Modeler+=E6=A0=87=E5=87=86=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E9=9D=A2=E6=9D=BF+=E5=AD=98=E9=87=8F=E8=BD=BD?= =?UTF-8?q?=E5=85=A5+=E8=AE=BE=E8=AE=A1=E4=B8=AD=E5=BF=83=E5=85=A5?= =?UTF-8?q?=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 阶段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:」中文+冒号)。 - 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 --- src/App.tsx | 3 + src/api/processModeler.test.ts | 78 ++++++ src/api/processModeler.ts | 90 +++++++ src/modeler/bpmn-properties-panel.d.ts | 6 + src/pages/DesignCenterPage.entrances.test.tsx | 4 +- src/pages/DesignCenterPage.tsx | 8 + src/pages/ProcessModelerPage.test.tsx | 97 +++++++ src/pages/ProcessModelerPage.tsx | 253 ++++++++++++++++++ tsconfig.app.json | 1 + 9 files changed, 539 insertions(+), 1 deletion(-) create mode 100644 src/api/processModeler.test.ts create mode 100644 src/api/processModeler.ts create mode 100644 src/modeler/bpmn-properties-panel.d.ts create mode 100644 src/pages/ProcessModelerPage.test.tsx create mode 100644 src/pages/ProcessModelerPage.tsx diff --git a/src/App.tsx b/src/App.tsx index 4c4e1dc..e4272b7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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() { } /> {/* 建模器(五环第①环·元数据→表,仅管理员)*/} } /> + {/* 在线流程 Modeler(可编辑 BPMN 设计器,仅管理员)*/} + } /> {/* 根路径默认跳工作台 */} } /> diff --git a/src/api/processModeler.test.ts b/src/api/processModeler.test.ts new file mode 100644 index 0000000..8bfcabb --- /dev/null +++ b/src/api/processModeler.test.ts @@ -0,0 +1,78 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest'; + +vi.mock('./http', () => ({ http: { get: vi.fn() } })); + +import { http } from './http'; +import { fetchProcDefSource, 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: '', 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: '', idMap: { '总包合同交底': 'Proc_zbht' }, procDefKey: '总包合同交底', version: 5 }, + }); + const r = await fetchProcDefSource('PD-1'); + expect(r).toEqual({ + found: true, + bpmnXml: '', + idMap: { '总包合同交底': 'Proc_zbht' }, + procDefKey: '总包合同交底', + version: 5, + }); + }); +}); + +describe('fetchProcessOptions', () => { + it('解 amis 信封 data.options 并映射字段', async () => { + mGet.mockResolvedValue({ + data: { + status: 0, + msg: '', + data: { options: [{ label: '总包合同交底', value: '总包合同交底', id: 'PD:3:u', key: 'zbht', type: 'process' }] }, + }, + }); + const opts = await fetchProcessOptions(); + expect(opts).toEqual([{ label: '总包合同交底', value: '总包合同交底', 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([]); + }); +}); diff --git a/src/api/processModeler.ts b/src/api/processModeler.ts new file mode 100644 index 0000000..3789658 --- /dev/null +++ b/src/api/processModeler.ts @@ -0,0 +1,90 @@ +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; + /** 流程定义 key(存量多为中文,如「总包合同交底」)。 */ + procDefKey?: string; + /** 流程定义版本号。 */ + version?: number; +} + +/** + * 按 procDefId 取净化后的存量流程源 XML(含可逆 idMap)。 + * + * ⚠️ procDefId 必须编码进 path:真实库 1445 个流程的 id 形如「总包合同交底:3:」 + * (中文 + 冒号),不 encodeURIComponent 会破坏 path segment。 + * found:false 时后端省略 bpmnXml/idMap 键——先判 found 再解构,不在 false 分支碰这些键。 + */ +export async function fetchProcDefSource(procDefId: string): Promise { + const { data } = await http.get( + `/api/workflow/process-definitions/${encodeURIComponent(procDefId)}/source`, + ); + 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, + }; +} + +/** + * 存量流程选择器的一条选项。复用旧 ProcessSelectDialog 的数据源 + * `/api/process-select/options`(amis 信封 {status,data:{options}})。 + * + * - {@link id} 为 procDefId(source=processDefinition/model 时有值;history 来源为空,不可载入)。 + * - {@link value}/{@link label} 均为流程名称(沿用旧口径 value==label==流程名)。 + */ +export interface ProcessOption { + label: string; + value: string; + id?: string; + key?: string; +} + +interface ProcessSelectEnvelope { + data?: { options?: unknown[] }; + options?: unknown[]; +} + +interface RawOption { + label?: unknown; + value?: unknown; + id?: unknown; + key?: unknown; +} + +/** GET /api/process-select/options —— 取存量流程选项(解 amis 信封,防御性返回数组)。 */ +export async function fetchProcessOptions(q?: string): Promise { + const { data } = await http.get('/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, + id: opt.id != null && String(opt.id) !== '' ? String(opt.id) : undefined, + key: opt.key != null && String(opt.key) !== '' ? String(opt.key) : undefined, + }; + }); +} diff --git a/src/modeler/bpmn-properties-panel.d.ts b/src/modeler/bpmn-properties-panel.d.ts new file mode 100644 index 0000000..ed44dd0 --- /dev/null +++ b/src/modeler/bpmn-properties-panel.d.ts @@ -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; +} diff --git a/src/pages/DesignCenterPage.entrances.test.tsx b/src/pages/DesignCenterPage.entrances.test.tsx index fa5600f..3cd4ea7 100644 --- a/src/pages/DesignCenterPage.entrances.test.tsx +++ b/src/pages/DesignCenterPage.entrances.test.tsx @@ -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(); }); diff --git a/src/pages/DesignCenterPage.tsx b/src/pages/DesignCenterPage.tsx index 5ff9236..3db637d 100644 --- a/src/pages/DesignCenterPage.tsx +++ b/src/pages/DesignCenterPage.tsx @@ -73,6 +73,14 @@ export function DesignCenterPage() {
+ + + +
+ + {/* 主体:左画布 + 右栏(上=EIP4 侧板占位 / 下=标准属性面板) */} +
+
+
+ + {/* 未打开任何流程:叠加「打开存量流程」选择器 + 新建占位 */} + {!procDefId ? ( +
+
选择一个存量流程开始编辑
+ + {optionsError ? ( +
{optionsError}
+ ) : null} + +
+ ) : null} + + {/* 载入中 / 载入失败 */} + {procDefId && loadState === 'loading' ? ( +
+ 加载流程中… +
+ ) : null} + {procDefId && loadState === 'error' ? ( +
+ {loadError} +
+ ) : null} +
+ +
+ {/* EIP4 定制侧板占位(办理人/会签/formKey…由 T2.4 接入) */} +
+ EIP4 定制控件(办理人 / 会签 / formKey)将在此叠加,下阶段接入。 +
+ {/* 标准属性面板宿主(bpmn-js-properties-panel 渲染进此容器) */} +
+
+
+
+ ); +} + +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, + }; +} diff --git a/tsconfig.app.json b/tsconfig.app.json index 24ba6ff..37fdd8e 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -8,6 +8,7 @@ "moduleResolution": "bundler", "allowImportingTsExtensions": true, + "resolveJsonModule": true, "isolatedModules": true, "moduleDetection": "force", "noEmit": true, From ae097f2a9c78fbdd99d94494d143533e70f54ac1 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 2 Jul 2026 10:59:24 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix(modeler):=20=E6=89=93=E5=BC=80=E5=99=A8?= =?UTF-8?q?=E6=94=B9=20by-key=20=E8=BD=BD=E5=85=A5(=E4=BF=AE=20options=20s?= =?UTF-8?q?ource=3Dmodel=20=E8=AF=AD=E4=B9=89=E7=BC=BA=E5=8F=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=, 其余(model/history)用 ?procKey=;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 --- src/api/processModeler.test.ts | 31 ++++++++++++-- src/api/processModeler.ts | 46 +++++++++++++++----- src/pages/ProcessModelerPage.test.tsx | 40 +++++++++++++++-- src/pages/ProcessModelerPage.tsx | 62 +++++++++++++++++++-------- 4 files changed, 142 insertions(+), 37 deletions(-) diff --git a/src/api/processModeler.test.ts b/src/api/processModeler.test.ts index 8bfcabb..02d695c 100644 --- a/src/api/processModeler.test.ts +++ b/src/api/processModeler.test.ts @@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; vi.mock('./http', () => ({ http: { get: vi.fn() } })); import { http } from './http'; -import { fetchProcDefSource, fetchProcessOptions } from './processModeler'; +import { fetchProcDefSource, fetchProcDefSourceByKey, fetchProcessOptions } from './processModeler'; const mGet = vi.mocked(http.get); @@ -50,17 +50,40 @@ describe('fetchProcDefSource', () => { }); }); +describe('fetchProcDefSourceByKey', () => { + it('纯中文 key 必须 encodeURIComponent 进 by-key path', async () => { + mGet.mockResolvedValue({ + data: { found: true, bpmnXml: '', 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 并映射字段', async () => { + it('解 amis 信封 data.options 并映射 source/id/key 字段', async () => { mGet.mockResolvedValue({ data: { status: 0, msg: '', - data: { options: [{ label: '总包合同交底', value: '总包合同交底', id: 'PD:3:u', key: 'zbht', type: 'process' }] }, + data: { + options: [{ label: '总包合同交底', value: '总包合同交底', source: 'model', id: 'PD:3:u', key: 'zbht', type: 'process' }], + }, }, }); const opts = await fetchProcessOptions(); - expect(opts).toEqual([{ label: '总包合同交底', value: '总包合同交底', id: 'PD:3:u', key: 'zbht' }]); + expect(opts).toEqual([{ label: '总包合同交底', value: '总包合同交底', source: 'model', id: 'PD:3:u', key: 'zbht' }]); }); it('history 来源 id 为空时 id=undefined(前端据此过滤不可载入项)', async () => { diff --git a/src/api/processModeler.ts b/src/api/processModeler.ts index 3789658..029b4a2 100644 --- a/src/api/processModeler.ts +++ b/src/api/processModeler.ts @@ -22,16 +22,10 @@ export interface ProcDefSource { } /** - * 按 procDefId 取净化后的存量流程源 XML(含可逆 idMap)。 - * - * ⚠️ procDefId 必须编码进 path:真实库 1445 个流程的 id 形如「总包合同交底:3:」 - * (中文 + 冒号),不 encodeURIComponent 会破坏 path segment。 - * found:false 时后端省略 bpmnXml/idMap 键——先判 found 再解构,不在 false 分支碰这些键。 + * source 端点返回体归一:found:false 时后端省略 bpmnXml/idMap 键——先判 found 再解构, + * 不在 false 分支碰这些键。 */ -export async function fetchProcDefSource(procDefId: string): Promise { - const { data } = await http.get( - `/api/workflow/process-definitions/${encodeURIComponent(procDefId)}/source`, - ); +function normalizeProcDefSource(data: ProcDefSource | undefined): ProcDefSource { if (!data?.found) { return { found: false }; } @@ -44,16 +38,46 @@ export async function fetchProcDefSource(procDefId: string): Promise」 + * (中文 + 冒号),不 encodeURIComponent 会破坏 path segment。 + */ +export async function fetchProcDefSource(procDefId: string): Promise { + const { data } = await http.get( + `/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 { + const { data } = await http.get( + `/api/workflow/process-definitions/by-key/${encodeURIComponent(key)}/source`, + ); + return normalizeProcDefSource(data); +} + /** * 存量流程选择器的一条选项。复用旧 ProcessSelectDialog 的数据源 * `/api/process-select/options`(amis 信封 {status,data:{options}})。 * - * - {@link id} 为 procDefId(source=processDefinition/model 时有值;history 来源为空,不可载入)。 + * - {@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; } @@ -66,6 +90,7 @@ interface ProcessSelectEnvelope { interface RawOption { label?: unknown; value?: unknown; + source?: unknown; id?: unknown; key?: unknown; } @@ -83,6 +108,7 @@ export async function fetchProcessOptions(q?: string): Promise 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, }; diff --git a/src/pages/ProcessModelerPage.test.tsx b/src/pages/ProcessModelerPage.test.tsx index 211b3bd..4bf5869 100644 --- a/src/pages/ProcessModelerPage.test.tsx +++ b/src/pages/ProcessModelerPage.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { render, screen, waitFor } from '@testing-library/react'; +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'; @@ -25,6 +25,7 @@ vi.mock('bpmn-js-properties-panel', () => ({ })); vi.mock('../api/processModeler', () => ({ fetchProcDefSource: vi.fn(), + fetchProcDefSourceByKey: vi.fn(), fetchProcessOptions: vi.fn(), })); vi.mock('../auth/token', async (importOriginal) => ({ @@ -33,10 +34,11 @@ vi.mock('../auth/token', async (importOriginal) => ({ })); import { ProcessModelerPage } from './ProcessModelerPage'; -import { fetchProcDefSource, fetchProcessOptions } from '../api/processModeler'; +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); @@ -55,6 +57,7 @@ beforeEach(() => { 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: [] }); }); @@ -87,11 +90,40 @@ describe('ProcessModelerPage', () => { expect(importXMLMock).not.toHaveBeenCalled(); }); - it('无 procDefId 时展示「打开存量流程」选择器(数据源 process-select)', async () => { - mOptions.mockResolvedValue([{ label: '总包合同交底', value: '总包合同交底', id: 'PD-9', key: 'zbht' }]); + 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(); + }); }); diff --git a/src/pages/ProcessModelerPage.tsx b/src/pages/ProcessModelerPage.tsx index 0afb85e..7b097d7 100644 --- a/src/pages/ProcessModelerPage.tsx +++ b/src/pages/ProcessModelerPage.tsx @@ -12,7 +12,12 @@ 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, fetchProcessOptions, type ProcessOption } from '../api/processModeler'; +import { + fetchProcDefSource, + fetchProcDefSourceByKey, + fetchProcessOptions, + type ProcessOption, +} from '../api/processModeler'; // bpmn-js/lib/Modeler 自带类型,但选项对象里的标准面板模块(本项目无类型)与 moddle JSON // 会与官方选项类型产生摩擦;照 ProcessDiagram 惯例把构造器收窄为本页用到的最小契约再实例化。 @@ -31,7 +36,11 @@ export function ProcessModelerPage() { 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(null); const panelRef = useRef(null); @@ -44,9 +53,9 @@ export function ProcessModelerPage() { const [options, setOptions] = useState([]); const [optionsError, setOptionsError] = useState(''); - // 无参时拉存量流程选项(数据源复用旧 ProcessSelectDialog 端点)。 + // 未打开任何流程时拉存量流程选项(数据源复用旧 ProcessSelectDialog 端点)。 useEffect(() => { - if (!isAdmin || procDefId) return; + if (!isAdmin || hasTarget) return; let alive = true; fetchProcessOptions() .then((opts) => alive && setOptions(opts)) @@ -54,11 +63,11 @@ export function ProcessModelerPage() { return () => { alive = false; }; - }, [isAdmin, procDefId]); + }, [isAdmin, hasTarget]); - // 有 procDefId 时挂载 Modeler 并载入净化后的存量 BPMN。 + // 有目标(procDefId 或 procKey)时挂载 Modeler 并载入净化后的存量 BPMN。 useEffect(() => { - if (!isAdmin || !procDefId) return; + if (!isAdmin || !hasTarget) return; let alive = true; let modeler: ModelerLike | null = null; setLoadState('loading'); @@ -66,7 +75,10 @@ export function ProcessModelerPage() { (async () => { try { - const src = await fetchProcDefSource(procDefId); + // 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 源(可能未部署或无布局信息)'); @@ -115,17 +127,29 @@ export function ProcessModelerPage() { } modelerRef.current = null; }; - }, [isAdmin, procDefId]); + }, [isAdmin, procDefId, procKey]); if (!isAdmin) { return
流程设计器仅管理员可用。
; } - function openProcess(id: string) { - if (id) setParams({ procDefId: id }); - } + // 可载入 = 有可用打开参数:processDefinition 需 id(procDefId);其余(model/history)需 key。 + const loadableOptions = options.filter((o) => + o.source === 'processDefinition' ? !!o.id : !!o.key, + ); - const loadableOptions = options.filter((o) => !!o.id); + // 选择器按 source 分派:processDefinition→?procDefId=;其余→?procKey=。 + // 用索引取回选项对象(避免把 id/key 直接塞进