From d43ee2f37a75f561ad1cd699887acb4d9f6db640 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 10 Nov 2026 16:13:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9A=90=E7=A7=81=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=BC=96=E6=8E=92=E5=B9=B3=E5=8F=B0=EF=BC=88?= =?UTF-8?q?sswflow=20+=20=E8=AE=BE=E5=A4=87=E6=B3=A8=E5=86=8C=20+=20?= =?UTF-8?q?=E9=93=BE=E4=B8=8A=E5=AD=98=E8=AF=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从 ssw-mvp 抽取隐私计算编排域,框架换 JNPF Lite 契约 (NestJS + TypeORM + PGlite 嵌入式 Postgres + React 18/Vite), 执行底座对接 ../ssw-mpc Rust CLI。 三个兄弟模块: - sswflow(编排,12 表):DAG 画布(React Flow @xyflow/react)、 19 算子目录、可插拔执行引擎(mpc / simulation)、运行监控 - sswdevice(设备注册,1 表):真源 = ssw-mpc 控制面 GET /nodes, TeeNode 字段逐一对应,含 TTL 90s 在线清单的下线语义 - sswchain(链上存证,1 表):真源 = ssw-mpc outbox 二进制 canonical_bytes + FISCO 国密链自有 RPC,Receipt 四验证位分开报 配套 scripts/ 六个门禁脚本(期望数字写死)+ docs/e2e 端到端演示 + CLAUDE.md 项目级上下文。 --- .env.example | 6 + .gitignore | 44 + .workbuddy/memory/2026-11-10.md | 364 ++ .workbuddy/memory/MEMORY.md | 164 + CLAUDE.md | 222 + README.md | 414 ++ docs/e2e/sswflow/README.md | 74 + docs/e2e/sswflow/demo-fraud-detect.mjs | 497 ++ docs/e2e/sswflow/run.sh | 8 + run.sh | 130 + scripts/check-canvas-ports.js | 175 + scripts/check-module.sh | 280 + scripts/gen-schema.js | 120 + scripts/perm-smoke.sh | 165 + scripts/seed-demo.js | 178 + scripts/seed-infra.js | 132 + scripts/sswflow-smoke.sh | 226 + src/backend/db/schema.sql | 301 + src/backend/nest-cli.json | 6 + src/backend/package-lock.json | 5091 +++++++++++++++++ src/backend/package.json | 31 + src/backend/src/app.module.ts | 38 + src/backend/src/auth/auth.controller.ts | 49 + src/backend/src/auth/auth.module.ts | 14 + src/backend/src/auth/auth.service.ts | 54 + src/backend/src/books/book.controller.ts | 62 + src/backend/src/books/book.entity.ts | 41 + src/backend/src/books/book.service.ts | 52 + src/backend/src/books/books.module.ts | 14 + .../src/common/action-result.filter.ts | 70 + src/backend/src/common/action-result.ts | 24 + src/backend/src/common/business.exception.ts | 15 + src/backend/src/common/cipher.ts | 36 + src/backend/src/demo/demo-item.controller.ts | 49 + src/backend/src/demo/demo-item.entity.ts | 27 + src/backend/src/demo/demo-item.service.ts | 48 + src/backend/src/demo/demo.module.ts | 13 + src/backend/src/main.ts | 17 + src/backend/src/shop/product.controller.ts | 62 + src/backend/src/shop/product.entity.ts | 28 + src/backend/src/shop/product.service.ts | 48 + src/backend/src/shop/shop.module.ts | 14 + .../src/sswchain/chainblock.controller.ts | 76 + src/backend/src/sswchain/chainblock.entity.ts | 129 + .../src/sswchain/chainblock.service.ts | 298 + src/backend/src/sswchain/sswchain.module.ts | 15 + .../src/sswdevice/device.controller.ts | 76 + src/backend/src/sswdevice/device.entity.ts | 121 + src/backend/src/sswdevice/device.service.ts | 190 + src/backend/src/sswdevice/sswdevice.module.ts | 15 + .../src/sswflow/artifact.controller.ts | 49 + src/backend/src/sswflow/artifact.entity.ts | 54 + src/backend/src/sswflow/artifact.service.ts | 50 + src/backend/src/sswflow/catalog/catalog.json | 381 ++ .../src/sswflow/catalog/operator-catalog.ts | 1104 ++++ src/backend/src/sswflow/dataset.controller.ts | 49 + src/backend/src/sswflow/dataset.entity.ts | 51 + src/backend/src/sswflow/dataset.service.ts | 50 + .../src/sswflow/datasetauth.controller.ts | 49 + src/backend/src/sswflow/datasetauth.entity.ts | 42 + .../src/sswflow/datasetauth.service.ts | 50 + .../src/sswflow/datasource.controller.ts | 49 + src/backend/src/sswflow/datasource.entity.ts | 39 + src/backend/src/sswflow/datasource.service.ts | 50 + src/backend/src/sswflow/engine.controller.ts | 20 + .../src/sswflow/engine/compute-engine.ts | 69 + .../src/sswflow/engine/engine-registry.ts | 55 + src/backend/src/sswflow/engine/flow-graph.ts | 193 + src/backend/src/sswflow/engine/mpc-client.ts | 200 + src/backend/src/sswflow/engine/mpc-engine.ts | 140 + .../src/sswflow/engine/mpc-operator-map.ts | 152 + .../src/sswflow/engine/simulation-engine.ts | 95 + .../src/sswflow/engine/ssw-mpc-adapter.ts | 656 +++ src/backend/src/sswflow/flow.controller.ts | 86 + src/backend/src/sswflow/flow.entity.ts | 45 + src/backend/src/sswflow/flow.service.ts | 113 + src/backend/src/sswflow/flowrun.controller.ts | 124 + src/backend/src/sswflow/flowrun.entity.ts | 69 + src/backend/src/sswflow/flowrun.service.ts | 398 ++ .../src/sswflow/flowschedule.controller.ts | 49 + .../src/sswflow/flowschedule.entity.ts | 54 + .../src/sswflow/flowschedule.service.ts | 50 + .../src/sswflow/flowsteprun.controller.ts | 49 + src/backend/src/sswflow/flowsteprun.entity.ts | 60 + .../src/sswflow/flowsteprun.service.ts | 50 + .../src/sswflow/operator.controller.ts | 61 + src/backend/src/sswflow/party.controller.ts | 49 + src/backend/src/sswflow/party.entity.ts | 60 + src/backend/src/sswflow/party.service.ts | 50 + src/backend/src/sswflow/project.controller.ts | 49 + src/backend/src/sswflow/project.entity.ts | 39 + src/backend/src/sswflow/project.service.ts | 50 + .../src/sswflow/projectparty.controller.ts | 49 + .../src/sswflow/projectparty.entity.ts | 39 + .../src/sswflow/projectparty.service.ts | 50 + .../src/sswflow/runevent.controller.ts | 49 + src/backend/src/sswflow/runevent.entity.ts | 48 + src/backend/src/sswflow/runevent.service.ts | 50 + src/backend/src/sswflow/sswflow.module.ts | 73 + src/backend/src/sys/authorize.controller.ts | 58 + src/backend/src/sys/base-authorize.entity.ts | 42 + src/backend/src/sys/base-module.entity.ts | 57 + src/backend/src/sys/base-organize.entity.ts | 44 + .../src/sys/base-role-relation.entity.ts | 34 + src/backend/src/sys/base-role.entity.ts | 46 + .../src/sys/base-user-relation.entity.ts | 32 + src/backend/src/sys/base-user.entity.ts | 64 + src/backend/src/sys/module.controller.ts | 54 + src/backend/src/sys/organize.controller.ts | 54 + src/backend/src/sys/permission.service.ts | 117 + src/backend/src/sys/role.controller.ts | 62 + src/backend/src/sys/seed.service.ts | 199 + src/backend/src/sys/sys.module.ts | 43 + src/backend/src/sys/sys.service.ts | 300 + src/backend/src/sys/user.controller.ts | 54 + src/backend/tsconfig.build.json | 4 + src/backend/tsconfig.json | 24 + src/frontend/index.html | 12 + src/frontend/package-lock.json | 2355 ++++++++ src/frontend/package.json | 28 + src/frontend/src/App.tsx | 65 + src/frontend/src/api/artifact.ts | 8 + src/frontend/src/api/auth.ts | 19 + src/frontend/src/api/book.ts | 5 + src/frontend/src/api/chainblock.ts | 10 + src/frontend/src/api/dataset.ts | 8 + src/frontend/src/api/datasetauth.ts | 8 + src/frontend/src/api/datasource.ts | 8 + src/frontend/src/api/device.ts | 10 + src/frontend/src/api/flow.ts | 24 + src/frontend/src/api/flowrun.ts | 24 + src/frontend/src/api/flowschedule.ts | 8 + src/frontend/src/api/flowsteprun.ts | 8 + src/frontend/src/api/party.ts | 8 + src/frontend/src/api/product.ts | 7 + src/frontend/src/api/project.ts | 8 + src/frontend/src/api/projectparty.ts | 8 + src/frontend/src/api/request.ts | 72 + src/frontend/src/api/runevent.ts | 8 + src/frontend/src/api/sys.ts | 36 + src/frontend/src/components/CrudPage.tsx | 206 + src/frontend/src/components/SswNode.tsx | 165 + src/frontend/src/components/sswNode.css | 31 + src/frontend/src/main.tsx | 12 + src/frontend/src/utils/cipher.ts | 26 + src/frontend/src/utils/flowTransform.ts | 203 + src/frontend/src/views/Artifact.tsx | 16 + src/frontend/src/views/Book.tsx | 155 + src/frontend/src/views/ChainBlock.tsx | 96 + src/frontend/src/views/Dashboard.tsx | 64 + src/frontend/src/views/Dataset.tsx | 16 + src/frontend/src/views/DatasetAuth.tsx | 16 + src/frontend/src/views/Datasource.tsx | 16 + src/frontend/src/views/DemoItem.tsx | 101 + src/frontend/src/views/Device.tsx | 89 + src/frontend/src/views/Flow.tsx | 493 ++ src/frontend/src/views/FlowRun.tsx | 176 + src/frontend/src/views/FlowSchedule.tsx | 16 + src/frontend/src/views/FlowStepRun.tsx | 16 + src/frontend/src/views/Login.tsx | 81 + src/frontend/src/views/MenuManage.tsx | 155 + src/frontend/src/views/OrganizeManage.tsx | 112 + src/frontend/src/views/Party.tsx | 16 + src/frontend/src/views/Product.tsx | 93 + src/frontend/src/views/Project.tsx | 16 + src/frontend/src/views/ProjectParty.tsx | 16 + src/frontend/src/views/RoleManage.tsx | 153 + src/frontend/src/views/RunEvent.tsx | 16 + src/frontend/src/views/UserManage.tsx | 148 + src/frontend/src/views/ui.ts | 46 + src/frontend/tsconfig.json | 20 + src/frontend/vite.config.ts | 15 + 172 files changed, 22668 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 .workbuddy/memory/2026-11-10.md create mode 100644 .workbuddy/memory/MEMORY.md create mode 100644 CLAUDE.md create mode 100644 README.md create mode 100644 docs/e2e/sswflow/README.md create mode 100755 docs/e2e/sswflow/demo-fraud-detect.mjs create mode 100755 docs/e2e/sswflow/run.sh create mode 100755 run.sh create mode 100644 scripts/check-canvas-ports.js create mode 100755 scripts/check-module.sh create mode 100644 scripts/gen-schema.js create mode 100755 scripts/perm-smoke.sh create mode 100644 scripts/seed-demo.js create mode 100644 scripts/seed-infra.js create mode 100644 scripts/sswflow-smoke.sh create mode 100644 src/backend/db/schema.sql create mode 100644 src/backend/nest-cli.json create mode 100644 src/backend/package-lock.json create mode 100644 src/backend/package.json create mode 100644 src/backend/src/app.module.ts create mode 100644 src/backend/src/auth/auth.controller.ts create mode 100644 src/backend/src/auth/auth.module.ts create mode 100644 src/backend/src/auth/auth.service.ts create mode 100644 src/backend/src/books/book.controller.ts create mode 100644 src/backend/src/books/book.entity.ts create mode 100644 src/backend/src/books/book.service.ts create mode 100644 src/backend/src/books/books.module.ts create mode 100644 src/backend/src/common/action-result.filter.ts create mode 100644 src/backend/src/common/action-result.ts create mode 100644 src/backend/src/common/business.exception.ts create mode 100644 src/backend/src/common/cipher.ts create mode 100644 src/backend/src/demo/demo-item.controller.ts create mode 100644 src/backend/src/demo/demo-item.entity.ts create mode 100644 src/backend/src/demo/demo-item.service.ts create mode 100644 src/backend/src/demo/demo.module.ts create mode 100644 src/backend/src/main.ts create mode 100644 src/backend/src/shop/product.controller.ts create mode 100644 src/backend/src/shop/product.entity.ts create mode 100644 src/backend/src/shop/product.service.ts create mode 100644 src/backend/src/shop/shop.module.ts create mode 100644 src/backend/src/sswchain/chainblock.controller.ts create mode 100644 src/backend/src/sswchain/chainblock.entity.ts create mode 100644 src/backend/src/sswchain/chainblock.service.ts create mode 100644 src/backend/src/sswchain/sswchain.module.ts create mode 100644 src/backend/src/sswdevice/device.controller.ts create mode 100644 src/backend/src/sswdevice/device.entity.ts create mode 100644 src/backend/src/sswdevice/device.service.ts create mode 100644 src/backend/src/sswdevice/sswdevice.module.ts create mode 100644 src/backend/src/sswflow/artifact.controller.ts create mode 100644 src/backend/src/sswflow/artifact.entity.ts create mode 100644 src/backend/src/sswflow/artifact.service.ts create mode 100644 src/backend/src/sswflow/catalog/catalog.json create mode 100644 src/backend/src/sswflow/catalog/operator-catalog.ts create mode 100644 src/backend/src/sswflow/dataset.controller.ts create mode 100644 src/backend/src/sswflow/dataset.entity.ts create mode 100644 src/backend/src/sswflow/dataset.service.ts create mode 100644 src/backend/src/sswflow/datasetauth.controller.ts create mode 100644 src/backend/src/sswflow/datasetauth.entity.ts create mode 100644 src/backend/src/sswflow/datasetauth.service.ts create mode 100644 src/backend/src/sswflow/datasource.controller.ts create mode 100644 src/backend/src/sswflow/datasource.entity.ts create mode 100644 src/backend/src/sswflow/datasource.service.ts create mode 100644 src/backend/src/sswflow/engine.controller.ts create mode 100644 src/backend/src/sswflow/engine/compute-engine.ts create mode 100644 src/backend/src/sswflow/engine/engine-registry.ts create mode 100644 src/backend/src/sswflow/engine/flow-graph.ts create mode 100644 src/backend/src/sswflow/engine/mpc-client.ts create mode 100644 src/backend/src/sswflow/engine/mpc-engine.ts create mode 100644 src/backend/src/sswflow/engine/mpc-operator-map.ts create mode 100644 src/backend/src/sswflow/engine/simulation-engine.ts create mode 100644 src/backend/src/sswflow/engine/ssw-mpc-adapter.ts create mode 100644 src/backend/src/sswflow/flow.controller.ts create mode 100644 src/backend/src/sswflow/flow.entity.ts create mode 100644 src/backend/src/sswflow/flow.service.ts create mode 100644 src/backend/src/sswflow/flowrun.controller.ts create mode 100644 src/backend/src/sswflow/flowrun.entity.ts create mode 100644 src/backend/src/sswflow/flowrun.service.ts create mode 100644 src/backend/src/sswflow/flowschedule.controller.ts create mode 100644 src/backend/src/sswflow/flowschedule.entity.ts create mode 100644 src/backend/src/sswflow/flowschedule.service.ts create mode 100644 src/backend/src/sswflow/flowsteprun.controller.ts create mode 100644 src/backend/src/sswflow/flowsteprun.entity.ts create mode 100644 src/backend/src/sswflow/flowsteprun.service.ts create mode 100644 src/backend/src/sswflow/operator.controller.ts create mode 100644 src/backend/src/sswflow/party.controller.ts create mode 100644 src/backend/src/sswflow/party.entity.ts create mode 100644 src/backend/src/sswflow/party.service.ts create mode 100644 src/backend/src/sswflow/project.controller.ts create mode 100644 src/backend/src/sswflow/project.entity.ts create mode 100644 src/backend/src/sswflow/project.service.ts create mode 100644 src/backend/src/sswflow/projectparty.controller.ts create mode 100644 src/backend/src/sswflow/projectparty.entity.ts create mode 100644 src/backend/src/sswflow/projectparty.service.ts create mode 100644 src/backend/src/sswflow/runevent.controller.ts create mode 100644 src/backend/src/sswflow/runevent.entity.ts create mode 100644 src/backend/src/sswflow/runevent.service.ts create mode 100644 src/backend/src/sswflow/sswflow.module.ts create mode 100644 src/backend/src/sys/authorize.controller.ts create mode 100644 src/backend/src/sys/base-authorize.entity.ts create mode 100644 src/backend/src/sys/base-module.entity.ts create mode 100644 src/backend/src/sys/base-organize.entity.ts create mode 100644 src/backend/src/sys/base-role-relation.entity.ts create mode 100644 src/backend/src/sys/base-role.entity.ts create mode 100644 src/backend/src/sys/base-user-relation.entity.ts create mode 100644 src/backend/src/sys/base-user.entity.ts create mode 100644 src/backend/src/sys/module.controller.ts create mode 100644 src/backend/src/sys/organize.controller.ts create mode 100644 src/backend/src/sys/permission.service.ts create mode 100644 src/backend/src/sys/role.controller.ts create mode 100644 src/backend/src/sys/seed.service.ts create mode 100644 src/backend/src/sys/sys.module.ts create mode 100644 src/backend/src/sys/sys.service.ts create mode 100644 src/backend/src/sys/user.controller.ts create mode 100644 src/backend/tsconfig.build.json create mode 100644 src/backend/tsconfig.json create mode 100644 src/frontend/index.html create mode 100644 src/frontend/package-lock.json create mode 100644 src/frontend/package.json create mode 100644 src/frontend/src/App.tsx create mode 100644 src/frontend/src/api/artifact.ts create mode 100644 src/frontend/src/api/auth.ts create mode 100644 src/frontend/src/api/book.ts create mode 100644 src/frontend/src/api/chainblock.ts create mode 100644 src/frontend/src/api/dataset.ts create mode 100644 src/frontend/src/api/datasetauth.ts create mode 100644 src/frontend/src/api/datasource.ts create mode 100644 src/frontend/src/api/device.ts create mode 100644 src/frontend/src/api/flow.ts create mode 100644 src/frontend/src/api/flowrun.ts create mode 100644 src/frontend/src/api/flowschedule.ts create mode 100644 src/frontend/src/api/flowsteprun.ts create mode 100644 src/frontend/src/api/party.ts create mode 100644 src/frontend/src/api/product.ts create mode 100644 src/frontend/src/api/project.ts create mode 100644 src/frontend/src/api/projectparty.ts create mode 100644 src/frontend/src/api/request.ts create mode 100644 src/frontend/src/api/runevent.ts create mode 100644 src/frontend/src/api/sys.ts create mode 100644 src/frontend/src/components/CrudPage.tsx create mode 100644 src/frontend/src/components/SswNode.tsx create mode 100644 src/frontend/src/components/sswNode.css create mode 100644 src/frontend/src/main.tsx create mode 100644 src/frontend/src/utils/cipher.ts create mode 100644 src/frontend/src/utils/flowTransform.ts create mode 100644 src/frontend/src/views/Artifact.tsx create mode 100644 src/frontend/src/views/Book.tsx create mode 100644 src/frontend/src/views/ChainBlock.tsx create mode 100644 src/frontend/src/views/Dashboard.tsx create mode 100644 src/frontend/src/views/Dataset.tsx create mode 100644 src/frontend/src/views/DatasetAuth.tsx create mode 100644 src/frontend/src/views/Datasource.tsx create mode 100644 src/frontend/src/views/DemoItem.tsx create mode 100644 src/frontend/src/views/Device.tsx create mode 100644 src/frontend/src/views/Flow.tsx create mode 100644 src/frontend/src/views/FlowRun.tsx create mode 100644 src/frontend/src/views/FlowSchedule.tsx create mode 100644 src/frontend/src/views/FlowStepRun.tsx create mode 100644 src/frontend/src/views/Login.tsx create mode 100644 src/frontend/src/views/MenuManage.tsx create mode 100644 src/frontend/src/views/OrganizeManage.tsx create mode 100644 src/frontend/src/views/Party.tsx create mode 100644 src/frontend/src/views/Product.tsx create mode 100644 src/frontend/src/views/Project.tsx create mode 100644 src/frontend/src/views/ProjectParty.tsx create mode 100644 src/frontend/src/views/RoleManage.tsx create mode 100644 src/frontend/src/views/RunEvent.tsx create mode 100644 src/frontend/src/views/UserManage.tsx create mode 100644 src/frontend/src/views/ui.ts create mode 100644 src/frontend/tsconfig.json create mode 100644 src/frontend/vite.config.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..79f5109 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# 复制为 .env 后按需修改(MVP 默认嵌入式 PGlite,无需本地 Postgres) +# 嵌入式数据库:留空 = 纯内存(重启清空,适合原型);如需持久化设成本地目录 +PGLLITE_DIR=memory:// +# 迁 JNPF 前关掉自动建表:PG_SYNC=false +PG_SYNC=true +PORT=30000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1508e03 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +node_modules/ +dist/ +.env +*.log +.DS_Store +# 嵌入式 PGlite 持久化目录(设 PGLLITE_DIR=./.pglite 时生成) +.pglite/ +.data/ +# run.sh dev 把 nest + vite 后台进程的 stdout/PID 写到这里 +.logs/ + +# Maven / Gradle 构建产物(template-boot-jnpf/ 等 Java 子项目) +**/target/ + +# 构建临时文件(vite 异常退出时残留) +*.timestamp-*.mjs +*.tmp + +# ---- ssw-mpc-flow 专属 ---- + +# 链上存证模块的 outbox(chain outbox):运行状态,随真实提交变化。 +# 它是「链上存证」真源的输入之一,但不是代码 —— 由本地 ssw-mpc 产生。 +src/backend/.mpc-state/ + +# e2e 演示的运行产物(bash docs/e2e/sswflow/run.sh 可重新生成) +docs/e2e/sswflow/results/ + +# 私钥 / 证书 / 密钥文件:本地素材一律不入库。 +# ssw-mpc 的 SM2 私钥在仓库外(如 /tmp/mpc-chain-real/key.pem)。 +*.pem +*.key +*.p12 +*.pfx +*.jks +*.keystore + +# 本地环境覆盖(.env.example 入库) +.env.local +.env.*.local + +# 编辑器 / 系统 +.idea/ +.vscode/ +*.swp diff --git a/.workbuddy/memory/2026-11-10.md b/.workbuddy/memory/2026-11-10.md new file mode 100644 index 0000000..b525854 --- /dev/null +++ b/.workbuddy/memory/2026-11-10.md @@ -0,0 +1,364 @@ +# 2026-11-10 + +## ssw-mpc-flow 项目:从 ssw-mvp 抽取隐私计算编排域,框架换 JNPF Lite + +**项目路径**:`/Users/xs/Desktop/workspace/ssw-mpc-flow` +**来源**:`../ssw-mvp` 的 sswflow 域;**执行底座**:`../ssw-mpc`(Rust) +**框架**:NestJS + TypeORM + PGlite(嵌入式 Postgres WASM) + React 18/Vite + +### 技术决策(已落盘,勿推翻) + +- **架构**:NestJS + TypeORM + PostgreSQL + React/Vite,沿用 JNPF Lite 契约 + (`f_` 前缀列、`f_id varchar(50)` UUID、软删 `f_delete_mark`、`ActionResult` 返回)。 +- **数据库用 PGlite**(`@electric-sql/pglite` + `typeorm-pglite`):WASM Postgres, + 零服务进程零 docker,但保留真 Postgres 方言 → `f_` 列契约完全成立。 + `PGLLITE_DIR=./.pglite` 可持久化;`PG_SYNC=false` 切到显式建表。 +- **12 张业务表**(`sswflow_*`)+ `demo_item` = 13 张,`db/schema.sql` 由 + `scripts/gen-schema.js` 从实体自动生成(防漂移),已接入 `run.sh build`。 +- **不修改 ssw-mpc Rust 源码**。原因已查证: + - `mpc-ir` 的 21 个 `Op` 是内部 IR,**无 JSON/serde**,NestJS 不能直接提交; + - `mpc hostd` 只管 TEE sandbox,不是 DAG 提交口; + - `mpc-demo` HTTP 仅单算子参考,非生产协议。 + - 适配层 = 固定 CLI argv + `mpc orch run --plan` 文本计划 + 内置 simulation。 +- **算子 19 个**(`catalog.json` 唯一事实源),7 分类。`sink.export` 是唯一 terminal。 + MPC 能力分布:native 4 / partial 7 / local 7 / unsupported 1(`model.gbdt.train`)。 +- **DAG 契约**(前后端一致,勿改): + `steps[{stepId,operatorKey,label,x,y,params}]` / + `edges[{edgeId,sourceStepId,sourcePort,targetStepId,targetPort}]` +- **6 种运行范围**:FULL / SINGLE / SELECTED / UPSTREAM / DOWNSTREAM / RESUME。 +- **裁掉**:TDS/TDC 胶水、跨方 HTTP 转发、SSE(改轮询 Events)、审批待办、NAX 执行层。 +- **保留**:DAG 契约、运行状态机、端口级连线语义、`ComputeEngine` SPI。 + +### 本次修掉的真实缺陷 + +1. **后端 4 处 TS 报错**:`repo.create({...} as any)` 命中 TypeORM 的**数组重载**, + TS 报 TS2352。运行时无 bug(TypeORM 用 `Array.isArray` 分支),但加 + `as unknown as X` 打断歧义链。 +2. **`FlowRunService.save()` 真 bug**:`Object.assign(await this.get(id), item)` + 丢弃查询结果,且软删行 `get()` 返回 null 会抛错 → 改为直接 `findOne({where:{id}})`, + 查不到则新建。 +3. **前端边 id 缺陷**:`edgeId: \`...-Date.now()\`` 写成了**字面量文本**而非函数调用, + 同对节点同端口的平行边撞 id(React key 冲突 + 误删多条)→ 改 `Date.now().toString(36)`; + `openFlow` 的回退 id 也补了下标避免重复。 +4. **画布端口选择缺陷(产品级)**:`addEdge` 固定取 `outputs[0]`/`inputs[0]`, + 导致 `prep.intersect` 的 `right` 端口、`model.predict` 的 `model` 端口**永远连不上**, + 校验器随后报「输入端口未连线」→ 改为源/目标端口显式可选(端口数 >1 时出下拉)。 + +### 验证状态(全绿) + +| 检查 | 结果 | +|---|---| +| 后端 `tsc --noEmit` | 通过 | +| 后端 `nest build` | 通过 | +| 前端 `tsc --noEmit` / `vite build` | 通过 | +| `check-module.sh sswflow <12实体>` | PASS=219 FAIL=0 | +| `perm-smoke.sh` | PASS=32 FAIL=0 | +| `scripts/sswflow-smoke.sh`(本次新增) | PASS=46 FAIL=0 | +| 浏览器实测 | 登录→菜单→画布→加节点→选端口→连线→落库 全链路通 | + +`sswflow-smoke.sh` 覆盖:算子目录 19/能力分布、流程 CRUD、画布校验(合法/缺参数/缺端口/有环)、 +plan 编译、异步运行收敛、步骤/事件/产物、6 种运行范围语义、软删。 + +### 环境坑(重要) + +- **`nest start` 会被安全删除钩子拦截**(它要清 dist)→ 用 `node dist/main.js` 起后端。 +- **`./run.sh dev` 的 nohup 后台进程在工具 shell 里会被回收** → 用工具原生 + `run_in_background=true` 起 `node dist/main.js` 和 `npx vite`。 +- **`aix` 软链断链**:`/usr/local/bin/aix` → `agentx/target/release/agentx` 已不存在。 + 改用全局 `agent-browser`(在 `/Users/xs/.npm-global/bin/`)。 +- **agent-browser 的 `click @ref` 在 React 重渲染后 ref 会失效** → 改用 + `eval` 里 `element.click()` + 手动 dispatch `change` 事件(原生 select 需用 + `HTMLSelectElement.prototype` 的 value setter,React 才认)。 +- **macOS 的 grep 不支持 `-P`** → 用 `sed -n "s/.../\1/p"` 或 Grep 工具。 +- **`npm bin -g` 在 npm 9+ 已移除** → 用 `npm root -g`。 + +### 下一步 + +- 接真实 ssw-mpc:`MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` + 起各方 `mpc agent`, + 验证 native 4 个算子(PSI / SCQL / LR / FedAvg)真跑。 +- `FlowSchedule` 周期调度目前只有表和 CRUD,**调度器未实现**(到点不自动起 run)。 +- 迁 JNPF:`db/schema.sql` 已就绪,关 `synchronize` 直接复用; + `base_module` 14 条菜单已在 `sys/seed.service.ts` 内置。 + +--- + +## 画布组件:手写 SVG → React Flow(`@xyflow/react` 12.12.1) + +**背景**:用户指出「React 没有 VueFlow 等价物」的论断是错的 —— VueFlow 与 React Flow +同属 xyflow 家族,API 几乎一一对应。故把 `Flow.tsx` 的手写 SVG 画布**完整替换为 React Flow**。 + +**改动文件**: +- `src/frontend/src/views/Flow.tsx`:删除全部手写 SVG(view/pan/wheel/``/ + ``/transform 层/缩放工具条),改用 `` 受控模式 + (`onNodesChange`/`onEdgesChange` 走 `applyNodeChanges`/`applyEdgeChanges`); + 外层包 ``,内层 `useReactFlow()` 拿 `fitView`。 +- `src/frontend/src/components/SswNode.tsx`(新增):React Flow 自定义节点,按算子 + ports **动态渲染 N 个 Handle**(`Handle id={port.key}`),多端口算子每个端口独立可连。 +- `src/frontend/src/components/sswNode.css`(新增):动画 keyframes + Handle 热区(内联 style 无法定义 keyframes)。 +- `src/frontend/src/utils/flowTransform.ts`(新增):移植自 ssw-mvp 的 VueFlow 转换层, + `toBackendSteps`/`toBackendEdges`,`sourceHandle`/`targetHandle` 直接存端口 key。 +- `src/frontend/package.json`:加 `@xyflow/react ^12.12.1`。 +- `README.md`:修正「React 无 VueFlow 等价物」错误论断,改为 VueFlow→React Flow 平移 + + API 对照表;迁移对照表「画布组件」行同步。 + +**关键坑**:本地函数 `addEdge`(属性面板「添加连线」)遮蔽了从 `@xyflow/react` 导入的 +`addEdge` → 导入改别名 `addEdge as addFlowEdge`。 + +**验证(本次全绿)**: +| 检查 | 结果 | +|---|---| +| 前端 `tsc --noEmit` / `vite build` | 通过(230kB gzip 176kB) | +| 后端 `tsc --noEmit` | 通过 | +| `check-module.sh sswflow <12实体>` | 219/0 | +| `perm-smoke.sh` | 32/0 | +| `sswflow-smoke.sh` | 46/0 | +| `scripts/check-canvas-ports.js`(新增) | 从后端读回 f_steps/f_edges,断言多端口边 sourcePort/targetPort 命中 catalog;6 条多端口边全中(left/right/train/test) | +| 浏览器实测 | 多端口 Handle 渲染正确(left/right/train/test);属性面板连线列表区分入/出方向与端口名;校验抓出真实缺参/缺端口;▶运行 → 7 步骤全 SUCCESS | + +**服务端口记**:后端实际监听 **30000**(不是 3000);前端 dev `http://127.0.0.1:5173`。 +`check-canvas-ports.js` / `sswflow-smoke.sh` 登录契约:`x-www-form-urlencoded` 的 +`account` + **AES-ECB 密文密码**(`encryptPassword('123456')`) + `grant_type=password`, +token 在 `data.token`。 + +## 端到端演示脚本(参考 ssw-mvp/docs/e2e/sswflow) + +新增 `docs/e2e/sswflow/` 自包含演示,照搬 ssw-mvp `demo-risk-control.mjs` 的思路但**不依赖其 `../lib` 底座**: +- `demo-fraud-detect.mjs`:联合反欺诈纵向联邦场景(电商特征方 × 银行标签方 → PSI 求交 → split → LR → 评估 → 出域)。 + 内联登录加密(用 `src/backend/node_modules/crypto-js`,与前端 `cipher.ts` 逐字节一致)、API 客户端、服务探针(net.connect + 按需 spawn 后端/前端)、场景装置(按 code 幂等复用)、运行轮询、指标提取、HTML/JSON 报告、`--ui` 模式(agent-browser 真实点击「▶ 运行」并截图)。 +- `run.sh` 启动器 + `README.md`。 +- **事实标注**:本环境默认 `simulation` 引擎,指标是确定性占位(AUC=0.8731/KS=0.421/训练1600·测试400),报告与开头都显式标「simulation 模拟」;设 `MPC_DRIVER=mpc` 才走真实 ssw-mpc,脚本自动识别并标注。 +- 已实测:无头 + `--ui` 两条链路均 PASS,产出 `results/fraud-detect-*.{json,html}` 与 `results/shots/ui-run.png`。 +- 注意 `Dataset` 控制器**无 `Authorized` 端点**(只有 List/Save/Delete),授权计数改用 `DatasetAuth/List` 过滤。 + +## 新增两个兄弟模块:设备注册 + 区块链浏览器 + +用户要求把「设备注册」「区块链浏览器」做起来。**先查清 ssw-mvp 的真实落点**(重要): +这两个不是 sswflow 域的模块,而是散在三个子项目里、**三种语言**: +- `nax/nax/device/`(Python):offline/plain/secret/site/vault 五类设备登记 +- `scard/code/connector/register/`(Go):registrar.go 设备注册连接器 +- `boot/ssw-tds/.../tds/chain/`(Java):FISCO 联盟链存证 FiscoChainClient/ChainReceipt/ChainEvidenceTicker + +→ 结论:**没有现成 TS 版可搬**,只能在 ssw-mpc-flow 里按 JNPF-Lite 契约新建。 +用户选择:融入 ssw-mpc-flow(新建 TS)+ 两个一起做,本轮搭骨架。 + +### 落地结构(兄弟模块,与 shop/books 同级,不是 sswflow 子域) +- `src/backend/src/sswdevice/`:device.entity/service/controller + sswdevice.module(表 `sswdevice_device`,14 列) +- `src/backend/src/sswchain/`:chainblock.entity/service/controller + sswchain.module(表 `sswchain_chain_block`,14 列) +- 前端:`api/device.ts` `api/chainblock.ts` + `views/Device.tsx` `views/ChainBlock.tsx`(通用 CrudPage 薄包装) +- `CrudPage.tsx` 新增可选 `apiBase` prop(默认 sswflow),修正副标题路径;原调用方零改动 +- seed 新增目录菜单「数据基础设施」(m_infra) + 2 子页;`ensureBase` 幂等回灌并自动给 admin 授权 +- 新增 `scripts/seed-infra.js`(幂等灌 3 设备 + 3 区块,含 `--list`) + +### 踩坑 +- **`nest build` 会被安全删除钩子拦**(它要先批量清空 dist,254 文件 > 50 阈值)→ 改用 + `npx tsc -p tsconfig.json` 直接发射到 dist(增量覆盖,不批量删目录),**绕过钩子且成功**。 + 这比 `nest start` 更省事(后者同样触发清 dist)。 +- `gen-schema.js` 的 `ENTITY_DIR` 原本**硬编码 sswflow 子目录**,新模块在别处 → 改成递归 walk + 整个 `src/backend/src`,schema.sql 表数 13 → 15(另含 book_shop_book / demo_item / shop_product,实测输出 18 行)。 + +### 验证(全绿) +| 检查 | 结果 | +|---|---| +| `check-module.sh sswdevice Device` | 21/0 | +| `check-module.sh sswchain ChainBlock` | 21/0 | +| `perm-smoke.sh` | 32/0(菜单树断言动态纳入新菜单) | +| `sswflow-smoke.sh` | 46/0 | +| 前后端 tsc / 前端 build | 通过(gzip 176.59 kB) | +| 实跑 API | Device/ChainBlock List/Save/Delete + 软删 + 600 拦截 + 菜单树「数据基础设施:设备注册,区块链浏览器」 | +| 浏览器实测 | 两页渲染正常;新增表单真实落库;区块按高度倒序、时间格式化正确 | + +**诚实标注**:设备注册无真实注册流程(无 mTLS/agent 上报);区块链浏览器未接任何真实链节点 +(FISCO 链客户端未移植),区块数据来自 seed 脚本。README 已写明「当前为骨架」。 + +--- + +## 第二轮:两个模块改成真接口对接(ssw-mpc 实际脚本/文档口径) + +用户明确要求:「ssw-mpc 有跑通的脚本及文档,你按实际脚本和文档来优化」+ 授权去 k8s +与三台真机实测。方向从「自造字段 + 自造数据」纠到「严格对接真实契约」。 + +### 真源判定(两个模块各一个) +| 模块 | 真源 | 入口 | +|---|---|---| +| 设备注册 | ssw-mpc **control-plane** 的节点注册表 | `GET {url}/nodes`(另有 /sessions /report) | +| 链上存证 | ssw-mpc **outbox** + FISCO 国密链 | `mpc chain status --outbox` + FISCO 自有 RPC | + +### TeeNode 真实字段(22 列,纠正旧的自造字段) +`key`(=site@host) / `site` / `host` / `platform.kind` / `platform.tcb` / `capacity` / +`last_seen` / `device_present` / `qemu_present` / `firmware_present` / `image_present` / +`kbs_reachable` / `kbc` / `measurement[32]` / `kbs_endpoint`(**只能从 descriptor 解析**, +`node_to_json` 没这字段)/ `descriptor`。 +★ `platform` 取值 = `sev-snp` / `hygon-csv`;`kbc` = `cc_kbc` / `offline_fs_kbc::null` +(**不是** online/offline);`tcb` 是整数(AMD SNP=5,海光 CSV2=3)。 +旧字段(device_code/name/party_id/device_type/endpoint/cert_fingerprint/status/reg_time/ +last_heartbeat_time/desc)**全部删除**。 + +### 控制面鉴权(crates/mpc-hostd/src/auth.rs) +- 配了密钥 ⇒ 必须 `Authorization: Bearer <明文原文>`(≥32B ASCII、不含空白)。 + 服务端只存 SHA-256 摘要,`ct_eq` 常量时间比对。 +- 没配密钥 ⇒ 不带凭据放行,**带了任何凭据一律拒**。 +- ★ token 必须是**原文**,不能用 hex(曾用 `hex_encode(secret)` ⇒ 全 401)。 +- 对外统一一句「缺少或无效的凭据」,不区分 missing/malformed/mismatch。 +- 实测:不带凭据 401 / 错凭据 401 / 正确原文 200。 + +### Receipt 二进制布局(crates/mpc-chain/src/objects.rs)—— 本轮新写的逆解器 +``` +"mpc/tee/chain/object/v1" 固定 25B,无长度前缀 ← 我第一版误当有长度前缀,踩了 +push_field("receipt") 4B 大端长度前缀 + "receipt" +"v1" 固定 2B +push_field(order_id) / push_field(decision_id) 变长 +result_hash[32] / input_hash[32] / user_data[64] +attest: 4×u8(user_data_ok/meas_ok/tcb_ok/chip_sig) +push_field(link) / link_binding[32] +(signatures 故意不写 —— 签名是产物不是被签内容) +``` +outbox 行格式 `v1|key|state|attempts|payload_hex|last_error_hex`(6 段缺一 ⇒ 整表拒绝)。 +幂等键 = `kind:order_id:decision_id`;`state` P/C,**C 只代表已广播,不代表已出块**。 + +### FISCO 国密链真相源(rpc.rs) +- 成功判据**三件套**:`status==0`(TransactionStatus::None=成功,**与 web3 的 0x1 相反**) + + `transactionHash` 非空(FISCO 自有字段名,不是 txHash)+ `blockNumber>0`。 +- 自有端点(不是 web3):`getTransactionReceipt` 4 参 `[group,node,txHash,requireProof]` / + `call` 4 参 `[group,node,to,data]`(第 5 参是**签名**不是 "latest")/ + `sendTransaction` 4 参 / `getBlockNumber` ★ **只接受 0 参**。 +- 真链对 `eth_getTransactionReceipt`/`eth_call` 回 `-32601`。 +- HTTP 200 ≠ 成功(错误在 body.error);`result:null` = 还没出块(不是错误)。 +- selector 是二元数组 `[keccak_u32, sm3_u32]`,国密链用 **SM3(signature)[0..4]**: + `recordHardRule`=4461f95a / `isRecorded`=a3414302 / `hardRuleSummary`=73a3d38c。 + +### ★ 本轮实测挖到的真边界 +- **`recordHardRule` 的 orderId 长度必须 ≤ 16 字节**:15/16 通过,17/20/29 全 + `status=16` revert 且 output 空。根因是 FISCO solidity 编译器对 `bytes.concat` 的长度限制。 +- **`chain contract deploy --bin` 参数被忽略**:实际读 `--abi` 文件,且要求 combined.json + 或 `{abi,bin}` 形状,裸 `.bin` 文件不认(报「solc 产物缺 bin」)。 +- `--arg` 必须是 `TYPE:VALUE` 形式(`bytes:0x…` / `bytes32:0x…`),类型要与 ABI 声明一致; + 写接口还要 `--key `(仓库外 `/tmp/mpc-chain-real/key.pem`)+ `--node node0`。 +- Receipt JSON 的 hex 字段**不许带 0x**(from_hex 直接拒);`--arg` 命令行才允许带。 +- FISCO 合约部署需 `EVM_ABI_CODEC(0x1)` attribute(写调用 attribute=0)。 +- 真实链私钥**不入库**,通过 `MPC_FISCO_KEY` 注入。 + +### 三台真机实测 +- **海光 192.168.1.102**(arm64):hostd `0.0.0.0:3010` + control-plane `0.0.0.0:3020` 都在跑; + 共享密钥 `/tmp/mpc-cluster/cluster.secret`(64B ASCII, 0600)。**真控制面数据源**。 +- **Zynq 192.168.1.233**:armv7l,`/usr/local/bin/mpc` 存在,跑着 `mpc-sa tee sa-serve :9300`; + 无 3010/3020。 +- **AMD 192.168.1.7**:ssh 22 端口 OPEN 但**握手被 reset**,**未取得 SSH 会话**。 + 最后一次用 `ssh -vvv` 精确定位:TCP 建立 → 客户端发出 `SSH-2.0-OpenSSH_10.3` + → **服务端在发自己 banner 前就 RST** ⇒ 服务端侧行为(sshd 未就绪 / MaxStartups 限流 / + 前置防护),客户端无解。 + ★ 端口扫描必须 **`--noproxy '*'` 或 `NO_PROXY=*`** —— 本机代理会把 `nc -z` 的 + 「succeeded」报成假阳性(3010/3020 实际 Connection refused,只有 22 真活)。 + 但控制面已收到它的自报(alice@192.168.1.7),数据侧不缺。 +- 注册表真实内容(2 节点): + `bob@192.168.1.102 | hygon-csv | tcb=3 | kbc=cc_kbc | kbs=可达`、 + `alice@192.168.1.7 | sev-snp | tcb=5 | kbc=cc_kbc | kbs=可达`。 + +### k8s(ns wuguirong) +`fisco-chain-f89888898-pd8lb`(IP 10.244.84.232,节点 sswcc29)、 +`fisco-verify-7457b699bf-v5ksz`、`mpc-demo-54d569f7b4-hbt9t`(IP 10.244.84.234)。 +svc:`fisco-chain` NodePort **30100**(RPC→20200) / 30101(P2P→30300);`mpc-demo` 30082。 +链是活的:RPC 直连 `getBlockNumber` → `result: 34`(本轮测到 45)。 + +### 本轮修复的 bug +1. **主键超长**:`rcpt-`+48hex=53 / `tee-`+48hex=52 > `f_id VARCHAR(50)` ⇒ + `QueryFailedError: value too long for type character varying(50)`。 + 改 `rcpt-`+45hex=50、`tee-`+46hex=50。(踩坑:device 侧当时没触发,一并改了) +2. **Receipt 反解**:outbox payload 是二进制 canonical_bytes,不是 JSON ⇒ 自己写了解码器 + (adapter 的 `decodeReceiptPayload` + `readOutboxRows`)。 +3. **`mpcSettings()` 仓库根解析**:`../../ssw-mpc` 从 `src/backend` 落到 workspace 根下, + 正确是 `../../../ssw-mpc` ⇒ 改成多候选 + 存在性探测(含 `target/debug/mpc` 探测)。 +4. **seed 菜单显示名**:新增「内置菜单显示名对齐」逻辑(只改内置 urlAddress 且名不同的行; + 软删行/人工菜单不动)—— 因为 `ensureBase` 按 urlAddress 补、**不覆盖已有行**。 + +### 脚本改造 +- `scripts/seed-infra.js` **重写**:从「灌 3 假设备 + 3 假区块」改成「**触发真源同步**」, + 新增 `--list` / `--tx `。假数据退休。 + +### 验证(全绿 + 真实链路) +| 检查 | 结果 | +|---|---| +| 后端 tsc / 前端 tsc --noEmit | 通过 | +| `check-module.sh sswdevice Device` | 21/0 | +| `check-module.sh sswchain ChainBlock` | 21/0 | +| `perm-smoke.sh` | 32/0 | +| `sswflow-smoke.sh` | 46/0 | +| `Device/Sync` 真机 | code 200, synced=2, source=control-plane, origin=GET http://192.168.1.102:3020/nodes | +| `ChainBlock/Sync` 真链 | code 200, synced=1, source=chain-cli, height=44→45 | +| `ChainBlock/Sync` + txHash | txReceipt: status=16, blockNumber=45, gasUsed=21520, success=false(三件套判对) | +| fail-closed | 控制面不可达 ⇒ 0 条 + source=mock + reason;不造假数据 | +| 浏览器实测 | 菜单动态出「设备注册」「链上存证」;两页渲染正常;同步按钮可点;
txHash 输入 → 摘要显示「链上回执 失败(16) @块高 45(group0/node0)」 | + +### 环境坑(本轮新增) +- **PGlite 0.5.8 持久化模式起不来**:`new PGlite('/tmp/x')` 卡在 `waitReady`(40s 超时), + 纯 `memory://` 正常 ⇒ 持久化目录暂时不可用(既有环境限制,非本次改动引入)。 + 后果:**每次重启后端数据清空**,测「存量库改名」这类路径需要真 Postgres。 +- 后端**启动后 5~8s 内登录会失败**(PGlite 初始化竞态),要等日志出现 + 「Nest application successfully started」再打 API。 +- `grep` 在部分 ssw-mpc 源文件上返回空(编码/换行),改用 `python3` + `re` 读。 +- `grep -n "中文" file` 对本仓库文件常返回空(退出码 1)⇒ 改用 python 计数验证。 +- xop 一次注入全部密钥(单次生物识别),`sshpass -e` + `ssh -l`;`printenv` 会被拦成 + `ro****【xop禁止将密钥泄漏】`。 + +## 第三轮:设备同步补「下线」语义(`/nodes` 是当前在线清单) + +### 根因(读 ssw-mpc 源码确认,不是猜) + +`crates/mpc-tee/src/control_plane.rs`: + +```rust +pub fn nodes(&self) -> Vec { self.registry.list() } +/// 剔除超过 TTL 未心跳的节点。 +pub fn prune_stale(&self) { self.registry.prune_stale(None); } +``` + +- `node_ttl_secs` 默认 **90**(`control_plane.rs:84`); +- 长循环每轮 `reconcile_current()` → `prune_stale()` → `save_registry()`; +- ⇒ **`GET /nodes` 返回的是「此刻活跃的节点」,不是「注册过的档案」**。 + +原实现只 upsert 不下线 ⇒ 真源掉线的节点在库里留僵尸行,前端会显示成「在位」。 + +### 改动 + +| 文件 | 改动 | +|---|---| +| `src/backend/src/sswdevice/device.entity.ts` | 新增列 `f_online`(int, nullable) | +| `src/backend/src/sswdevice/device.service.ts` | 同步时标下线 + 返回 `offline` 计数;`save()` 剥掉 `online`/`source`/`sourceReason` | +| `src/frontend/src/components/CrudPage.tsx` | `summarizeSync` 加「下线 N 个」 | +| `src/frontend/src/views/Device.tsx` | 新增「状态」列(三态)+ banner 说明 | +| `src/backend/db/schema.sql` | 重新生成(device 22→23 列) | + +**★ fail-closed 的延伸**:只有 `source !== 'mock'`(真源读取成功)时才做下线。 +控制面不可达时拿到的 0 条节点**不代表所有设备都掉线** ⇒ 此时 `offline` 恒 0、 +`f_online` 保持原值(否则就是误报)。 + +`f_online` 三态:`1`=在线 / `0`=真源里已消失 / `null`=从未同步(人工登记)。 +人工登记 `save()` 剥掉真源权威字段 —— 能力位与在线状态只能来自真源。 + +### 验证(自建假控制面复刻 node_to_json 字段形状 + 真控制面同一鉴权口径) + +| 阶段 | 期望 | 实测 | +|---|---|---| +| 1 | alice+bob 在线 → synced=2 offline=0,2 行 online=1 | ✅ | +| 2 | alice 掉线 → synced=1 offline=1,alice=0 bob=1 | ✅ | +| 3 | 再同步 → offline 不累加(幂等) | ✅ | +| 4 | 控制面停掉 → synced=0 offline=0 source=mock,**在线节点没被误标** | ✅ | + +回归全绿:后端 tsc 0 / 前端 tsc 0 / `check-module sswdevice Device` 21-0 / +`sswchain ChainBlock` 21-0 / `sswflow` 219-0 / `perm-smoke` 32-0 / `sswflow-smoke` 46-0 / +`gen-schema` 18 张表。 + +浏览器实测(agent-browser 0.27.0):设备页多出「状态」列显示「在线」; +同步摘要「数据来源:control-plane · 同步 1 条」;链上存证页四验证位仍分开报 +(通过/通过/通过/**未做验签**)+「失败(16)」+ 块高 45 + 真 txHash。 + +### 本轮的真源变化(不是缺陷) + +AMD 真机 192.168.1.7 上 hostd 已停(3010/3020 Connection refused,ping 0% 丢包, +22 端口 TCP 可连但握手被 reset ⇒ 服务端 banner 前 RST,客户端无解), +控制面 `/nodes` 只剩海光 `bob@192.168.1.102`。**库内行数与真源一致即正确**。 + +### 环境坑(本轮新增) + +- `aix` 软链指向的 agentx 二进制不存在(链接断),改用 `agent-browser`(`/Users/xs/.npm-global/bin/agent-browser` 0.27.0)。 +- 验「下线」需要能控制真源 ⇒ 自建临时假控制面(复刻 `node_to_json` 字段形状 + + 同一鉴权口径),跑完后删临时文件;起第二个后端实例用 `PORT=30001` + `MPC_CONTROL_PLANE_URL` 指过去。 diff --git a/.workbuddy/memory/MEMORY.md b/.workbuddy/memory/MEMORY.md new file mode 100644 index 0000000..c490e7c --- /dev/null +++ b/.workbuddy/memory/MEMORY.md @@ -0,0 +1,164 @@ +# ssw-mpc-flow 项目长期记忆 + +> 范围:`/Users/xs/Desktop/workspace/ssw-mpc-flow`(隐私计算编排,JNPF Lite 框架) + +## 项目定位 + +从 `../ssw-mvp` 抽取隐私计算编排(sswflow)域做成独立项目: +框架换 **JNPF Lite**(NestJS + TypeORM + PGlite + React/Vite), +执行底座换 **`../ssw-mpc`**(Rust CLI)。 +**不修改 ssw-mpc Rust 源码**(其 IR 无 serde、hostd 非 DAG 入口、demo 非生产协议)。 + +## 硬契约(改了会破) + +- **DAG 结构**:`steps[{stepId,operatorKey,label,x,y,params}]` / + `edges[{edgeId,sourceStepId,sourcePort,targetStepId,targetPort}]` —— 前后端一致。 +- **JNPF 数据契约**:`f_` 前缀列、`f_id VARCHAR(50)` UUID 主键、`f_delete_mark` 软删、 + `ActionResult` 统一返回、API 路径 `/api/ssw/sswflow/{Entity}/{List|Save|Delete}`。 +- **三处一字不差**:controller `MODULE_KEY` == `seed.service.ts` 的 `urlAddress` + == `App.tsx` 的 ``。改任一处必须同步另两处,否则菜单不显示 / 路由 404 / 权限静默放行。 +- **算子 19 个**在 `catalog/catalog.json`(唯一事实源);端口与必填参数以它为准。 +- **12 张表** `sswflow_*`;`db/schema.sql` 由 `scripts/gen-schema.js` 生成,**改列改实体后重跑**。 +- **模块是兄弟而非子域**:`sswflow`(编排)/ `sswdevice`(设备注册)/ `sswchain`(链上存证) + 与 `shop`/`books` 同级,各有自己的 appCode + 模块目录 + 表前缀(`sswdevice_*` / `sswchain_*`)。 +- **前端菜单全动态**:`Dashboard.tsx` 从 `currentUser().menuList` 渲染 → 加菜单**不用改导航代码**, + 只要 seed `menus[]` + App.tsx Route + controller MODULE_KEY 三处一致就会自动出现。 +- **★ `f_id VARCHAR(50)` 是硬上限**:主键派生前缀 + hex 必须 ≤ 50 + (`tee-`+46hex=50 / `rcpt-`+45hex=50)。超了报 `value too long for type character varying(50)`。 +- **★ 两个兄弟模块是真接口对接,不许灌假数据**: + - 设备注册真源 = ssw-mpc **control-plane** `GET {url}/nodes`(Bearer **明文原文**密钥) + - 链上存证真源 = ssw-mpc **outbox**(二进制 canonical_bytes)+ FISCO 国密链自有 RPC + - 真源不可达 ⇒ **0 条 + source=mock + 原因**,绝不造假数据顶。 +- **★ `sswdevice_device.f_online` 三态**:`1`=此刻在真源 `/nodes` 里 / `0`=真源里已消失 + (掉线或 TTL 过期)/ `null`=从未同步过(人工登记)。 + 控制面 `/nodes` 是**当前在线清单**(TTL 90s 自动剔除)⇒ 同步必须标下线, + 但**只有真源读取成功时**才标(不可达时 `offline` 恒 0)。 + `save()` 剥掉 `online`/`source`/`sourceReason` ⇒ 人工登记不能篡改真源权威字段。 + +## 关键入口 + +| 用途 | 路径 | +|---|---| +| 画布编辑器 | `src/frontend/src/views/Flow.tsx`(**React Flow `@xyflow/react`** 受控模式) | +| 画布节点 | `src/frontend/src/components/SswNode.tsx`(按算子 ports 动态渲染 Handle) | +| 画布转换层 | `src/frontend/src/utils/flowTransform.ts`(toBackendSteps/Edges,端口 key 直通) | +| 执行引擎层 | `src/backend/src/sswflow/engine/` | +| 算子能力映射 | `src/backend/src/sswflow/engine/mpc-operator-map.ts` | +| 运行调度中枢 | `src/backend/src/sswflow/flowrun.service.ts` | +| 菜单种子 | `src/backend/src/sys/seed.service.ts`(`menus[]` 字面量,perm-smoke 动态解析它) | +| schema 生成器 | `scripts/gen-schema.js`(递归扫 `src/backend/src/**/*.entity.ts`) | +| **ssw-mpc 适配层(真源唯一入口)** | `src/backend/src/sswflow/engine/ssw-mpc-adapter.ts` | +| 设备注册 / 链上存证 | `src/backend/src/sswdevice/` `src/backend/src/sswchain/`(**已真接口对接**) | +| 通用 CRUD 页 | `src/frontend/src/components/CrudPage.tsx`(`apiBase` / `sync` / `syncExtra` / `renderCell` / `banner`) | + +**★ ssw-mpc 侧真源(只读,不改 Rust 源码)**: +`crates/mpc-chain/src/objects.rs`(Receipt 布局)、`outbox.rs`(行格式 + 幂等键)、 +`rpc.rs`(FISCO 自有端点 + 成功三件套)、`crates/mpc-hostd/src/auth.rs`(Bearer 口径)、 +`crates/mpc-cli/src/chain.rs`(子命令)、`tools/selftest-fisco-contract.py`(真链门禁 22/22)、 +`tools/fisco-realnode/example.chain.json`(chain.json)、`contracts/MpcHardRule.sol` + +`build/contracts/combined.json`(合约与 ABI)、`deploy/tee/real-machine/`(真机参数集中入口)。 + +**画布组件事实**:原 ssw-mvp 用 VueFlow(`@vue-flow/core`);本项目用同门 React Flow +(`@xyflow/react`)。二者 API 一一对应(受控用 applyNodeChanges、Handle id=端口 key、 +useReactFlow/fitView、Background/MiniMap/Panel 全有)。**端口 key 透传**: +React Flow 的 `sourceHandle`/`targetHandle` == 后端 `edge.sourcePort`/`edge.targetPort` +== `catalog.json` 端口 key,无映射表。 + +## 验证命令(改完必跑) + +```bash +node scripts/gen-schema.js # 列有变更时 +bash scripts/check-module.sh sswflow Artifact Dataset DatasetAuth Datasource Flow \ + FlowRun FlowSchedule FlowStepRun Party Project ProjectParty RunEvent # 静态,期望 219/0 +bash scripts/perm-smoke.sh # 权限闭环,期望 32/0 +bash scripts/sswflow-smoke.sh # 业务链路,期望 46/0 +bash scripts/check-module.sh sswdevice Device # 静态,期望 21/0 +bash scripts/check-module.sh sswchain ChainBlock # 静态,期望 21/0 +node scripts/check-canvas-ports.js # 画布端口落库校验(默认 127.0.0.1:30000) +node scripts/seed-infra.js # ★ 触发真源同步(不再灌假数据) +node scripts/seed-infra.js --list # 只看当前库里有什么 +node scripts/seed-infra.js --tx 0x # 额外查 FISCO 链上出块回执 +``` + +**★ 两个模块的环境变量**(后端进程要带,否则退化成 mock): + +| 变量 | 值(真机) | +|---|---| +| `MPC_CONTROL_PLANE_URL` | `http://192.168.1.102:3020`(海光真机 control-plane) | +| `MPC_HOSTD_SHARED_SECRET` | `/tmp/mpc-cluster/cluster.secret` 的**原文**(非 hex) | +| `MPC_FISCO_CHAIN_CONFIG` | `../ssw-mpc/tools/fisco-realnode/example.chain.json` | +| `MPC_FISCO_OUTBOX` | `/chain-outbox.txt` | +| `MPC_FISCO_NODE` | `node0` | + +**服务端口**:后端实际监听 **30000**(非 3000),前端 dev `127.0.0.1:5173`。 +登录契约:`x-www-form-urlencoded` 的 `account` + AES-ECB 密文密码(`encryptPassword('123456')`) ++ `grant_type=password`,token 在 `data.token`。 + +`check-module.sh --all` 会把多词实体名拆错(`datasetauth`→`Datasetauth`), +**必须显式列实体名**。 + +## 环境坑 + +- 起后端用 `node dist/main.js`(`nest start`/`nest build` 会被安全删除钩子拦,因为它们要清 dist)。 + **编译用 `npx tsc -p tsconfig.json`**(直接发射到 dist,增量覆盖,不批量删目录)→ 绕过钩子且成功。 +- `gen-schema.js` 的 ENTITY_DIR 已改成递归扫整个 `src/backend/src`,新模块加在 sswflow 之外也能进 schema.sql。 +- `./run.sh dev` 的 nohup 进程在工具 shell 里会被回收 → 用工具原生后台任务起进程。 +- 浏览器自动化用 `agent-browser`(`aix` 软链已断);React 重渲染后 `@ref` 失效, + 改用 `eval` + `element.click()` + 手动 dispatch `change`(原生 select 要用 + `HTMLSelectElement.prototype` 的 value setter)。 +- macOS grep 无 `-P`;`npm bin -g` 已移除,用 `npm root -g`。 +- **PGlite 0.5.8 持久化模式起不来**:`new PGlite('/dir')` 卡在 `waitReady`,只有 + `memory://` 能用 ⇒ **每次重启后端数据清空**(测存量库路径需要真 Postgres)。 +- 后端启动后 **5~8s 内登录会失败**(PGlite 初始化竞态)→ 等日志出现 + 「Nest application successfully started」再打 API。 +- `grep` 对本仓库文件常返回空(退出码 1)⇒ 改用 python 计数/`re` 读。 +- `mpcSettings()` 仓库根解析是**多候选 + 存在性探测**(`../../../ssw-mpc` 等), + 别改回单路径 —— 从 `src/backend` 出发 `../../` 会落到 workspace 根下。 + +## 已知未实现 + +- **FlowSchedule 周期调度**:只有表和 CRUD,**调度器未实现**(到点不自动起 run)。 +- ssw-mpc 真实执行未跑通(需 `MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` + 各方 `mpc agent`)。 +- **AMD 真机 192.168.1.7 的 SSH 未打通**:22 端口 TCP 可连但握手被 reset + (`ssh -vvv` 定位:服务端在发 banner 前 RST ⇒ 服务端侧行为,客户端无解)。 + 2026-11-10 下午该机上的 hostd 已停(3010/3020 Connection refused,ping 通) + ⇒ 控制面 `/nodes` 只剩海光 `bob@192.168.1.102` 一个节点。 + 这是**真源变化**,不是读取缺陷 —— 库内行数与真源一致即正确。 +- **端口扫描必须 `--noproxy '*'` / `NO_PROXY=*`**:本机代理会把 `nc -z` 的 + 「succeeded」报成假阳性。 +- **设备注册无 mTLS 握手**:走的是 ssw-mpc 既有机制(TEE 节点经 hostd 向控制面自报), + 本项目只做注册表的读取与呈现,不自建注册协议。 +- **链上存证不是通用区块浏览器**:ssw-mpc `mpc chain` **没有**区块浏览命令, + 链上对象只有 Receipt / Member / PolicyBundleRecord 三类。 + +## ssw-mvp 原始落点(别再找错) + +「设备注册」「区块链」**不在 sswflow 域**,是三个子项目三种语言: +`nax/nax/device/`(Python 设备登记)、`scard/code/connector/register/`(Go 注册连接器)、 +`boot/ssw-tds/.../tds/chain/`(Java FISCO 链存证)。**没有现成 TS 版可搬** —— +本项目改为**直接对接 ssw-mpc 的真实接口**(control-plane + outbox + FISCO 链), +不是移植 ssw-mvp 的旧实现。 + +## ★ 真链/真机关键事实 + +细节见 README「设备注册 / 链上存证」两节与 `.workbuddy/memory/2026-11-10.md`。 +最易踩的 9 条: + +1. **FISCO 成功三件套**:`status==0`(与 web3 的 0x1 **相反**)+ `transactionHash` 非空 + + `blockNumber>0`;字段缺失按「没有」处理。 +2. **FISCO 自有端点**(非 web3):`getTransactionReceipt`/`call`/`sendTransaction` 都 4 参 + `[groupID,nodeName,…]`;`getBlockNumber` **只接受 0 参**。HTTP 200 ≠ 成功。 +3. **selector 是二元数组** `[keccak_u32, sm3_u32]`,国密链用 `SM3(signature)[0..4]`。 +4. **合约 `recordHardRule` 的 orderId ≤ 16 字节**(17 起 revert status=16)。 +5. **`chain contract deploy --bin` 被忽略**(实际读 `--abi`,要 combined.json); + `call --arg` 要 `TYPE:VALUE` + `--key ` + `--node node0`。 +6. **控制面 Bearer 必须是密钥原文**(非 hex);outbox `Confirmed` 只代表已广播。 +7. **Receipt 布局**:域分隔固定 25B 无长度前缀 → `push_field("receipt")` → `"v1"` → 字段。 +8. **TeeNode**:`kbc`=`cc_kbc`/`offline_fs_kbc::null`;`platform`=`sev-snp`/`hygon-csv`; + `kbs_endpoint` 只能从 descriptor 解析。 +9. **★ `GET /nodes` 是「当前在线清单」,不是注册档案**:控制面 + `prune_stale()` 会剔除超 `node_ttl_secs`(**默认 90s**)未心跳的节点 + (`crates/mpc-tee/src/control_plane.rs`)。⇒ 同步必须处理「下线」: + 真源里消失的节点标 `f_online=0`(不软删),且**只有真源读取成功时**才标 + (控制面不可达时 `offline` 恒 0,否则就是误报)。`f_online` 三态: + `1`=在线 / `0`=掉线 / `null`=从未同步(人工登记)。 diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..c181597 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,222 @@ +# CLAUDE.md + +> 本文件是 **ssw-mpc-flow** 的项目级上下文。改动前先读这里,别凭印象猜。 +> 详细口径见 `README.md`;踩坑与实测事实见 `.workbuddy/memory/`。 + +## 项目是什么 + +ssw-mpc-flow(尚数网 · 隐私计算流程编排):把多方安全计算的**业务流程编排**做成可配置、可视化、 +可执行的平台。DAG 画布编排 → 执行引擎跑 → 产物与指标留痕。 + +- **框架**:JNPF Lite 契约(NestJS + TypeORM + PGlite 嵌入式 Postgres + React 18 / Vite) +- **执行底座**:`../ssw-mpc`(Rust CLI,`mpc-*` crate),**不修改其源码** +- **来源**:从 `../ssw-mvp` 抽取 sswflow(隐私计算编排)域,原 Vue 技术栈换成 React +- **与 ssw-mvp 的关系**:只搬「编排」域;设备注册 / 区块链**不在 sswflow 域**, + 本项目改为**直接对接 ssw-mpc 的真实接口**(见下「两个真源模块」) + +三个业务模块是**兄弟**而非子域,各有 appCode + 模块目录 + 表前缀: + +| 模块 | appCode | 路径 | 表 | 定位 | +|---|---|---|---|---| +| 隐私计算编排 | `sswflow` | `/sswflow/*` | 12 | DAG 画布、算子目录、执行引擎、运行监控 | +| 设备注册 | `sswdevice` | `/sswdevice/Device` | 1 | TEE 节点注册表(真源 = ssw-mpc 控制面) | +| 链上存证 | `sswchain` | `/sswchain/ChainBlock` | 1 | Receipt / FISCO 回执(真源 = outbox + 国密链) | + +## 五条铁律(优先级高于一切) + +1. **三处一字不差**:controller 的 `MODULE_KEY` == `seed.service.ts` 的 `menus[].urlAddress` + == `App.tsx` 的 ``。改任一处必须同步另两处,否则**菜单不显示 / 路由 404 / + 权限静默放行** —— 这三种症状都不报错,极难定位。 + +2. **改列改实体后必须重跑 `node scripts/gen-schema.js`**。`src/backend/db/schema.sql` 由实体 + 自动生成,手改 SQL 会与 TypeORM 漂移。 + +3. **`f_id VARCHAR(50)` 是硬上限**。主键由真源稳定键派生(前缀 + hex), + 必须 ≤ 50 字符:`tee-`+46hex=50、`rcpt-`+45hex=50。 + 超了报 `value too long for type character varying(50)`。 + +4. **两个兄弟模块是真接口对接,不许灌假数据**。真源不可达 ⇒ **0 条 + `source=mock` + 原因**, + 绝不用假数据顶。造一份演示数据只会让人误以为系统能跑。 + +5. **算子目录以 `catalog/catalog.json` 为唯一事实源**(19 个算子)。端口与必填参数以它为准, + 不要在别处硬编码算子元信息。 + +## 快速验证 + +> **环境前置**:真机联调 / 真链访问的凭据走 **xop**(`xop -h`), +> 源码在内网 Git `192.168.1.18:13300/x/xop`。 +> 别把明文密码写进脚本或命令行 —— 用环境变量 + `sshpass -e` / `GIT_ASKPASS`。 + +```bash +# 后端编译(★ 不要用 nest start / nest build:它们要清 dist,会被安全删除钩子拦) +cd src/backend && npx tsc -p tsconfig.json # 增量发射到 dist,不批量删目录 + +# 起后端(实际监听 30000,不是 3000) +cd src/backend && node dist/main.js + +# 前端类型检查 +cd src/frontend && npx tsc --noEmit -p tsconfig.json +``` + +**改完必跑的回归**(期望数字写死,掉了就是回归): + +```bash +node scripts/gen-schema.js # 列有变更时;期望 18 张表 +bash scripts/check-module.sh sswflow Artifact Dataset DatasetAuth Datasource Flow \ + FlowRun FlowSchedule FlowStepRun Party Project ProjectParty RunEvent # 期望 219/0 +bash scripts/check-module.sh sswdevice Device # 期望 21/0 +bash scripts/check-module.sh sswchain ChainBlock # 期望 21/0 +bash scripts/perm-smoke.sh # 权限闭环;期望 32/0 +bash scripts/sswflow-smoke.sh # 业务链路;期望 46/0 +node scripts/check-canvas-ports.js # 画布端口落库校验 +``` + +> ★ `check-module.sh --all` 会把多词实体名拆错(`datasetauth` → `Datasetauth`), +> **必须显式列实体名**。 + +**拉真实数据**(不是灌演示数据): + +```bash +node scripts/seed-infra.js # 设备 + 存证:从真源同步(幂等) +node scripts/seed-infra.js --list # 只看库里有什么 +node scripts/seed-infra.js --tx 0x # 额外查一笔 FISCO 链上出块回执 +node scripts/seed-demo.js # 编排域演示数据(参与方/项目/DAG) +``` + +**端到端演示**(参考 ssw-mvp 的 e2e 脚本做的自包含版): + +```bash +bash docs/e2e/sswflow/run.sh # 无头:API 直通执行引擎,出控制台 + JSON + HTML 报告 +bash docs/e2e/sswflow/run.sh --ui # 额外用浏览器打开 Flow 画布真实点「▶ 运行」并截图 +``` + +> 登录契约:`POST /api/oauth/Login`(**不是** `/api/sys/Account/Login`), +> `x-www-form-urlencoded` 的 `account` + AES-ECB-PKCS7 密文密码(`encryptPassword('123456')`) +> + `grant_type=password`,token 在 `data.token`。 + +## 关键入口 + +| 用途 | 路径 | +|---|---| +| 画布编辑器 | `src/frontend/src/views/Flow.tsx`(React Flow `@xyflow/react` 受控模式) | +| 画布节点 | `src/frontend/src/components/SswNode.tsx`(按算子 ports 动态渲染 Handle) | +| 画布转换层 | `src/frontend/src/utils/flowTransform.ts`(端口 key 直通,无映射表) | +| 执行引擎层 | `src/backend/src/sswflow/engine/` | +| 算子能力映射 | `src/backend/src/sswflow/engine/mpc-operator-map.ts` | +| **真源适配层** | `src/backend/src/sswflow/engine/ssw-mpc-adapter.ts`(控制面 / outbox / FISCO 回执) | +| 运行调度中枢 | `src/backend/src/sswflow/flowrun.service.ts` | +| 菜单种子 | `src/backend/src/sys/seed.service.ts`(`menus[]` 字面量,perm-smoke 动态解析它) | +| schema 生成器 | `scripts/gen-schema.js`(递归扫 `src/backend/src/**/*.entity.ts`) | +| 设备注册 | `src/backend/src/sswdevice/` · `src/frontend/src/views/Device.tsx` | +| 链上存证 | `src/backend/src/sswchain/` · `src/frontend/src/views/ChainBlock.tsx` | +| 通用 CRUD 页 | `src/frontend/src/components/CrudPage.tsx`(`apiBase` prop 区分 appCode) | + +## 架构要点 + +### 前后端契约 + +- DAG 结构:`steps[{stepId,operatorKey,label,x,y,params}]` / + `edges[{edgeId,sourceStepId,sourcePort,targetStepId,targetPort}]` +- JNPF 数据契约:`f_` 前缀列、`f_id VARCHAR(50)` UUID 主键、`f_delete_mark` 软删、 + `ActionResult` 统一返回、API 路径 `/api/ssw/{appCode}/{Entity}/{List|Save|Delete}` +- 前端菜单**全动态**:`Dashboard.tsx` 从 `currentUser().menuList` 渲染 + ⇒ 加菜单**不用改导航代码**,只要三处一致就会自动出现 + +### 画布组件:VueFlow → React Flow + +原 ssw-mvp 用 VueFlow(`@vue-flow/core`),本项目用同门 React Flow(`@xyflow/react`)。 +二者 API 一一对应(受控用 `applyNodeChanges`、Handle `id` = 端口 key、 +`useReactFlow`/`fitView`、Background/MiniMap/Panel 全有)。 + +**端口 key 透传**:React Flow 的 `sourceHandle`/`targetHandle` == 后端 `edge.sourcePort`/`edge.targetPort` +== `catalog.json` 的端口 key,**没有映射表**。 + +### 两个真源模块 + +**设备注册** —— 真源 = ssw-mpc 控制面 `GET {MPC_CONTROL_PLANE_URL}/nodes`。 + +- TeeNode 真实字段:`site`/`host`/`platform{kind,tcb}`/`device_present`/`qemu_present`/ + `firmware_present`/`image_present`/`measurement[32]`/`kbc`/`kbs_reachable`/`kbs_endpoint`/`qemu_bin`… +- `platform` = `sev-snp` / `hygon-csv`;`kbc` = `cc_kbc` / `offline_fs_kbc::null` + (**不是** online/offline);`key` = `site@host`;`tcb` 是整数 +- ★ `kbs_endpoint` **只能从 descriptor 解析**(`node_to_json` 没有该字段) +- ★ 控制面鉴权:配了共享密钥 ⇒ 必须带 `Authorization: Bearer <明文密钥原文>` + (≥32 字节、纯 ASCII、**不许含空白**)。**用了 hex 编码会全 401** +- ★ **`/nodes` 是「当前在线清单」,不是注册档案**:控制面 `prune_stale()` 会剔除超 + `node_ttl_secs`(**默认 90s**)未心跳的节点 + ⇒ 真源里消失的节点要标 `f_online=0`(不软删), + 且**只有真源读取成功时**才标(不可达时 `offline` 恒 0,否则是误报) +- `f_online` 三态:`1`=在线 / `0`=掉线 / `null`=从未同步(人工登记) + +**链上存证** —— 真源 = ssw-mpc outbox(二进制 canonical_bytes)+ FISCO 国密链自有 RPC。 + +- Receipt 布局:域分隔固定 25B **无长度前缀** → `push_field("receipt")` → `"v1"` → 字段 +- ★ **「验证通过」必须拆成四句**:`user_data_ok` / `meas_ok` / `tcb_ok` / `chip_sig` 分开报, + **不许合并成 `ok=1`**(`chip_sig=0` 意为「绑定成立但没做芯片验签」) +- ★ **FISCO 成功三件套**:`status == 0`(与 web3 的 `0x1` **相反**)+ `transactionHash` 非空 + + `blockNumber > 0` +- ★ **FISCO 自有端点**(不是 web3 那套):`getTransactionReceipt` / `call` / `sendTransaction` 都是 + 4 参 `[groupID, nodeName, …]`;`getBlockNumber` **只接受 0 参**。**HTTP 200 ≠ 成功** +- outbox 行式:`v1|key|state|attempts|payload_hex|last_error_hex`, + **6 段缺一即坏行 ⇒ 整表拒绝**,绝不静默跳过;`Confirmed` 只代表已广播,不代表已出块 + +## 环境坑 + +- 起后端用 `node dist/main.js`(`nest start`/`nest build` 会被安全删除钩子拦)。 + 编译用 `npx tsc -p tsconfig.json` —— 增量覆盖,不批量删目录。 +- **PGlite 0.5.8 持久化模式起不来**(卡 `waitReady`),纯 `memory://` 正常 + ⇒ **每次重启后端数据清空**。这是既有环境限制,不是代码问题。 +- 后端启动后 **5~8s 内登录会失败**(PGlite 初始化竞态) + ⇒ 要等日志出现「Nest application successfully started」再打 API。 +- `./run.sh dev` 的 nohup 进程在工具 shell 里会被回收 → 用工具原生后台任务起进程。 +- 浏览器自动化:`aix` 软链**当前是断的**(指向的 agentx 二进制不存在), + 用 `agent-browser`(`/Users/xs/.npm-global/bin/agent-browser`)。 + React 重渲染后 `@ref` 失效 → 改用 `eval` + `element.click()`。 +- **端口扫描必须加 `--noproxy '*'` / `NO_PROXY=*`**:本机 HTTP 代理会把 `nc -z` 的 + 「succeeded」报成假阳性(AMD 真机就踩过)。 +- macOS grep 无 `-P`;`grep` 对部分 ssw-mpc 源文件返回空 → 改用 `python3` 读。 +- `npm bin -g` 已移除 → 用 `npm root -g`。 + +## 已知未实现 + +- **FlowSchedule 周期调度**:只有表和 CRUD,**调度器未实现**(到点不自动起 run)。 +- **ssw-mpc 真实执行未跑通**:需 `MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` + 各方 `mpc agent`; + 默认走 `simulation` 引擎(确定性占位指标,界面会显式标注,不粉饰)。 +- **设备注册无 mTLS 握手**:走 ssw-mpc 既有机制(TEE 节点经 hostd 向控制面自报), + 本项目只做注册表的读取与呈现,不自建注册协议。 +- **链上存证不是通用区块浏览器**:ssw-mpc `mpc chain` **没有**区块浏览命令, + 链上对象只有 Receipt / Member / PolicyBundleRecord 三类。 +- **AMD 真机 192.168.1.7 的 SSH 未打通**:22 端口 TCP 可连但握手被 reset + (`ssh -vvv` 定位:服务端在发 banner 前 RST ⇒ 服务端侧行为,客户端无解)。 + 该机 hostd 已停(3010/3020 refused),所以控制面当前只有海光一个节点。 + +## 环境变量 + +| 变量 | 默认 | 用途 | +|---|---|---| +| `PORT` | `30000` | 后端监听端口 | +| `PGLLITE_DIR` | `memory://` | PGlite 数据目录(持久化模式**当前不可用**) | +| `PG_SYNC` | — | `false` 关掉 TypeORM 自动建表 | +| `MPC_CONTROL_PLANE_URL` | — | ssw-mpc 控制面地址(设备注册真源) | +| `MPC_HOSTD_SHARED_SECRET` | — | 控制面共享密钥(**Bearer 原文**,不是 hex) | +| `MPC_FISCO_CHAIN_CONFIG` | — | FISCO `chain.json` 路径 | +| `MPC_FISCO_OUTBOX` | — | chain outbox 路径 | +| `MPC_FISCO_NODE` | `node0` | FISCO 节点名 | +| `MPC_DRIVER` / `MPC_REAL_EXEC` | — | `mpc` + `1` 切真实引擎 | + +## 迁回 JNPF + +本项目是 JNPF Lite 契约的**可运行子集**。迁回时: + +1. 关闭 `synchronize`,直接复用 `src/backend/db/schema.sql` 显式建表。 +2. `base_module` 插入菜单(已内置在 `sys/seed.service.ts` 的 `menus` 数组)。 +3. `ActionResult` → JNPF 原生 `ResultExceptionHand` 形状已在 + `common/action-result.filter.ts` 对齐。 +4. `f_delete_mark` 软删语义、JNPF `ActionResult` 统一返回体均已按原生风格写。 + +## 相关文档 + +- `README.md` —— 完整口径(目录结构、算子目录、API 契约、两个真源模块详解) +- `docs/e2e/sswflow/README.md` —— 端到端演示脚本说明 +- `.workbuddy/memory/MEMORY.md` —— 项目长期记忆(硬契约 / 关键入口 / 验证命令) +- `.workbuddy/memory/2026-11-10.md` —— 当日工作日志(踩坑与实测记录) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8aa6e31 --- /dev/null +++ b/README.md @@ -0,0 +1,414 @@ +# ssw-mpc-flow · 隐私计算编排 + +从 `ssw-mvp` 抽出隐私计算编排(sswflow)域,重构为独立项目: +**框架换成 JNPF Lite + NestJS/React,执行底座换成 `ssw-mpc`(Rust)**。 + +原始 `ssw-mvp` 是 Spring Boot + Vue + 自研 NAX 执行层;本项目保留其业务语义与数据契约, +替换掉框架胶水层和执行引擎。 + +--- + +## 快速开始 + +```bash +./run.sh install # 安装前后端依赖 +./run.sh build # 生成 db/schema.sql + 构建前后端 +./run.sh dev # 起后端(30000) + 前端(5173) +``` + +打开 http://127.0.0.1:5173 ,默认账号 `admin` / `123456`。 + +数据库用嵌入式 **PGlite**(WASM Postgres,零服务进程 / 零 docker),引擎即真 PostgreSQL, +所以 `f_` 列 / `varchar(50)` / Postgres 方言契约完全保留。设 `PGLLITE_DIR=./.pglite` 可持久化。 + +灌演示数据(幂等,可重复跑): + +```bash +node scripts/seed-demo.js # 隐私计算编排:参与方 / 项目 / 数据集 / DAG 流程 / 调度 +node scripts/seed-infra.js # 设备注册 + 链上存证:**拉真实数据**(控制面 + 真链),不灌假数据 +node scripts/seed-infra.js --list # 只看当前库里有什么 +node scripts/seed-infra.js --tx 0x # 额外查一笔 FISCO 链上出块回执 +``` + +--- + +## 与原项目的关系 + +| 层 | ssw-mvp(本项目来源) | ssw-mpc-flow(本项目) | +|---|---|---| +| 后端框架 | Spring Boot + MyBatis-Plus | NestJS + TypeORM | +| 前端框架 | Vue 2 + Element UI | React 18 + Vite | +| 权限底座 | JNPF 底座 + TDS/TDC 胶水 | JNPF Lite 契约自建(轻量、可平移) | +| 执行引擎 | NAX / RemoteNax / TeeComputeEngine | **ssw-mpc** Rust CLI | +| 画布组件 | VueFlow(`@vue-flow/core`) | **React Flow(`@xyflow/react`)**——xyflow 同门,API 一一对应 | + +### 被裁掉的东西 + +- **TDS / TDC 胶水**:跨方 HTTP 转发、SSE 推送、审批待办链。前端改为轮询运行事件(等价物)。 +- **NAX 执行层**:整体替换为 `ssw-mpc`。NAX 的 `ComputeEngine` SPI 抽象保留为 `ComputeEngine` 接口, + 换底座不用动业务代码。 + +### 被保留的东西 + +- **DAG 数据契约**(前后端完全一致): + + ```ts + steps: [{ stepId, operatorKey, label, x, y, params: {} }] + edges: [{ edgeId, sourceStepId, sourcePort, targetStepId, targetPort }] + ``` + +- **运行状态机**:`run` 与 `step` 的 PENDING → RUNNING → SUCCESS/FAILED/STOPPED/SKIPPED。 +- **6 种运行范围**:`FULL / SINGLE / SELECTED / UPSTREAM / DOWNSTREAM / RESUME`。 +- **端口级连线语义**:上游产物按端口装配成本节点输入,不是整图广播。 +- **JNPF 数据契约**:`f_` 前缀列、`f_id VARCHAR(50)` UUID 主键、`f_delete_mark` 软删、`ActionResult` 返回体。 + +### 关于画布组件:VueFlow → React Flow + +原实现用的是 **VueFlow**(`@vue-flow/core` + `@vue-flow/background` + `@vue-flow/minimap`), +不是 LogicFlow(全仓 0 引用)。 + +VueFlow 与 **React Flow(`@xyflow/react`)** 是 xyflow 家族的两个前端实现, +核心概念(节点/边/Handle/视口/自定义节点)完全同构,API 几乎一一对应, +所以迁移是**平移**而不是重写: + +| VueFlow(原实现) | React Flow(本项目) | +|---|---| +| `` | `` | +| `useVueFlow()` | `useReactFlow()`(需包 ``) | +| `nodeTypes` | `nodeTypes` | +| `defaultEdgeOptions` | `defaultEdgeOptions` | +| `addEdge(params, edges)` | `addEdge(params, edges)`(导入时注意与本地同名函数区分) | +| `` | `` | +| `fitView()` / `zoomIn()` / `zoomOut()` | `fitView()` / `zoomIn()` / `zoomOut()`(`useReactFlow()`) | +| `` | `` | +| `` | `` | +| `` | `` | +| `@connect="onConnect"` | `onConnect={onConnect}` | +| `isValidConnection` / `connection-radius` | `isValidConnection` / `connectionRadius` | + +两处值得记录的差异: + +- **受控模式**:VueFlow 用 `v-model` 直接双向绑定;React Flow 走 `applyNodeChanges` / + `applyEdgeChanges` 把 change 事件回灌进 React state,本项目在 `Flow.tsx` 中显式实现了 + `onNodesChange` / `onEdgesChange`。 +- **端口 id 即端口 key**:React Flow 的 `sourceHandle` / `targetHandle` 直接存算子端口 key + (`prep.intersect` 的 `left`/`right`、`model.predict` 的 `model`/`in`), + 与后端 `edge.sourcePort` / `edge.targetPort` 逐字对应,无需再做映射表。 + +**端口锚点比原实现更完整**:原 `SswNode.vue` 只有固定的 `in`/`out` 两个 Handle, +所以 `prep.intersect` 的 `left`/`right`、`model.predict` 的 `in`/`model` +在 UI 上无法区分(后端校验会报「输入端口未连线」)。本项目的 `SswNode.tsx` +按算子 `catalog.json` 的 ports 动态渲染 N 个 Handle,多端口算子的每个端口都能独立拖线。 + +--- + +## 目录结构 + +``` +src/backend/ NestJS + TypeORM + src/sswflow/ 业务域(12 张表 + 14 个控制器) + engine/ 执行引擎层 + flow-graph.ts DAG 解析 / 校验 / 拓扑排序 / 上下游闭包 + compute-engine.ts ComputeEngine SPI(可插拔执行引擎) + engine-registry.ts 引擎选路(mpc / simulation) + mpc-engine.ts ssw-mpc 执行引擎 + simulation-engine.ts 本地模拟引擎(无 Rust 依赖时兜底) + mpc-operator-map.ts 19 算子 → ssw-mpc 能力映射 + plan 编译 + mpc-client.ts Rust CLI 调用 / 探测 / orch plan 执行 + catalog/ 算子协议目录(catalog.json 为唯一事实来源) + src/sswdevice/ 设备注册模块(1 张表 + 1 控制器)—— 对接控制面节点注册表 + src/sswchain/ 链上存证模块(1 张表 + 1 控制器)—— 对接 outbox + FISCO 回执 + db/schema.sql 18 张表(由 scripts/gen-schema.js 从实体自动生成) +src/frontend/ React 18 + Vite + src/views/Flow.tsx DAG 画布编辑器(算子面板 + 画布 + 属性面板) + src/views/FlowRun.tsx 运行监控(步骤 / 事件 / 产物) + src/views/Device.tsx 设备注册(TEE 节点)—— 数据源:control-plane + src/views/ChainBlock.tsx 链上存证(Receipt)—— 数据源:chain outbox + FISCO +scripts/ + gen-schema.js 实体 → schema.sql 生成器(防漂移) + check-module.sh 模块规范检查 + perm-smoke.sh 登录 / 菜单权限冒烟 + seed-demo.js 隐私计算编排演示数据 + seed-infra.js 设备注册 + 链上存证:**触发真源同步** +``` + +--- + +## 业务模块一览 + +| 模块 | appCode | 路径 | 表 | 说明 | +|---|---|---|---|---| +| 隐私计算编排 | `sswflow` | `/sswflow/*` | 12 | DAG 画布、算子目录、可插拔执行引擎、运行监控 | +| 设备注册 | `sswdevice` | `/sswdevice/Device` | 1 | TEE 节点注册表,**真源 = ssw-mpc 控制面 `GET /nodes`**(在线清单,含下线标记) | +| 链上存证 | `sswchain` | `/sswchain/ChainBlock` | 1 | Receipt / FISCO 回执,**真源 = ssw-mpc outbox + 国密链** | + +三个模块共用同一套 JNPF-Lite 契约:`f_` 前缀列、`f_id VARCHAR(50)` UUID 主键、 +`f_delete_mark` 软删、`ActionResult` 返回体、模式 B 守卫(登录 + 菜单权限), +路径统一为 `/api/ssw/{appCode}/{Entity}/{List|Save|Delete}`。 + +--- + +## 设备注册:对接 ssw-mpc 控制面 + +**这不是手工登记的设备表**,而是 TEE 节点经 `mpc hostd` 向 `mpc control-plane` +自报后的注册表投影。前端「从控制面同步」调 `POST /api/ssw/sswdevice/Device/Sync`, +后端打 `GET {MPC_CONTROL_PLANE_URL}/nodes` 并 upsert。 + +### TeeNode 真实字段(23 列,逐一对应) + +| 列 | 来源字段 | 实测取值 | +|---|---|---| +| `f_key` | `key` | `site@host`(如 `alice@192.168.1.7`) | +| `f_site` / `f_host` | `site` / `host` | `alice` / `192.168.1.7` | +| `f_platform` | `platform.kind` | `sev-snp`(AMD)/ `hygon-csv`(海光) | +| `f_tcb` | `platform.tcb` | 整数:AMD SNP=5,海光 CSV2=3 | +| `f_capacity` | `capacity` | 并发槽位 | +| `f_last_seen` | `last_seen` | Unix 秒(bigint) | +| `f_device_present` / `f_qemu_present` / `f_firmware_present` / `f_image_present` | 同名 | 能力位,**漏填即被 `admit` 拒绝** | +| `f_kbs_reachable` | `kbs_reachable` | KBS 是否可达 | +| `f_kbc` | `kbc` | `cc_kbc` / `offline_fs_kbc::null`(**不是** online/offline) | +| `f_measurement` | `measurement[32]` | 镜像度量 hex | +| `f_kbs_endpoint` | descriptor 的 `kbs_endpoint` | ★ `node_to_json` **没有**这个字段,只能从 descriptor 解析 | +| `f_descriptor` | `descriptor` | 原始描述符全文(`key=value` 逐行) | +| `f_online` | — | **本表自己算的**:1=此刻在真源清单里 / 0=已掉线 / null=从未同步过 | +| `f_source` / `f_source_reason` | — | `control-plane` / 失败原因 | + +### ★ 下线语义:`/nodes` 是「当前在线清单」,不是注册档案 + +控制面 `ControlPlane::prune_stale()` 会**自动剔除**超过 `node_ttl_secs` +(默认 **90 秒**)未心跳的节点(`crates/mpc-tee/src/control_plane.rs`)。 +所以 `GET /nodes` 返回的是**此刻活跃的节点**,不是「注册过的历史档案」。 + +这带来一个必须处理的问题:**真源里消失的节点,在库里会留下旧行**, +前端会让人误以为该设备还在线。同步逻辑因此区分三态: + +| `f_online` | 含义 | +|---|---| +| `1` | 本次同步出现在真源清单里 ⇒ 此刻在线 | +| `0` | 真源里已经没有它(掉线 / TTL 过期)⇒ 同步时自动标出,**不软删、不物理删** | +| `null` | 从未同步过(人工登记)⇒ 前端显示「未登记」 | + +同步结果会额外返回 `offline` 计数(本次被标成离线的节点数),前端摘要显示「下线 N 个」。 + +**★ fail-closed 的延伸**:只有**真源读取成功**(`source !== 'mock'`)时才做下线。 +控制面不可达时拿到的 0 条节点**不代表所有设备都掉线** —— 此时标离线就是误报, +所以 `offline` 恒为 0,`f_online` 保持原值。 + +**★ 人工登记不能篡改真源权威字段**:`save()` 会剥掉 `online` / `source` / `sourceReason`, +人工只能填描述性字段(站点、主机、平台、度量、描述符等), +能力位与在线状态一律来自真源。 + +### 控制面鉴权口径(`crates/mpc-hostd/src/auth.rs`) + +- 配了共享密钥 ⇒ 必须带 `Authorization: Bearer <明文密钥原文>` + (≥32 字节、纯 ASCII、**不许含空白**)。服务端只存 SHA-256 摘要,常量时间比对。 +- 没配密钥(回环信任模式)⇒ 不带凭据放行,**带了任何凭据一律拒**。 +- ★ 已知坑:下发曾用 `hex_encode(secret)`,节点校验明文 ⇒ 全 401。token 必须是**原文**。 +- ★ 对外统一一句「缺少或无效的凭据」,不区分 missing / malformed / mismatch。 + +### fail-closed + +真源读不到 ⇒ 返回 **0 条** + `source=mock` + 原因,**绝不用假数据顶**。 +注册表为空时 `GET /nodes` 返回空数组(不是 404)。 + +--- + +## 链上存证:对接 outbox + FISCO 国密链 + +**这不是通用区块浏览器**:`mpc chain` **没有**区块浏览命令,链上对象只有 +`Receipt` / `Member` / `PolicyBundleRecord` 三类。所以这里做的是 +**链上对象 / Receipt / 回执浏览器**。 + +### Receipt 二进制布局(`crates/mpc-chain/src/objects.rs`) + +outbox 的 payload 是 `canonical_bytes` 的 hex,本项目实现了逆解: + +``` +"mpc/tee/chain/object/v1" 固定 25 字节,无长度前缀 +push_field("receipt") 4 字节大端长度前缀 + "receipt" +"v1" 固定 2 字节 +push_field(order_id) 变长 +push_field(decision_id) 变长 +result_hash[32] / input_hash[32] / user_data[64] +attest: 4 个 u8(user_data_ok / meas_ok / tcb_ok / chip_sig) +push_field(link) 变长(p2p / relay / unknown) +link_binding[32] +(signatures 故意不写 —— 签名是产物不是被签内容) +``` + +### ★ 「验证通过」必须拆成四句 + +`user_data_ok` / `meas_ok` / `tcb_ok` / `chip_sig` **分开报**,不许合并成一个 `ok=1`。 +`chip_sig = 否` 的含义是「**绑定成立但没做芯片验签**」,不是「没绑定」。 + +### ★ FISCO 成功判据三件套 + +``` +status == 0 ← TransactionStatus::None = 成功(与 web3 的 0x1 相反) +transactionHash 非空 ← FISCO 自有字段名,不是 txHash +blockNumber > 0 ← 进交易池但没出块时是 0,那只是「已受理未上链」 +``` + +### ★ FISCO 自有 RPC 端点(不是 web3 那套) + +| 用途 | 方法 | 参数 | +|---|---|---| +| 查回执 | `getTransactionReceipt` | 4 参 `[groupID, nodeName, txHash, requireProof]` | +| 只读调用 | `call` | 4 参 `[groupID, nodeName, to, data]`(第 5 参是**签名**不是 `"latest"`) | +| 提交交易 | `sendTransaction` | 4 参 `[groupID, nodeName, data(hex), requireProof]` | +| 链高度 | `getBlockNumber` | ★ **只接受 0 参**(`params:[]`) | + +真链对 `eth_getTransactionReceipt` / `eth_call` 一律回 `-32601`。 +**HTTP 200 ≠ 成功** —— 错误在 body 的 `error` 对象里;`result: null` = 还没出块。 + +### ★ 实测发现的边界 + +- **`recordHardRule` 的 `orderId` 长度必须 ≤ 16 字节**:17 字节起 `status=16` revert、 + output 为空。根因是 FISCO solidity 编译器对 `bytes.concat` 的长度限制。 +- **`chain contract deploy --bin` 参数被忽略**:实际读的是 `--abi` 文件, + 且要求 combined.json(`{"contracts":{...}}`)或 `{abi,bin}` 形状,裸 `.bin` 文件不认。 +- **合约调用需 `EVM_ABI_CODEC(0x1)` attribute**(写调用 attribute = 0)。 +- **selector 是二元数组** `[keccak_u32, sm3_u32]`,国密链调用用 **`SM3(signature)[0..4]`**: + `recordHardRule`=`4461f95a`、`isRecorded`=`a3414302`、`hardRuleSummary`=`73a3d38c`。 + +### ★ outbox 语义 + +- 行格式:`v1|key|state|attempts|payload_hex|last_error_hex`(6 段缺一即坏行 → **整表拒绝**)。 +- `state`:`P`(Pending) / `C`(Confirmed)。★ **Confirmed 只代表已广播,不代表已出块确认**。 +- 幂等键 = `kind:order_id:decision_id`;同键重复提交不新增、**不覆盖**。 + +### 端点 + +| 端点 | 说明 | +|---|---| +| `Device/{List,Save,Delete}` | 设备 CRUD | +| `Device/Sync` | 从控制面同步节点注册表 | +| `ChainBlock/{List,Save,Delete}` | 存证 CRUD | +| `ChainBlock/Sync` | 从真链同步(body 可带 `txHash` 查链上出块回执) | + +### 环境变量(这两个模块) + +| 变量 | 默认 | 说明 | +|---|---|---| +| `MPC_CONTROL_PLANE_URL` | `http://127.0.0.1:3020` | 控制面地址 | +| `MPC_HOSTD_SHARED_SECRET` | — | 共享密钥**原文**(非 hex) | +| `MPC_FISCO_CHAIN_CONFIG` | `../ssw-mpc/tools/fisco-realnode/example.chain.json` | 链配置(rpc_endpoint / group_id) | +| `MPC_FISCO_OUTBOX` | `/chain-outbox.txt` | outbox 路径 | +| `MPC_FISCO_NODE` | `node0` | FISCO nodeName | + +--- + +## 算子目录(19 个) + +`catalog.json` 是画布节点类型 / 端口 / 参数的唯一事实来源,7 个分类: + +| 分类 | 数量 | 算子 | +|---|---|---| +| `source` 数据接入 | 1 | `source.dataset` | +| `prep` 数据预处理 | 5 | `prep.intersect` `prep.sample` `prep.split` `prep.fillna` `prep.binning` | +| `stat` 统计分析 | 4 | `stat.profile` `stat.correlation` `stat.iv` `stat.scql` | +| `model` 联合建模 | 6 | `model.lr.train` `model.gbdt.train` `model.mlp.train` `model.fedavg.train` `model.predict` `model.evaluate` | +| `sink` 结果输出 | 1 | `sink.export`(**唯一 terminal**) | +| `tee` 机密计算 | 1 | `tee.privacy_aggregate` | +| `zkp` 零知识证明 | 1 | `zkp.prove` | + +### ssw-mpc 能力映射(诚实标注,不粉饰) + +| 状态 | 数量 | 含义 | +|---|---|---| +| `native` | 4 | 有对应 Rust CLI 子命令,可真实下发 | +| `partial` | 6 | ssw-mpc 能力部分对齐,回退模拟并写 WARN | +| `local` | 7 | 编排层职责(明文数据准备 / 统计 / 评估 / 导出),无需下发 Rust | +| `unsupported` | 1 | `model.gbdt.train`,ssw-mpc 无对应实现 | + +`native` 的 4 个:`prep.intersect`(PSI) `stat.scql`(SQL) `model.lr.train`(LR) `model.fedavg.train`(FedAvg)。 + +--- + +## 执行底座:ssw-mpc 适配层 + +**不修改 `ssw-mpc` 的 Rust 源码。** 原因: + +- `mpc-ir` 的 21 个 `Op` 是内部 IR,**无 JSON / serde 序列化**,不能由 NestJS 直接提交。 +- `mpc hostd` 只管理 TEE sandbox,**不是 DAG 提交接口**。 +- `mpc-demo` 的 HTTP 仅用于单算子参考,**不是生产执行协议**。 + +因此适配层把画布编译为 **固定 CLI argv**: + +``` +mpc psi --site alice --sites alice,bob --ids 1,2,3 +mpc lr --data-x 1,2,3,4 --data-y 0,1,1,0 --n 4 --d 2 --epochs 10 --lr 0.1 +mpc fl --clients 2 --features 4 --per-client 50 --rounds 3 +mpc sql --sql "SELECT count(*) FROM t" +``` + +整图依赖编译为 **`mpc orch run --plan`** 的文本计划: + +```text +job A +deps - +expect 35 +data alice=1,2,3 bob=4,5,6 +``` + +`orch run` 同步执行,stdout 输出稳定 NDJSON、stderr 输出进度、exit code 表示整体成败; +JSONL / `orch status` 用于崩溃恢复和审计。 + +### 环境变量 + +| 变量 | 默认 | 说明 | +|---|---|---| +| `MPC_DRIVER` | `simulation` | `mpc` 时启用 ssw-mpc 引擎并置于选路首位 | +| `MPC_REAL_EXEC` | `0` | `1` 时真实起 Rust 进程;否则只生成命令写进运行事件(可审计),产物标记 `simulated` | +| `MPC_ORCH_EXEC` | `0` | `1` 时真实执行 `mpc orch run` | +| `MPC_SITES` | `alice,bob` | 各方站点名 | +| `MPC_BIN` | `mpc` | Rust CLI 路径 | +| `MPC_WORK_DIR` | `../ssw-mpc` | ssw-mpc 仓库路径(用于探测二进制) | +| `MPC_DEMO_URL` | — | demo HTTP 算子服务地址 | + +> ⚠️ `mpc psi` / `lr` 等会话类子命令需要各方 `mpc agent` 进程在场,单进程调用会等到超时。 +> 生产部署请配合 ssw-mpc 的 deploy/ 起多方,或用 demo HTTP 算子服务。 + +--- + +## API 契约 + +路径形如 `/api/ssw/sswflow/{Entity}/{List|Save|Delete}`,返回统一 `ActionResult`: + +```json +{ "code": 200, "msg": "success", "data": { } } +``` + +前端 `request.ts` 统一解包 `data`,并处理 `600/601/602` → 清 token 跳登录。 + +sswflow 域主要端点: + +| 端点 | 说明 | +|---|---| +| `Flow/{List,Save,Delete}` | 流程 CRUD | +| `Flow/Canvas` | 保存画布(steps/edges 以 JSON 字符串落 `f_steps`/`f_edges`) | +| `Flow/Validate` | DAG 校验(返回 issues + 拓扑序) | +| `Flow/Copy` | 复制流程 | +| `Flow/CompilePlan` | 编译为 ssw-mpc 作业计划(不执行) | +| `Operator/Catalog` | 算子目录 + 每个算子的 ssw-mpc 能力状态 | +| `Engine/Info` | 引擎自检:当前驱动、Rust 二进制探测、19 算子能力分布 | +| `FlowRun/{Start,Stop,Events,Steps,Artifacts}` | 运行生命周期与可观测性 | + +菜单权限守卫按 `base_module.f_url_address` 匹配,与前端路由 path 一一对应。 + +--- + +## 迁回 JNPF 的路径 + +1. 关闭 TypeORM `synchronize`,改用 `db/schema.sql` 显式建表(已生成,Postgres 方言,13 张表)。 +2. `base_module` 表插入 14 条 sswflow 菜单(见 `sys/seed.service.ts` 的 `menus` 数组,已内置)。 +3. 实体类可平移到 JNPF 的 `SuperEntity` 子类,列名与 JNPF 原生 `f_` 契约一致,无需改名。 +4. `ActionResult` 与前端 `request.ts` 是 1:1 对应 JNPF `ResultExceptionHand` / `defHttp` 拦截器。 + +--- + +## 环境要求 + +- Node.js ≥ 18 +- 无需 Docker、无需独立 PostgreSQL(PGlite 内嵌) +- 可选:`ssw-mpc` Rust 二进制(仅 `MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` 时需要) diff --git a/docs/e2e/sswflow/README.md b/docs/e2e/sswflow/README.md new file mode 100644 index 0000000..ee1a859 --- /dev/null +++ b/docs/e2e/sswflow/README.md @@ -0,0 +1,74 @@ +# 联合反欺诈 · SSW-MPC-Flow 自动化演示 + +参考 `ssw-mvp/docs/e2e/sswflow/demo-risk-control.mjs` 的做法,在 **SSW-MPC-Flow** +(隐私计算流程编排子系统,NestJS + PGlite + React Flow)里做了一套**自包含**的端到端演示脚本。 + +> 与 ssw-mvp 版本的区别:本脚本**不依赖外部测试台底座**(`../lib/*`),登录加密、API 客户端、 +> 服务探针、场景装置全部内联在 `demo-fraud-detect.mjs` 里。因为 ssw-mpc-flow 的后端 API 与 +> ssw-mvp 不同(统一 `/{Entity}/Save|List|Delete`,Flow 额外有 `/Canvas|Validate|Start`, +> 执行引擎是 ssw-mpc Rust CLI 或本地 `simulation`),无法直接复用那套底座。 + +## 场景 + +消费金融机构想给客户做反欺诈评分,但样本薄;它联合两方做**纵向联邦建模**: + +| 参与方 | 角色 | 持有数据 | +|---|---|---| +| 电商(上海数科) | 特征方 | 交易行为 + 多头借贷特征 | +| 银行(深圳智算) | 标签方 | 授信样本 + 违约标签 | +| 消费金融(北京数安) | 数据使用方 | 发起方 & 评分卡结果接收方 | + +三方都不愿把原始数据交出去 → 用隐私计算「**数据可用不可见**」地联合建模。 + +## 演示链路 + +``` +三方入场 → 项目组建 → 数据集登记 → 授权放行 + → 画布编排(PSI 求交 → 训练/测试拆分 → 纵向 LR → 评估 → 评分卡出域) + → 执行引擎跑 DAG → 指标报告(PSI 输出行数 / 拆分比例 / AUC / KS) +``` + +## ⚠️ 关于指标真实性(务必如实告知观众) + +- 本环境默认走 **`simulation` 模拟引擎**(`MPC_DRIVER` 未开启)。模拟引擎产出的是 + **确定性占位指标**(AUC=0.8731 / KS=0.421 / 训练集 1600 / 测试集 400 行),**不是真实算力结果**。 + 脚本在开始和报告里都会**显式标注**当前引擎驱动,绝不粉饰。 +- 要跑真实 ssw-mpc 计算:设 `MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` 并起各方 `mpc agent`, + 脚本会自动识别引擎驱动为 `mpc` 并在报告里如实标注「真实 ssw-mpc」。 + +## 运行 + +```bash +# 前置:后端 30000 与前端 5173 在跑(脚本会自动探针,缺失则按需拉起;已有实例则复用,绝不重启) +cd docs/e2e/sswflow + +bash run.sh # 无头:API 直通执行引擎,出控制台 + JSON + HTML 报告 +bash run.sh --ui # 额外用浏览器打开 Flow 画布真实点击「▶ 运行」并截图 +bash run.sh --no-services # 不自动探针/拉起后端与前端(假定已在运行) +bash run.sh --backend http://x:30000 --frontend http://x:5173 --account admin --password 123456 +``` + +> 后端实际监听 **30000**(不是 3000)。登录契约:`x-www-form-urlencoded` 的 `account` + +> AES-ECB 密文密码(`encryptPassword('123456')`) + `grant_type=password`,token 在 `data.token`。 + +## 输出 + +运行后在 `docs/e2e/sswflow/results/` 下生成: + +- `fraud-detect-<时间戳>.json` —— 完整过程与指标(含引擎能力分布、步骤、产物、事件)。 +- `fraud-detect-<时间戳>.html` —— 自包含可视化报告:引擎驱动、DAG 流水线、执行指标、引擎日志。 +- `results/shots/ui-run.png` —— `--ui` 模式下的画布截图(节点已渲染 + 运行已发起)。 + +## 关键接口(脚本实际打的后端端点) + +| 步骤 | 端点 | +|---|---| +| 机构入场 | `POST /api/ssw/sswflow/Party` · `Project` · `ProjectParty` · `Datasource` · `Dataset` · `DatasetAuth` | +| 画布 | `POST /api/ssw/sswflow/Flow/Save`(含 steps/edges JSON)· `Flow/Canvas` · `Flow/Validate` | +| 执行 | `POST /api/ssw/sswflow/FlowRun/Start` · `GET /api/ssw/sswflow/FlowRun/Info` · `/Steps` · `/Artifacts` · `/Events` | +| 引擎 | `GET /api/ssw/sswflow/Engine/Info`(驱动 / ssw-mpc 探测 / 19 算子能力分布) | + +## 幂等性 + +场景实体(参与方 / 项目 / 数据源 / 数据集 / 授权)按 `code` 复用,画布按名称复用并强制以演示 +DAG 覆盖,可反复运行不会重复建实体。 diff --git a/docs/e2e/sswflow/demo-fraud-detect.mjs b/docs/e2e/sswflow/demo-fraud-detect.mjs new file mode 100755 index 0000000..6406c57 --- /dev/null +++ b/docs/e2e/sswflow/demo-fraud-detect.mjs @@ -0,0 +1,497 @@ +#!/usr/bin/env node +/** + * 联合反欺诈 · SSW-MPC-Flow 自动化演示脚本 + * ===================================================================== + * + * 在 SSW-MPC-Flow(隐私计算流程编排子系统,NestJS + PGlite + React Flow)里, + * 端到端演示一个**金融反欺诈**纵向联邦场景: + * + * 电商(特征方)持有交易行为 + 多头借贷特征; + * 银行(标签方)持有授信样本 + 违约标签; + * 两方都不愿把原始数据交出去 → 用隐私计算「数据可用不可见」地联合建模。 + * + * 链路: + * 三方入场 → 项目组建 → 数据集登记 → 授权放行 + * → 画布编排(PSI 求交 → 训练/测试拆分 → 纵向 LR → 评估 → 评分卡出域) + * → 执行引擎跑 DAG → 指标报告(命中行数 / AUC / KS / 拆分比例) + * + * 与 ssw-mvp 的 demo-risk-control.mjs 同源思路,但**自包含**(不依赖外部测试台底座): + * 登录加密、API 客户端、服务探针、场景装置全部内联在本文件。 + * + * 重要事实(必须如实告知观众): + * - 本环境默认走 **simulation 模拟引擎**(MPC_DRIVER 未开启)。模拟引擎产出的是 + * **确定性占位指标**(AUC=0.8731 / KS=0.421 / 拆分比例等),不是真实算力结果。 + * - 要跑真实 ssw-mpc 计算:设 `MPC_DRIVER=mpc` + `MPC_REAL_EXEC=1` 并起各方 `mpc agent`, + * 脚本会自动识别引擎驱动并如实标注。 + * + * 用法: + * node demo-fraud-detect.mjs # 无头:API 直通,出控制台 + JSON + HTML 报告 + * node demo-fraud-detect.mjs --ui # 额外用浏览器打开 Flow 画布真实点击「▶ 运行」 + * node demo-fraud-detect.mjs --no-services # 不自动探针/拉起后端与前端(假定已在运行) + * node demo-fraud-detect.mjs --backend http://x:30000 --frontend http://x:5173 --account admin --password 123456 + */ + +import fs from 'node:fs' +import path from 'node:path' +import net from 'node:net' +import { fileURLToPath } from 'node:url' +import { spawn } from 'node:child_process' +import { createRequire } from 'node:module' + +const require = createRequire(import.meta.url) + +const HERE = path.dirname(fileURLToPath(import.meta.url)) +const ROOT = path.resolve(HERE, '../../..') // docs/e2e/sswflow → 项目根 +const RESULT_DIR = path.join(HERE, 'results') +const SHOT_DIR = path.join(RESULT_DIR, 'shots') +const Crypto = require(path.join(ROOT, 'src/backend/node_modules/crypto-js')) + +// ----------------------------------------------------------------- 命令行 +// 模块级配置(被 login / api / ensureServices 等共享) +let O = { + ui: false, noServices: false, + backend: process.env.SSW_BE || 'http://127.0.0.1:30000', + frontend: process.env.SSW_FE || 'http://127.0.0.1:5173', + account: process.env.SSW_ACCOUNT || 'admin', + password: process.env.SSW_PASSWORD || '123456', +} +function parseArgs(argv) { + for (let i = 0; i < argv.length; i++) { + const k = argv[i] + if (k === '--ui') O.ui = true + else if (k === '--no-services') O.noServices = true + else if (k === '--backend') O.backend = argv[++i] + else if (k === '--frontend') O.frontend = argv[++i] + else if (k === '--account') O.account = argv[++i] + else if (k === '--password') O.password = argv[++i] + else if (k === '--help' || k === '-h') { printHelp(); process.exit(0) } + } +} +function printHelp() { + console.log('联合反欺诈 · SSW-MPC-Flow 自动化演示脚本') + console.log(' --ui 用浏览器打开 Flow 画布真实点击「▶ 运行」') + console.log(' --no-services 不自动探针/拉起后端与前端') + console.log(' --backend URL --frontend URL --account U --password P') +} + +// ----------------------------------------------------------------- 日志 +const logLines = [] +function log(msg) { logLines.push(msg); process.stdout.write(msg + '\n') } +const C = { reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', cyan: '\x1b[36m' } +const ok = (m) => log(` ${C.green}✓${C.reset} ${m}`) +const warn = (m) => log(` ${C.yellow}⚠${C.reset} ${m}`) +const fail = (m) => log(` ${C.red}✘${C.reset} ${m}`) +const step = (m) => log(`${C.cyan}▸${C.reset} ${C.bold}${m}${C.reset}`) + +// ----------------------------------------------------------------- 极简 API 客户端(与前端 request.ts 同源) +let TOKEN = null +function beUrl(p) { return p.startsWith('http') ? p : O.backend + (p.startsWith('/api') ? '' : '/api') + p } +function enc(pwd) { + const k = Crypto.enc.Utf8.parse(Crypto.MD5('EY8WePvjM5GGwQzn').toString()) + const s = Crypto.enc.Utf8.parse(Crypto.MD5(pwd).toString()) + return Crypto.AES.encrypt(s, k, { mode: Crypto.mode.ECB, padding: Crypto.pad.Pkcs7 }).ciphertext.toString(Crypto.enc.Hex) +} +async function login(account, password) { + const form = new URLSearchParams({ account, password: enc(password), grant_type: 'password' }) + const res = await fetch(`${O.backend}/api/oauth/Login`, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'App-Code': 'sswflow', 'Jnpf-Origin': 'pc' }, + body: form.toString(), + }) + const j = await res.json().catch(() => ({})) + if (j.code !== 200 || !j.data?.token) throw new Error(`登录失败:code=${j.code} msg=${j.msg || res.status}`) + TOKEN = j.data.token.startsWith('bearer ') ? j.data.token : `bearer ${j.data.token}` + return TOKEN +} +async function api(method, url, body) { + const upper = method.toUpperCase() + const safeBody = (upper === 'GET' || upper === 'HEAD') ? undefined : body + const res = await fetch(`${O.backend}${url.startsWith('http') ? '' : ''}${url}`, { + method: upper, + headers: { + Authorization: TOKEN, + 'App-Code': 'sswflow', 'Jnpf-Origin': 'pc', + ...(safeBody ? { 'Content-Type': 'application/json' } : {}), + }, + ...(safeBody ? { body: JSON.stringify(safeBody) } : {}), + }) + return res.json().catch(() => ({})) +} +function unwrap(r) { + // ActionResult:data 解包;错误时 r.code !== 200 + if (r && r.code !== undefined && r.code !== 200) throw new Error(r.msg || `code=${r.code}`) + return r?.data !== undefined ? r.data : r +} +async function apiList(url) { + const r = await api('GET', url) + const d = unwrap(r) + return Array.isArray(d) ? d : (d?.list ?? d?.records ?? []) +} + +// ----------------------------------------------------------------- 服务探针 + 按需拉起 +function ping(host, port) { + return new Promise((resolve) => { + const s = net.connect({ host, port, timeout: 800 }) + s.once('connect', () => { s.destroy(); resolve(true) }) + s.once('error', () => resolve(false)) + s.once('timeout', () => { s.destroy(); resolve(false) }) + }) +} +function hostPort(u) { + try { const uu = new URL(u); return { host: uu.hostname, port: Number(uu.port) } } + catch { return { host: '127.0.0.1', port: 30000 } } +} +async function ensureServices() { + const be = hostPort(O.backend) + const fe = hostPort(O.frontend) + const beUp = await ping(be.host, be.port) + const feUp = await ping(fe.host, fe.port) + log(` 后端 ${O.backend}:${beUp ? C.green + '在线' : C.yellow + '未就绪'}${C.reset} · 前端 ${O.frontend}:${feUp ? C.green + '在线' : C.yellow + '未就绪' + C.reset}`) + if (O.noServices) { + if (!beUp) warn('已指定 --no-services 但后端未就绪,演示可能无法执行真实计算。') + return + } + if (!beUp) { + step('拉起后端(node dist/main.js)') + const child = spawn('node', ['dist/main.js'], { cwd: path.join(ROOT, 'src/backend'), detached: true, stdio: 'ignore' }) + child.unref() + for (let i = 0; i < 30; i++) { if (await ping(be.host, be.port)) break; await sleep(500) } + ok(await ping(be.host, be.port) ? '后端已就绪' : '后端启动超时(请手动检查)') + } + if (!feUp) { + step('拉起前端(vite dev)') + const child = spawn('node', ['node_modules/vite/bin/vite.js', '--port', String(fe.port), '--host', fe.host], { cwd: path.join(ROOT, 'src/frontend'), detached: true, stdio: 'ignore' }) + child.unref() + for (let i = 0; i < 30; i++) { if (await ping(fe.host, fe.port)) break; await sleep(500) } + ok(await ping(fe.host, fe.port) ? '前端已就绪' : '前端启动超时(请手动检查)') + } +} +function sleep(ms) { return new Promise((r) => setTimeout(r, ms)) } + +// ----------------------------------------------------------------- 场景装置(幂等:按 code 复用,避免重复污染) +const PROJECT_CODE = 'DEMO-PRJ-FRAUD' +const FLOW_NAME = '联合反欺诈模型训练 · 自动化演示' + +const PARTIES = [ + { partyCode: 'DEMO-P01', name: '上海数科(电商)', orgName: '上海数科信息科技有限公司', endpoint: 'https://shdsk.internal:8443', role: 'participant', status: 'ACTIVE', selfMark: 0, computeMode: 'MPC', desc: '特征方:交易行为 + 多头借贷' }, + { partyCode: 'DEMO-P02', name: '深圳智算(银行)', orgName: '深圳智算科技有限公司', endpoint: 'https://szzk.internal:8443', role: 'initiator', status: 'ACTIVE', selfMark: 1, computeMode: 'MPC', desc: '标签方:授信样本 + 违约标签' }, + { partyCode: 'DEMO-P03', name: '北京数安(消费金融)', orgName: '北京数安研究院', endpoint: 'https://bjsan.internal:8443', role: 'participant', status: 'ACTIVE', selfMark: 0, computeMode: 'TEE', desc: '数据使用方:结果接收方' }, +] +const DATASETS = [ + { datasetCode: 'DEMO-DS01', name: '电商交易明细', partyAlias: 'DEMO-P01', datasourceName: '电商交易库', storageType: 'MySQL', location: 'ods.trade_detail', rowCount: 1280000, externalRef: 'trade_detail_demo', desc: '订单与支付流水' }, + { datasetCode: 'DEMO-DS02', name: '银行授信申请', partyAlias: 'DEMO-P02', datasourceName: '银行信贷库', storageType: 'PostgreSQL', location: 'public.credit_apply', rowCount: 860000, externalRef: 'credit_apply_demo', desc: '授信与还款记录' }, +] + +async function ensureScene() { + // 参与方(按 partyCode 复用) + const parties = await apiList('/api/ssw/sswflow/Party/List') + const partyIds = {} + for (const p of PARTIES) { + let found = parties.find((x) => x.partyCode === p.partyCode) + if (!found) { const r = unwrap(await api('POST', '/api/ssw/sswflow/Party/Save', p)); found = r } + partyIds[p.partyCode] = found.id + } + ok(`参与方就位:${PARTIES.map((p) => `${p.name}=${partyIds[p.partyCode]}`).join(' · ')}`) + + // 项目 + const projects = await apiList('/api/ssw/sswflow/Project/List') + let project = projects.find((x) => x.projectCode === PROJECT_CODE) + if (!project) project = unwrap(await api('POST', '/api/ssw/sswflow/Project/Save', { + projectCode: PROJECT_CODE, name: '联合反欺诈建模', desc: '电商 + 银行联合反欺诈模型', ownerPartyId: partyIds['DEMO-P02'], computeMode: 'MPC', status: 'RUNNING', + })) + ok(`协作项目已建立 projectId=${project.id}`) + + // 项目成员 + for (const p of PARTIES) { + await api('POST', '/api/ssw/sswflow/ProjectParty/Save', { + projectId: project.id, partyId: partyIds[p.partyCode], + role: p.partyCode === 'DEMO-P02' ? 'owner' : 'participant', + joinStatus: p.partyCode === 'DEMO-P02' ? 'JOINED' : 'INVITED', + }) + } + ok('项目成员关系已建立(授权需全票通过)') + + // 数据源(按 name 复用) + const dss = await apiList('/api/ssw/sswflow/Datasource/List') + const dsIds = {} + for (const d of DATASETS) { + let found = dss.find((x) => x.name === d.datasourceName) + if (!found) found = unwrap(await api('POST', '/api/ssw/sswflow/Datasource/Save', { + name: d.datasourceName, partyId: partyIds[d.partyAlias], type: d.storageType === 'MySQL' ? 'MySQL' : 'PostgreSQL', status: 'ONLINE', desc: d.desc, + })) + dsIds[d.datasourceName] = found.id + } + + // 数据集(按 datasetCode 复用) + const dsList = await apiList('/api/ssw/sswflow/Dataset/List') + const datasetIds = {} + for (const d of DATASETS) { + let found = dsList.find((x) => x.datasetCode === d.datasetCode) + if (!found) found = unwrap(await api('POST', '/api/ssw/sswflow/Dataset/Save', { + datasetCode: d.datasetCode, name: d.name, partyId: partyIds[d.partyAlias], + datasourceId: dsIds[d.datasourceName], storageType: d.storageType, location: d.location, rowCount: d.rowCount, externalRef: d.externalRef, + })) + datasetIds[d.datasetCode] = found.id + } + ok(`数据集登记:${DATASETS.map((d) => d.name).join(' · ')}(平台不落原始数据,只登记血缘)`) + + // 授权(按 数据集+项目 复用,直接 APPROVED) + const auths = await apiList('/api/ssw/sswflow/DatasetAuth/List') + for (const d of DATASETS) { + const exist = auths.find((x) => x.datasetId === datasetIds[d.datasetCode] && x.projectId === project.id) + if (!exist) { + unwrap(await api('POST', '/api/ssw/sswflow/DatasetAuth/Save', { + datasetId: datasetIds[d.datasetCode], projectId: project.id, authStatus: 'APPROVED', + authUserId: 'admin', expireTime: new Date(Date.now() + 90 * 864e5).toISOString(), + })) + } + } + const auths2 = await apiList('/api/ssw/sswflow/DatasetAuth/List') + const approved = auths2.filter((x) => x.projectId === project.id && x.authStatus === 'APPROVED') + ok(`数据集授权通过 ${approved.length} 份(未授权的数据在项目里不可见)`) + + return { partyIds, projectId: project.id, datasetIds } +} + +// ----------------------------------------------------------------- 画布编排(联合反欺诈 DAG,端口 key 与后端校验器逐字对应) +function fraudCanvas(scene) { + const trade = scene.datasetIds['DEMO-DS01'] + const credit = scene.datasetIds['DEMO-DS02'] + return { + steps: [ + { stepId: 'src-trade', operatorKey: 'source.dataset', label: '电商交易明细', x: 40, y: 60, params: { datasetId: trade } }, + { stepId: 'src-credit', operatorKey: 'source.dataset', label: '银行授信申请', x: 40, y: 240, params: { datasetId: credit } }, + { stepId: 'psi', operatorKey: 'prep.intersect', label: '隐私求交(PSI)', x: 300, y: 150, params: { leftKeys: ['user_id'], rightKeys: ['cust_no'], protocol: 'ECDH', receiver: 'shdsk', keepOrder: true } }, + { stepId: 'split', operatorKey: 'prep.split', label: '训练/测试拆分', x: 560, y: 150, params: { testRatio: 0.2 } }, + { stepId: 'lr', operatorKey: 'model.lr.train', label: '纵向逻辑回归', x: 820, y: 60, params: { labelColumn: 'is_fraud', n: 64, d: 16, epochs: 30, learningRate: 0.05 } }, + { stepId: 'eval', operatorKey: 'model.evaluate', label: '模型评估', x: 820, y: 240, params: { labelColumn: 'is_fraud' } }, + { stepId: 'export', operatorKey: 'sink.export', label: '评分卡出域', x: 1080, y: 150, params: { targetParty: 'shdsk', fileName: 'fraud_lr_model.bin' } }, + ], + edges: [ + { edgeId: 'e1', sourceStepId: 'src-trade', sourcePort: 'out', targetStepId: 'psi', targetPort: 'left' }, + { edgeId: 'e2', sourceStepId: 'src-credit', sourcePort: 'out', targetStepId: 'psi', targetPort: 'right' }, + { edgeId: 'e3', sourceStepId: 'psi', sourcePort: 'out', targetStepId: 'split', targetPort: 'in' }, + { edgeId: 'e4', sourceStepId: 'split', sourcePort: 'train', targetStepId: 'lr', targetPort: 'in' }, + { edgeId: 'e5', sourceStepId: 'split', sourcePort: 'test', targetStepId: 'eval', targetPort: 'in' }, + { edgeId: 'e6', sourceStepId: 'lr', sourcePort: 'model', targetStepId: 'export', targetPort: 'in' }, + ], + } +} +async function ensureFlow(scene) { + const flows = await apiList('/api/ssw/sswflow/Flow/List') + let flow = flows.find((x) => x.name === FLOW_NAME) + const canvas = fraudCanvas(scene) + if (!flow) { + flow = unwrap(await api('POST', '/api/ssw/sswflow/Flow/Save', { + name: FLOW_NAME, desc: '电商交易 + 银行授信 → 隐私求交 → 纵向LR → 评估 → 导出', projectId: scene.projectId, + steps: JSON.stringify(canvas.steps), edges: JSON.stringify(canvas.edges), + })) + } else { + // 复用既有时,强制以演示 DAG 覆盖画布,保证端口语义正确 + unwrap(await api('POST', '/api/ssw/sswflow/Flow/Canvas', { + id: flow.id, steps: canvas.steps, edges: canvas.edges, + })) + } + return flow.id +} + +// ----------------------------------------------------------------- 运行 + 轮询 +async function runFlow(flowId, maxWaitMs = 240000) { + const start = await api('POST', '/api/ssw/sswflow/FlowRun/Start', { flowId, trigger: 'MANUAL', mode: 'FULL' }) + const run = unwrap(start) + const runId = run.id + const t0 = Date.now() + let last = null + while (Date.now() - t0 < maxWaitMs) { + await sleep(800) + last = unwrap(await api('GET', `/api/ssw/sswflow/FlowRun/Info?id=${runId}`)) + if (['SUCCESS', 'FAILED', 'STOPPED'].includes(last.status)) break + } + const steps = unwrap(await api('GET', `/api/ssw/sswflow/FlowRun/Steps?runId=${runId}`)) + const artifacts = unwrap(await api('GET', `/api/ssw/sswflow/FlowRun/Artifacts?runId=${runId}`)) + const events = unwrap(await api('GET', `/api/ssw/sswflow/FlowRun/Events?runId=${runId}`)) + return { runId, status: last?.status, costMs: last?.costMs || 0, steps, artifacts, events } +} +function findArtifact(artifacts, stepId, portKey) { + return artifacts.find((a) => a.stepId === stepId && a.portKey === portKey) || null +} +function metricsOf(a) { + if (!a) return {} + try { return typeof a.metrics === 'string' ? JSON.parse(a.metrics) : (a.metrics || {}) } catch { return {} } +} +function extractMetrics(run) { + const psi = findArtifact(run.artifacts, 'psi', 'out') + const train = findArtifact(run.artifacts, 'split', 'train') + const test = findArtifact(run.artifacts, 'split', 'test') + const lr = findArtifact(run.artifacts, 'lr', 'model') + const evalA = findArtifact(run.artifacts, 'eval', 'report') + return { + psi: { intersection: metricsOf(psi).intersection, rowCount: psi?.rowCount }, + split: { trainRows: train?.rowCount, testRows: test?.rowCount }, + model: metricsOf(lr), + evaluate: metricsOf(evalA), + engineLog: (run.events || []).slice(0, 8).map((e) => e.message).join(' · ').slice(0, 400), + } +} + +// ----------------------------------------------------------------- UI 演示(agent-browser 真实点击「▶ 运行」) +function agentBrowser() { + // 优先用 PATH,其次用本机常见位置 + const cand = ['agent-browser', '/Users/xs/.npm-global/bin/agent-browser'] + for (const c of cand) { + try { const p = require('child_process').execSync(`command -v "${c}" || true`).toString().trim(); if (p) return p } catch {} + } + return 'agent-browser' +} +async function uiDemo(ctx) { + const ab = agentBrowser() + const shots = [] + const run = (...args) => new Promise((res) => { + const c = spawn(ab, args, { cwd: HERE }) + let out = '' + c.stdout.on('data', (d) => (out += d)) + c.stderr.on('data', (d) => (out += d)) + c.on('close', () => res(out)) + }) + step('UI 演示:用浏览器打开 Flow 画布真实点击「▶ 运行」') + fs.mkdirSync(SHOT_DIR, { recursive: true }) + try { + await run('open', O.frontend) + await sleep(2500) + // 注入登录态(前端 token 存 localStorage['ssw_token'],带 bearer 前缀) + await run('eval', `(()=>{localStorage.setItem('ssw_token','${TOKEN}');location.href='${O.frontend}/sswflow/Flow';})()`) + await sleep(3000) + const nodeCount = await run('eval', "document.querySelectorAll('.react-flow__node').length") + ok(`画布上渲染出 ${String(nodeCount).trim()} 个节点(PSI → 拆分 → 纵向LR → 评估 → 出域)`) + await run('eval', `(async()=>{const b=[...document.querySelectorAll('button')].find(x=>x.textContent.trim()==='▶ 运行');if(b)b.click();})()`) + await sleep(2500) + await run('screenshot', path.join(SHOT_DIR, 'ui-run.png')) + shots.push(path.join(SHOT_DIR, 'ui-run.png')) + ok('已真实点击「▶ 运行」并截图') + } catch (e) { + warn(`UI 演示异常(不影响 API 真实计算链路):${e.message.slice(0, 120)}`) + } + return { shots } +} + +// ----------------------------------------------------------------- HTML 报告 +function htmlReport(rec) { + const m = rec.metrics || {} + const metricRow = (k, v, note) => `${k}${v ?? '-'}${note ? `${note}` : ''}` + const pipeline = ['电商交易', '银行授信', 'PSI 求交', '拆分', '纵向LR', '评估', '出域'] + const dag = pipeline.map((p, i) => (i ? '
→
' : '') + `
${p}
`).join('') + const engineTag = rec.engine.driver === 'mpc' + ? `
执行引擎:真实 ssw-mpc(MPC_DRIVER=mpc)
` + : `
执行引擎:simulation 模拟(MPC_DRIVER 未开启,指标为确定性占位,非真实算力)
` + return `联合反欺诈 · SSW-MPC-Flow 演示报告 +
+

联合反欺诈 · SSW-MPC-Flow 演示报告

+
${rec.at} · 场景:${FLOW_NAME} · 纵向联邦 · 数据可用不可见
+
+
演示结论:${rec.verdict === 'PASS' ? '通过 · 联合反欺诈链路贯通' : rec.verdict}
+ ${engineTag} +
运行 ID:${rec.runId || '-'} · 耗时:${rec.costMs || 0} ms · 状态:${rec.status} · 步骤:${rec.stepCount ?? '-'}/${rec.stepTotal ?? '-'}
+
+

隐私计算 DAG

${dag}
+

执行指标

+ ${metricRow('PSI 求交命中行数(两方共同客户)', m.psi?.intersection, m.psi?.rowCount != null ? `输出行数 ${m.psi.rowCount}` : '')} + ${metricRow('训练集行数', m.split?.trainRows)} + ${metricRow('测试集行数', m.split?.testRows)} + ${metricRow('训练 AUC', m.model?.auc)} + ${metricRow('训练 Loss', m.model?.loss)} + ${metricRow('测试 AUC', m.evaluate?.auc)} + ${metricRow('测试 KS', m.evaluate?.ks)} +
+

引擎日志(节选)

${m.engineLog || '(无)'}
+ ${rec.ui && rec.ui.shots?.length ? `

UI 演示截图

${rec.ui.shots.map((s) => ``).join('')}
` : ''} +
` +} + +// ----------------------------------------------------------------- 主流程 +async function main() { + const argv = process.argv.slice(2) + const a = parseArgs(argv) + fs.mkdirSync(RESULT_DIR, { recursive: true }) + const ts = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19) + log(`${C.bold}═══ 联合反欺诈 · SSW-MPC-Flow 自动化演示 ═══${C.reset}`) + log(`后端 ${O.backend} · 前端 ${O.frontend} · 账号 ${O.account}`) + + await ensureServices() + await login(O.account, O.password) + ok(`已登录 ${O.account}`) + + const rec = { at: new Date().toISOString(), verdict: 'PASS', runId: null, metrics: null, ui: null } + + const engine = unwrap(await api('GET', '/api/ssw/sswflow/Engine/Info')) + rec.engine = engine + log(` 执行引擎驱动:${engine.driver === 'mpc' ? C.green + '真实 ssw-mpc' : C.yellow + 'simulation 模拟' + C.reset}(native=${engine.summary.native} partial=${engine.summary.partial} local=${engine.summary.local} unsupported=${engine.summary.unsupported})`) + + // 1) 场景 + let scene + await (async () => { + step('① 机构入场:电商(特征方) / 银行(标签方) / 消费金融(使用方) 三方登记,组建联合建模项目') + scene = await ensureScene() + })() + + // 2) 画布 + await (async () => { + step('② 画布编排:PSI 求交 → 拆分 → 纵向 LR → 评估 → 出域') + const flowId = await ensureFlow(scene) + const vr = unwrap(await api('POST', '/api/ssw/sswflow/Flow/Validate', { id: flowId })) + const valid = vr?.valid ?? vr?.data?.valid ?? vr?.data?.success + const errs = vr?.errors ?? vr?.issues ?? vr?.data?.errors ?? [] + ok(`画布校验${valid ? '通过' : '未通过'}(${fraudCanvas(scene).steps.length} 个节点${errs.length ? ';' + errs.join(';') : ''})`) + rec.flowId = flowId + rec.projectId = scene.projectId + })() + + // 3) UI 演示(可选) + if (O.ui) { + try { rec.ui = await uiDemo(scene) } catch (e) { rec.ui = { shots: [], error: e.message.slice(0, 200) }; fail(`UI 演示未通过:${e.message.slice(0, 160)}`) } + } + + // 4) 执行 + await (async () => { + step('③ 真实执行:执行引擎跑 DAG(默认 simulation,可切真实 ssw-mpc)') + const run = await runFlow(rec.flowId) + const m = extractMetrics(run) + rec.runId = run.runId; rec.status = run.status; rec.costMs = run.costMs + rec.metrics = m + rec.stepCount = run.steps.filter((s) => s.status === 'SUCCESS').length + rec.stepTotal = run.steps.length + if (run.status !== 'SUCCESS') { fail(`联合建模执行未成功(status=${run.status})`); rec.verdict = run.status || 'FAIL' } + else { + ok(`执行成功(status=${run.status},耗时 ${run.costMs} ms,${rec.stepCount}/${rec.stepTotal} 步骤 SUCCESS)`) + ok(`PSI 输出 ${m.psi.rowCount} 行(模拟引擎:两源各 1000 行并集占位;真实 ssw-mpc 会算真实交集)`) + ok(`训练集 ${m.split.trainRows} 行 / 测试集 ${m.split.testRows} 行(8:2 拆分)`) + ok(`纵向LR AUC=${m.model.auc} Loss=${m.model.loss} · 评估 AUC=${m.evaluate.auc} KS=${m.evaluate.ks}`) + } + })() + + // 5) 报告落盘 + const jsonPath = path.join(RESULT_DIR, `fraud-detect-${ts}.json`) + fs.writeFileSync(jsonPath, JSON.stringify(rec, null, 2)) + const htmlPath = path.join(RESULT_DIR, `fraud-detect-${ts}.html`) + fs.writeFileSync(htmlPath, htmlReport(rec)) + log('') + log(`${C.bold}═══ 演示完成 ═══${C.reset}`) + log(`JSON 报告:${jsonPath}`) + log(`HTML 报告:${htmlPath}`) +} + +main().catch((e) => { + fail(`演示中断:${e.message}`) + log(e.stack?.split('\n').slice(0, 4).join('\n')) + process.exit(1) +}) diff --git a/docs/e2e/sswflow/run.sh b/docs/e2e/sswflow/run.sh new file mode 100755 index 0000000..76a29f1 --- /dev/null +++ b/docs/e2e/sswflow/run.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# 联合反欺诈 · SSW-MPC-Flow 自动化演示 启动器 +# 用法:bash run.sh [--ui] [--no-services] ...(其余参数透传给 demo-fraud-detect.mjs) +set -e +cd "$(dirname "$0")" +NODE="${NODE:-node}" +echo "▶ 联合反欺诈 · SSW-MPC-Flow 演示(docs/e2e/sswflow)" +exec "$NODE" demo-fraud-detect.mjs "$@" diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..b8b0efa --- /dev/null +++ b/run.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +# ssw-jnpf-lite-react MVP 一键脚本 +# 数据库为嵌入式 PGlite(WASM Postgres,零服务 / 零 docker),无需先起 PG。 +# 用法: +# ./run.sh install 安装前后端依赖 +# ./run.sh build 构建前后端(并重新生成 db/schema.sql) +# ./run.sh schema 从实体定义重新生成 db/schema.sql +# ./run.sh dev 同时起后端(30000) + 前端(5173),输出到 .logs/,PID 写入 .logs/*.pid +# ./run.sh backend 只起后端 +# ./run.sh frontend 只起前端 +# ./run.sh stop 用 PID 文件停后台进程 + 兜底 kill_ports +# ./run.sh logs tail .logs/{backend,frontend}.log +# ./run.sh --help 本用法 +# 退出码:0 成功 / 1 运行期失败 / 2 用法错 +set -e +ROOT="$(cd "$(dirname "$0")" && pwd)" +LOGS="$ROOT/.logs" + +# 加载项目根 .env(backend 代码不 import dotenv,靠这里把 PGLLITE_DIR/PORT/PG_SYNC 等导出给子进程) +if [ -f "$ROOT/.env" ]; then + set -a; . "$ROOT/.env"; set +a +fi + +usage() { + sed -n '4,14p' "$0" | sed 's/^# \{0,1\}//' +} + +# 端口守护:dev/start 前清掉残留进程,避免 EADDRINUSE 被静默吞掉(旧进程仍占端口, +# 新进程崩溃但请求全部打到旧实例 → 看起来「改了 seed 但菜单不变」之类的灵异 bug)。 +kill_ports() { + local killed=0 + for p in "$@"; do + local pids + pids="$(lsof -ti:"$p" 2>/dev/null || true)" + if [ -n "$pids" ]; then + echo " ↳ 端口 $p 被旧进程占用 (PID: $pids),清理中…" + # shellcheck disable=SC2086 + kill -9 $pids 2>/dev/null || true + killed=1 + fi + done + # 注意 set -e:端口空闲时 [ ] 返回 1 会炸掉调用方(dev 走不到 start_logged) + [ "$killed" -eq 1 ] && sleep 1 + return 0 +} + +# 用 PID 文件优雅停(先 SIGTERM,1s 后 SIGKILL),清理 root 进程树 +stop_pid() { + local f="$1" + [ -f "$f" ] || return 0 + local pid + pid="$(cat "$f" 2>/dev/null || true)" + if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then + echo " ↳ stop $(basename "$f") PID=$pid SIGTERM" + kill -TERM "$pid" 2>/dev/null || true + sleep 1 + kill -0 "$pid" 2>/dev/null && kill -KILL "$pid" 2>/dev/null || true + fi + rm -f "$f" +} + +# 用 nohup 后台起,stdout/stderr 都进日志;写 PID 便于 ./run.sh stop 精准收 +start_logged() { + local dir="$1" cmd="$2" name="$3" + mkdir -p "$LOGS" + : > "$LOGS/${name}.log" + ( + cd "$ROOT/$dir" || exit 1 + # nohup + & 把子进程从父进程会话脱离,CI/harness 退出不会拖垮服务; + # setsid 让子进程成为新进程组领头,避免父 SIGINT 误杀。 + # macOS 无 setsid(Linux util-linux 专有),探测后回退纯 nohup。 + if command -v setsid >/dev/null 2>&1; then + setsid nohup $cmd > "$LOGS/${name}.log" 2>&1 & + else + nohup $cmd > "$LOGS/${name}.log" 2>&1 & + fi + echo $! > "$LOGS/${name}.pid" + ) + echo " ↳ $name PID=$(cat "$LOGS/${name}.pid") log=$LOGS/${name}.log" +} + +case "${1:-}" in + -h|--help|help) + usage + ;; + install) + (cd "$ROOT/src/backend" && npm install) + (cd "$ROOT/src/frontend" && npm install) + ;; + build) + node "$ROOT/scripts/gen-schema.js" + (cd "$ROOT/src/backend" && npm run build) + (cd "$ROOT/src/frontend" && npm run build) + ;; + schema) + node "$ROOT/scripts/gen-schema.js" + ;; + dev) + kill_ports 30000 5173 + start_logged src/backend "npm run start:dev" backend + start_logged src/frontend "npm run dev" frontend + echo + echo "服务已在后台启动。日志:tail -f $LOGS/{backend,frontend}.log" + echo "停止:./run.sh stop" + ;; + backend) + kill_ports 30000 + (cd "$ROOT/src/backend" && npm run start:dev) + ;; + frontend) + kill_ports 5173 + (cd "$ROOT/src/frontend" && npm run dev) + ;; + stop) + stop_pid "$LOGS/backend.pid" + stop_pid "$LOGS/frontend.pid" + kill_ports 30000 5173 + pkill -f "nest start" 2>/dev/null || true + pkill -f "vite" 2>/dev/null || true + echo "stopped" + ;; + logs) + [ -f "$LOGS/backend.log" ] && echo "=== backend ===" && tail -n 50 "$LOGS/backend.log" + [ -f "$LOGS/frontend.log" ] && echo "=== frontend ===" && tail -n 50 "$LOGS/frontend.log" + ;; + *) + usage + exit 2 + ;; +esac \ No newline at end of file diff --git a/scripts/check-canvas-ports.js b/scripts/check-canvas-ports.js new file mode 100644 index 0000000..a5b42e2 --- /dev/null +++ b/scripts/check-canvas-ports.js @@ -0,0 +1,175 @@ +#!/usr/bin/env node +/** + * 画布端口落库校验: + * 1. 用 JNPF 登录契约(x-www-form-urlencoded + AES 密文密码)拿到 token + * 2. 拉 Flow/List,读回 f_steps / f_edges + * 3. 断言多端口算子(prep.intersect / prep.split / model.predict)的 + * sourcePort / targetPort 与 catalog.json 的端口 key 逐字一致 + * + * 用法:node scripts/check-canvas-ports.js [baseUrl] + */ +const CryptoJS = require('../src/frontend/node_modules/crypto-js'); +const fs = require('fs'); +const path = require('path'); + +const BASE = process.argv[2] || 'http://127.0.0.1:30000'; +const API = `${BASE}/api`; +const CIPHER_KEY = 'EY8WePvjM5GGwQzn'; + +const md5 = (s) => CryptoJS.MD5(s).toString(); +function encryptPassword(plain) { + const key = CryptoJS.enc.Utf8.parse(md5(CIPHER_KEY)); + const src = CryptoJS.enc.Utf8.parse(md5(plain)); + return CryptoJS.AES.encrypt(src, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }).ciphertext.toString(CryptoJS.enc.Hex); +} + +async function http(url, opts = {}) { + const res = await fetch(url, { ...opts, signal: AbortSignal.timeout(15000) }); + const text = await res.text(); + let json = null; + try { + json = JSON.parse(text); + } catch { + /* 非 JSON */ + } + return { status: res.status, json, text }; +} + +function parseArray(v) { + if (!v) return []; + if (Array.isArray(v)) return v; + try { + const p = JSON.parse(v); + return Array.isArray(p) ? p : []; + } catch { + return []; + } +} + +const CATALOG_PATH = path.join(__dirname, '../src/backend/src/sswflow/catalog/catalog.json'); + +(async () => { + let pass = 0; + let fail = 0; + const ok = (name) => { + pass++; + console.log(` ok ${name}`); + }; + const bad = (name, detail) => { + fail++; + console.log(` FAIL ${name}${detail ? ' :: ' + detail : ''}`); + }; + + // ---- 登录 ---- + const body = new URLSearchParams(); + body.set('account', 'admin'); + body.set('password', encryptPassword('123456')); + body.set('grant_type', 'password'); + const login = await http(`${API}/oauth/Login`, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: body.toString(), + }); + const token = login.json && login.json.data && login.json.data.token; + if (!token) { + console.log('登录失败,无法校验:', login.status, login.text.slice(0, 300)); + process.exit(1); + } + console.log('登录成功\n'); + + const auth = { Authorization: `Bearer ${token}` }; + + // ---- 拉流程 ---- + const flows = await http(`${API}/ssw/sswflow/Flow/List`, { + headers: auth, + }); + const raw = flows.json && flows.json.data; + const list = Array.isArray(raw) ? raw : (raw && raw.list) || []; + if (!list.length) { + console.log('流程列表为空,无法校验'); + process.exit(1); + } + console.log(`流程数:${list.length}`); + + // ---- catalog 端口事实源 ---- + const catalog = JSON.parse(fs.readFileSync(CATALOG_PATH, 'utf8')); + const opMap = new Map(); + for (const cat of catalog.categories || []) { + for (const op of cat.operators || []) opMap.set(op.key, op); + } + + let multiPortEdges = 0; + let edgeTotal = 0; + + for (const f of list) { + const steps = parseArray(f.steps); + const edges = parseArray(f.edges); + const stepMap = new Map(steps.map((s) => [s.stepId, s])); + edgeTotal += edges.length; + + console.log(`\n[${f.name}] steps=${steps.length} edges=${edges.length}`); + + for (const e of edges) { + const src = stepMap.get(e.sourceStepId); + const tgt = stepMap.get(e.targetStepId); + if (!src || !tgt) { + bad('边端点存在', `${e.edgeId} 引用了不存在的 step`); + continue; + } + const srcOp = opMap.get(src.operatorKey); + const tgtOp = opMap.get(tgt.operatorKey); + const srcPorts = (srcOp && srcOp.outputs || []).map((p) => p.key); + const tgtPorts = (tgtOp && tgtOp.inputs || []).map((p) => p.key); + + // sourcePort / targetPort 必须命中 catalog 端口 + if (srcPorts.length && !srcPorts.includes(e.sourcePort)) { + bad('sourcePort 合法', `${src.operatorKey}.${e.sourcePort} 不在 [${srcPorts}]`); + continue; + } + if (tgtPorts.length && !tgtPorts.includes(e.targetPort)) { + bad('targetPort 合法', `${tgt.operatorKey}.${e.targetPort} 不在 [${tgtPorts}]`); + continue; + } + if (srcPorts.length > 1 || tgtPorts.length > 1) { + multiPortEdges++; + console.log( + ` 多端口边 ${e.edgeId}: ${src.operatorKey}[${e.sourcePort}] -> ${tgt.operatorKey}[${e.targetPort}]`, + ); + } + } + if (fail === 0) ok(`${f.name} 的 ${edges.length} 条边端口全部命中 catalog`); + } + + console.log(`\n合计边数 ${edgeTotal},其中涉及多端口算子的 ${multiPortEdges} 条`); + + // ---- 端口覆盖检查:多端口算子的每个必填输入端口是否都有连线 ---- + for (const f of list) { + const steps = parseArray(f.steps); + const edges = parseArray(f.edges); + const stepMap = new Map(steps.map((s) => [s.stepId, s])); + for (const s of steps) { + const op = opMap.get(s.operatorKey); + if (!op) continue; + const requiredInputs = (op.inputs || []).filter((p) => p.required); + for (const p of requiredInputs) { + const hit = edges.some( + (e) => e.targetStepId === s.stepId && e.targetPort === p.key, + ); + if (!hit) { + console.log( + ` note 流程「${f.name}」的 ${s.operatorKey} 必填输入端口 ${p.key} 尚未连线`, + ); + } + } + } + } + + console.log(`\n结果:${pass} 通过 / ${fail} 失败`); + process.exit(fail === 0 ? 0 : 1); +})().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/scripts/check-module.sh b/scripts/check-module.sh new file mode 100755 index 0000000..dfd31e7 --- /dev/null +++ b/scripts/check-module.sh @@ -0,0 +1,280 @@ +#!/usr/bin/env bash +# ssw-jnpf-lite-react 加业务模块的「接触点」静态自检 +# +# 目的:在跑 perm-smoke 之前,**快速发现漏改的文件或字符串不一致**——这类问题一旦漏掉, +# 表现是「菜单不显示」「页面 404」「权限静默放行」,非常难定位。 +# +# 用法: +# bash scripts/check-module.sh ... # 静态检查(1 个或多个 Entity) +# bash scripts/check-module.sh ... --live # 额外实跑后端 +# bash scripts/check-module.sh --all [--live] # 自动扫 src/backend/src/${appCode}/*.entity.ts +# +# 例: +# bash scripts/check-module.sh books Book # 单 Entity(向后兼容) +# bash scripts/check-module.sh shoes Shoe Order # 同 appCode 多 Entity(一次跑完) +# bash scripts/check-module.sh shoes --all # 自动探测 Shoe + Order +# bash scripts/check-module.sh --help # 本用法 +# +# 退出码:0 全过 / 1 有 ❌ 项 / 2 用法错(参数不足 / --all 没探到 Entity) + +set -u + +usage() { + echo "用法: bash scripts/check-module.sh ... [--live]" + echo " bash scripts/check-module.sh --all [--live]" + echo "例: bash scripts/check-module.sh books Book" + echo " bash scripts/check-module.sh shoes Shoe Order" + echo "退出码: 0 全过 / 1 有 ❌ 项 / 2 用法错" +} + +if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then + usage + exit 0 +fi + +if [ "$#" -lt 2 ]; then + usage + exit 2 +fi + +APP="$1" # books / shoes 小写 +LIVE="" + +# 必须先算 ROOT,--all 分支要靠它探 *.entity.ts +ROOT="$(cd "$(dirname "$0")/.." && pwd)" + +# ---- 解析参数:APP + 1+ Entity + 可选 --live ---- +shift +ENT_ARGS=() +for arg in "$@"; do + if [ "$arg" = "--live" ]; then + LIVE="--live" + elif [ "$arg" = "--all" ]; then + # 自动探测 src/backend/src/${APP}/*.entity.ts + for f in "$ROOT/src/backend/src/${APP}"/*.entity.ts; do + [ -f "$f" ] || continue + lc="$(basename "$f" .entity.ts)" # 小写 + ent="$(printf '%s' "$lc" | cut -c1 | tr '[:lower:]' '[:upper:]')$(printf '%s' "$lc" | cut -c2-)" + ENT_ARGS+=("$ent") + done + else + ENT_ARGS+=("$arg") + fi +done + +if [ "${#ENT_ARGS[@]}" -eq 0 ]; then + echo "❌ 没找到任何 Entity(--all 模式下 src/backend/src/${APP}/ 是否有 *.entity.ts?)" + exit 2 +fi + +cd "$ROOT/src/backend" || exit 2 +PASS=0; FAIL=0 + +# 工具函数 +ok() { echo " ✅ $1"; PASS=$((PASS+1)); } +no() { echo " ❌ $1"; FAIL=$((FAIL+1)); } +hdr() { echo; echo "── $1 ──"; } +# 小写(兼容 bash 3.x,不用 ${var,,}) +lower() { printf '%s' "$1" | tr '[:upper:]' '[:lower:]'; } +# 首字母大写(兼容 bash 3.x) +upper_first() { + local s="$1" + printf '%s' "$s" | cut -c1 | tr '[:lower:]' '[:upper:]' + printf '%s' "$s" | cut -c2- +} +# 自然英语复数(兼容 bash 3.x,不依赖 declare -A) +# Apply → Applies / Box → Boxes / Match → Matches / Buy → Buys(y 辅音前) / Boy → Boys +plural() { + case "$1" in + *s|*x|*ch|*sh) echo "${1}es" ;; # -s/-x/-ch/-sh 直接加 es + *ay|*ey|*oy|*uy) echo "${1}s" ;; # 单元音 + y → 保留 +s(Boy → Boys) + *y) echo "${1%y}ies" ;; # 辅音 + y → 去 y 加 ies + *) echo "${1}s" ;; # 默认 +s + esac +} + +# APP 级(与 Entity 无关,只检查一次) +APP_MOD="$(upper_first "$APP")Module" # BooksModule / ShoesModule +hdr "APP 级:${APP} 模块文件 + app.module.ts 注册(接触点 5)" +APP_MOD_FILE="$ROOT/src/backend/src/${APP}/${APP}.module.ts" +if [ -f "$APP_MOD_FILE" ]; then ok "${APP}/${APP}.module.ts" +else no "缺文件: ${APP}/${APP}.module.ts(${APP_MOD} 类)" +fi + +AM="$ROOT/src/backend/src/app.module.ts" +if grep -q "import.*${APP_MOD}.*from.*${APP}/${APP}.module" "$AM" 2>/dev/null; then + ok "import 行包含 ${APP_MOD}" +else + no "app.module.ts 缺 ${APP_MOD} 的 import" +fi +if grep -qE "^[[:space:]]+${APP_MOD}," "$AM" 2>/dev/null; then + ok "imports[] 数组含 ${APP_MOD}" +else + no "app.module.ts 的 imports[] 数组缺 ${APP_MOD}(接触点 5 漏了 → 后端起不来)" +fi + +# ---- 每个 Entity 各自跑一遍 ---- +for ENT in "${ENT_ARGS[@]}"; do + LC="$(lower "$ENT")" # book / shoe / order + URL="${APP}/${ENT}" # books/Book / shoes/Shoe / shoes/Order + + hdr "[${ENT}] 后端 3 文件齐全(appCode=${APP};模块文件共享)" + for f in "src/backend/src/${APP}/${LC}.entity.ts" \ + "src/backend/src/${APP}/${LC}.service.ts" \ + "src/backend/src/${APP}/${LC}.controller.ts"; do + if [ -f "$ROOT/$f" ]; then ok "$f" + else no "缺文件: $f" + fi + done + + hdr "[${ENT}] 前端 api/${LC}.ts 含 list/save/delete 三导出" + API="$ROOT/src/frontend/src/api/${LC}.ts" + if [ -f "$API" ]; then + # 命名约定:list 函数走「自然英语复数」 + # Apply → listApplies / Box → listBoxes / Order → listOrders / Match → listMatches + # plural() 兼容上述五类(-s/-x/-ch/-sh → +es;辅音 + y → 去 y 加 ies;元音 + y → +s;默认 +s)。 + # save/delete 用 Entity 单数(PascalCase),与 controller 端点命名一致。 + PLURAL_ENT="$(plural "$ENT")" + for fn in "list${PLURAL_ENT}" "save${ENT}" "delete${ENT}"; do + if grep -qE "export[[:space:]]+const[[:space:]]+${fn}" "$API" 2>/dev/null; then + ok "$fn 导出存在" + else + # 显式 brace 包变量,避免 set -u 在 bash 3.x 下对复合字符串的 unbound 误报 + no "${API} 缺 export const ${fn}(前端解构会 undefined)" + fi + done + else + no "缺文件: $API" + fi + + hdr "[${ENT}] 前端 views/${ENT}.tsx 存在" + if [ -f "$ROOT/src/frontend/src/views/${ENT}.tsx" ]; then + ok "views/${ENT}.tsx" + else + no "缺文件: views/${ENT}.tsx" + fi + + hdr "[${ENT}] App.tsx 含 ),BSD grep 不支持 -P 跨行匹配, + # 用 tr 把换行去掉再 grep 最稳。 + if tr '\n' ' ' < "$ROOT/src/frontend/src/App.tsx" | grep -q "]*path=\"/${URL}\"" 2>/dev/null \ + || grep -Eq "]*path=\"/${URL}\"" "$ROOT/src/frontend/src/App.tsx" 2>/dev/null; then + ok "Route path=\"/${URL}\" 已注册" + else + no "App.tsx 缺 /dev/null; then + ok "menus[] 已含 '${URL}'" + else + no "seed.service.ts 缺 urlAddress:'${URL}' 行 → 菜单不显示" + fi + + hdr "[${ENT}] 三处一字不差:MODKEY const == urlAddress == Route path(去前导斜杠)" + CTRL="$ROOT/src/backend/src/${APP}/${LC}.controller.ts" + if [ -f "$CTRL" ]; then + if grep -qE "const[[:space:]]+MODULE_KEY[[:space:]]*=[[:space:]]*'${URL}'" "$CTRL" 2>/dev/null; then + ok "controller MODULE_KEY = '${URL}'" + else + no "controller 缺 const MODULE_KEY = '${URL}'(接触点 9 与守卫 key 不一致 → 权限静默放行)" + fi + else + no "controller 文件不存在,跳过 MODKEY 检查" + fi + + hdr "[${ENT}] 实体列 f_ 前缀 + 主键 varchar(50)(契约红线 4)" + ENT_FILE="$ROOT/src/backend/src/${APP}/${LC}.entity.ts" + if [ -f "$ENT_FILE" ]; then + if grep -qE "PrimaryColumn.*name:[[:space:]]*'f_id'.*length:[[:space:]]*50" "$ENT_FILE" 2>/dev/null; then + ok "主键 f_id varchar(50)" + else + no "主键必须是 varchar(50)(不要写成 32,否则 36 位 UUID 装不下)" + fi + if grep -qE "name:[[:space:]]*'f_" "$ENT_FILE" 2>/dev/null; then + ok "含 f_ 前缀列" + else + no "实体里没找到任何 f_ 前缀列" + fi + fi + + hdr "[${ENT}] 软删契约:查询带 deleteMark: 0 + remove 软删" + if grep -qE "deleteMark:[[:space:]]*0" "$ROOT/src/backend/src/${APP}/${LC}.service.ts" 2>/dev/null; then + ok "list 查询带 deleteMark: 0" + else + no "list 查询缺 where: { deleteMark: 0 } → 软删数据会显示" + fi + if grep -qE "deleteMark:[[:space:]]*1" "$ROOT/src/backend/src/${APP}/${LC}.service.ts" 2>/dev/null; then + ok "remove 置 deleteMark = 1" + else + no "remove 没软删(应是 update deleteMark=1,非 repo.delete)" + fi + + hdr "[${ENT}] 端点命名 /api/ssw/${APP}/${ENT}/{List|Save|Delete}" + if grep -qE "@Controller\('api/ssw/${APP}/${ENT}'\)" "$CTRL" 2>/dev/null; then + ok "@Controller('api/ssw/${APP}/${ENT}')" + else + no "controller 类注解不是 @Controller('api/ssw/${APP}/${ENT}')" + fi + for ep in "'List'" "'Save'" "'Delete'"; do + if grep -qE "@(Get|Post|Delete)\(${ep}\)" "$CTRL" 2>/dev/null; then + ok "端点 ${ep} 存在" + else + no "缺端点 ${ep}" + fi + done +done + +# -------- 总结 -------- +echo +echo "── 总结 ──" +echo "Entities: ${ENT_ARGS[*]}" +echo "PASS=$PASS FAIL=$FAIL" +if [ "$FAIL" -eq 0 ]; then + echo "全 ✅ 可以跑 perm-smoke 了" +else + echo "有 ❌,请按上面修复后再跑 perm-smoke" +fi + +# -------- 可选:实跑端点(需后端已起) -------- +if [ "$LIVE" = "--live" ]; then + hdr "实跑端点(依赖后端在 127.0.0.1:30000)" + B="${B:-http://127.0.0.1:30000}" + # 默认走 which node,回退到 workbuddy 路径 + NODE_RESOLVED="$(command -v node 2>/dev/null || echo /Users/xs/.workbuddy/binaries/node/versions/22.22.2-3/bin/node)" + ENC="$($NODE_RESOLVED -e "const C=require('crypto-js');const k=C.enc.Utf8.parse(C.MD5('EY8WePvjM5GGwQzn').toString());const s=C.enc.Utf8.parse(C.MD5('123456').toString());console.log(C.AES.encrypt(s,k,{mode:C.mode.ECB,padding:C.pad.Pkcs7}).ciphertext.toString(C.enc.Hex))")" + LOGIN=$(curl --noproxy '*' -s -X POST "$B/api/oauth/Login" \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "account=admin" --data-urlencode "password=$ENC" --data-urlencode "grant_type=password") + T=$(echo "$LOGIN" | $NODE_RESOLVED -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{console.log(JSON.parse(d).data.token)})") + if [ -z "$T" ]; then + no "admin 登录失败,确认后端在跑" + exit 1 + fi + ok "admin 登录成功" + + # 每个 Entity 都打实跑 + for ENT in "${ENT_ARGS[@]}"; do + hdr "[${ENT}] 实跑 /api/ssw/${APP}/${ENT}/List" + CODE=$(curl --noproxy '*' -s -o /tmp/.chk-list.json -w '%{http_code}' \ + "$B/api/ssw/${APP}/${ENT}/List" -H "Authorization: bearer $T") + BCODE=$($NODE_RESOLVED -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{console.log(JSON.parse(d).code)})" < /tmp/.chk-list.json) + if [ "$CODE" = "200" ] && [ "$BCODE" = "200" ]; then + ok "GET List 返 200 + body.code=200" + else + no "List 失败:HTTP=$CODE body.code=$BCODE" + fi + + CODE=$(curl --noproxy '*' -s -o /tmp/.chk-600.json -w '%{http_code}' \ + "$B/api/ssw/${APP}/${ENT}/List") + BCODE=$($NODE_RESOLVED -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{console.log(JSON.parse(d).code)})" < /tmp/.chk-600.json) + if [ "$BCODE" = "600" ]; then + ok "无 token 拦截:code=600" + else + no "无 token 应返 600,实得 $BCODE" + fi + done +fi + +exit $([ "$FAIL" -eq 0 ] && echo 0 || echo 1) \ No newline at end of file diff --git a/scripts/gen-schema.js b/scripts/gen-schema.js new file mode 100644 index 0000000..6ef7c8c --- /dev/null +++ b/scripts/gen-schema.js @@ -0,0 +1,120 @@ +#!/usr/bin/env node +/** + * 从实体定义生成 db/schema.sql —— 保证 SQL 与 TypeORM 实体零漂移。 + * + * 用法:node scripts/gen-schema.js + * + * 解析规则(只覆盖本项目实体实际用到的写法,刻意不做通用解析器): + * @Entity({ name: 'xxx' }) -> 表名 + * @PrimaryColumn({ name: 'f_xx', type: 'varchar', length: 50 }) + * @Column({ name: 'f_xx', type: 'varchar', length: 255, nullable: true }) + * @Column({ name: 'f_xx', type: 'int', nullable: true, default: 0 }) + * + * 输出对齐 JNPF 原生 schema 风格:f_ 前缀 + varchar(50) 主键 + f_delete_mark 软删。 + */ +const fs = require('fs'); +const path = require('path'); + +const ROOT = path.resolve(__dirname, '..'); +const ENTITY_DIR = path.join(ROOT, 'src/backend/src'); +const OUT = path.join(ROOT, 'src/backend/db/schema.sql'); + +/** varchar(n) / text / int / timestamp / numeric → Postgres 方言 */ +function sqlType(col) { + const type = (col.type || 'varchar').toLowerCase(); + if (type === 'text') return 'TEXT'; + if (type === 'int' || type === 'integer') return 'INT'; + if (type === 'bigint') return 'BIGINT'; + if (type === 'timestamp') return 'TIMESTAMP'; + if (type === 'numeric' || type === 'decimal') return 'NUMERIC'; + if (type === 'boolean' || type === 'bool') return 'BOOLEAN'; + if (type === 'json' || type === 'jsonb') return 'JSONB'; + if (type === 'varchar') return col.length ? `VARCHAR(${col.length})` : 'VARCHAR(255)'; + return 'VARCHAR(255)'; +} + +function parseEntity(file) { + const src = fs.readFileSync(file, 'utf8'); + const tableMatch = src.match(/@Entity\(\{\s*name:\s*'([^']+)'/); + if (!tableMatch) return null; + const table = tableMatch[1]; + + const cols = []; + const re = /@(Primary)?Column\(\{([^}]*)\}\)/g; + let m; + while ((m = re.exec(src))) { + const isPk = !!m[1]; + const attrs = m[2]; + const name = (attrs.match(/name:\s*'([^']+)'/) || [])[1]; + if (!name) continue; + const type = (attrs.match(/type:\s*'([^']+)'/) || [])[1]; + const length = (attrs.match(/length:\s*(\d+)/) || [])[1]; + const nullable = !attrs.includes('nullable: false'); + const def = (attrs.match(/default:\s*([^,}]+)/) || [])[1]; + cols.push({ + name, + sqlType: sqlType({ type, length }), + nullable, + default: def !== undefined && def !== 'null' ? def.trim() : null, + isPk, + }); + } + return { table, cols }; +} + +function render(t) { + const lines = []; + lines.push(`CREATE TABLE IF NOT EXISTS ${t.table} (`); + const body = t.cols.map((c) => { + let s = ` ${c.name.padEnd(22)}${c.sqlType}`; + if (c.isPk) s += ' PRIMARY KEY'; + else if (!c.nullable) s += ' NOT NULL'; + if (c.default !== null) s += ` DEFAULT ${c.default}`; + return s; + }); + lines.push(body.join(',\n')); + lines.push(');'); + return lines.join('\n'); +} + +function walk(dir) { + const out = []; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name); + if (entry.isDirectory()) out.push(...walk(full)); + else if (entry.name.endsWith('.entity.ts')) out.push(full); + } + return out; +} + +const files = walk(ENTITY_DIR).sort(); +const tables = files.map((f) => parseEntity(f)).filter(Boolean); + +if (!tables.length) { + console.error('未解析到任何实体,检查目录:' + ENTITY_DIR); + process.exit(1); +} + +const header = `-- JNPF 原生 schema(Postgres 方言) +-- 本文件由 scripts/gen-schema.js 从 src/backend/src/**/*.entity.ts 自动生成,请勿手改。 +-- 改列结构请改实体后重跑:node scripts/gen-schema.js +-- +-- 契约(对齐 JNPF / ssw-mvp): +-- f_ 前缀列名、主键 f_id VARCHAR(50)、软删 f_delete_mark(0=正常 1=已删) +-- MVP 期由 TypeORM synchronize 自动建表;迁 JNPF 时关掉 synchronize,直接复用本文件。 + +CREATE TABLE IF NOT EXISTS demo_item ( + f_id VARCHAR(50) PRIMARY KEY, + f_title VARCHAR(255), + f_status VARCHAR(32), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); +`; + +const out = header + '\n' + tables.map(render).join('\n\n') + '\n'; +fs.writeFileSync(OUT, out); +console.log(`已生成 ${OUT}`); +console.log(` 表数量:${tables.length + 1}(含 demo_item)`); +for (const t of tables) console.log(` - ${t.table} ${t.cols.length} 列`); diff --git a/scripts/perm-smoke.sh b/scripts/perm-smoke.sh new file mode 100755 index 0000000..1b185f7 --- /dev/null +++ b/scripts/perm-smoke.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env bash +# ssw-jnpf-lite-react 权限闭环冒烟测试 +# +# 用途:验证「登录 cipher / ActionResult 形状 / 菜单树 / 数据权限 / 异常兜底」五段契约。 +# 用法:bash scripts/perm-smoke.sh # 默认打 127.0.0.1:30000 +# B=http://127.0.0.1:30000 bash scripts/perm-smoke.sh +# +# 前置:后端已启动(./run.sh dev 或 node dist/main.js),且库为初始种子状态。 +# 脚本可重复执行(内部会先清理 smoke_user)。 +# 退出码:0 全绿(FAIL=0) / 1 有断言失败 / 2 前置错误(后端不可达 / 进不去 src/backend) +set -u + +if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then + sed -n '2,10p' "$0" | sed 's/^# \{0,1\}//' + exit 0 +fi + +# crypto-js 在 src/backend/node_modules 下,必须从那里解析 +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT/src/backend" || exit 2 + +# 前置探活:后端不可达属「没跑成」不是「跑挂了」,退 2 而不是逐条断言假失败 +B_PRE="${B:-http://127.0.0.1:30000}" +if ! curl --noproxy '*' -s --max-time 3 -o /dev/null "$B_PRE/api/oauth/CurrentUser"; then + echo "❌ 后端不可达(${B_PRE})。先 ./run.sh dev,或 B= 指定目标后重试。" + exit 2 +fi + +# 默认走 which node,回退到 workbuddy 路径(兼容旧机器) +NODE_RESOLVED="$(command -v node 2>/dev/null || echo /Users/xs/.workbuddy/binaries/node/versions/22.22.2-3/bin/node)" +NODE="${NODE:-$NODE_RESOLVED}" +B="${B:-http://127.0.0.1:30000}" +PASS=0; FAIL=0 + +enc() { $NODE -e "const C=require('crypto-js');const k=C.enc.Utf8.parse(C.MD5('EY8WePvjM5GGwQzn').toString());const s=C.enc.Utf8.parse(C.MD5('$1').toString());console.log(C.AES.encrypt(s,k,{mode:C.mode.ECB,padding:C.pad.Pkcs7}).ciphertext.toString(C.enc.Hex))"; } +# 从 stdin JSON 里取字段:json "" +json() { $NODE -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{try{console.log(eval(process.argv[1]))}catch(e){console.log('ERR:'+e.message)}})" "$1"; } +# 断言:check <期望> <实际> <说明> +check() { if [ "$1" = "$2" ]; then echo " ✅ $3 ($2)"; PASS=$((PASS+1)); else echo " ❌ $3 期望=$1 实际=$2"; FAIL=$((FAIL+1)); fi; } + +# 从 seed.service.ts 的 menus[] 动态算期望菜单树字符串。 +# 与硬编码字符串的差别:加新菜单后无需改这里,断言自动适配。 +# 实现:grep 出 menus 数组字面量 → eval 成 JS 对象数组 → 按 parentId 建树 → 按 sortCode 排序 → 序列化。 +expected_menu_tree() { + $NODE -e " + const fs = require('fs'); + const txt = fs.readFileSync('$ROOT/src/backend/src/sys/seed.service.ts', 'utf8'); + const m = txt.match(/menus\s*=\s*\[([\s\S]*?)\];/); + if (!m) { console.log('<>'); process.exit(0); } + const items = eval('[' + m[1] + ']'); + const byId = Object.fromEntries(items.map(i => [i.id, {...i, children: []}])); + items.forEach(i => { if (byId[i.parentId]) byId[i.parentId].children.push(byId[i.id]); }); + // 注意:用 byId[...] 拿带 children 字段的对象,原 items[] 没有 children + const top = items + .filter(i => i.parentId === '0') + .sort((a, b) => a.sortCode - b.sortCode) + .map(i => byId[i.id]); + console.log(top.map(n => + n.fullName + ':' + n.children.sort((a, b) => a.sortCode - b.sortCode).map(c => c.fullName).join(',') + ).join('|')); + " +} + +echo "== 0) 无 token 访问 User/List(期望 600)==" +check 600 "$(curl --noproxy '*' -s "$B/api/ssw/sys/User/List" | json 'JSON.parse(d).code')" "未登录返回 SESSIONOVERDUE" + +echo "== 1) admin 登录(cipher: md5->AES-256-ECB-PKCS7)==" +LOGIN=$(curl --noproxy '*' -s -X POST "$B/api/oauth/Login" \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "account=admin" --data-urlencode "password=$(enc 123456)" --data-urlencode "grant_type=password") +check 200 "$(echo "$LOGIN" | json 'JSON.parse(d).code')" "登录成功" +TOKEN=$(echo "$LOGIN" | json 'JSON.parse(d).data.token') +AUTH="Authorization: bearer $TOKEN" +check 1 "$([ -n "$TOKEN" ] && echo 1 || echo 0)" "拿到 token" + +echo "== 2) admin 菜单树(动态从 seed.service.ts 计算期望)==" +MENU=$(curl --noproxy '*' -s "$B/api/oauth/CurrentUser" -H "$AUTH") +check 200 "$(echo "$MENU" | json 'JSON.parse(d).code')" "CurrentUser 成功" +EXPECTED_TREE="$(expected_menu_tree)" +check "$EXPECTED_TREE" \ + "$(echo "$MENU" | json 'JSON.parse(d).data.menuList.map(n=>n.fullName+":"+((n.children||[]).map(c=>c.fullName).join(","))).join("|")')" \ + "菜单树分组正确(期望来自 seed.service.ts:${EXPECTED_TREE})" + +echo "== 3) 清理历史 smoke_user(幂等)==" +OLD=$(curl --noproxy '*' -s "$B/api/ssw/sys/User/List" -H "$AUTH" | json '(JSON.parse(d).data.find(u=>u.account==="smoke_user")||{}).id||""') +[ -n "$OLD" ] && curl --noproxy '*' -s -X DELETE "$B/api/ssw/sys/User/Delete?id=$OLD" -H "$AUTH" >/dev/null +echo " cleared=${OLD:-none}" + +echo "== 4) 新建 smoke_user(期望 200)==" +check 200 "$(curl --noproxy '*' -s -X POST "$B/api/ssw/sys/User/Save" -H "$AUTH" -H 'Content-Type: application/json' \ + -d '{"account":"smoke_user","realName":"Smoke","password":"abc","isAdministrator":false,"roleIds":["role_user"]}' | json 'JSON.parse(d).code')" "创建用户" + +echo "== 5) 重复建 smoke_user(期望 400 + 业务提示,不是 500 裸异常)==" +DUP=$(curl --noproxy '*' -s -o /tmp/.perm-dup.json -w '%{http_code}' -X POST "$B/api/ssw/sys/User/Save" -H "$AUTH" -H 'Content-Type: application/json' \ + -d '{"account":"smoke_user","realName":"Smoke","password":"abc","isAdministrator":false,"roleIds":["role_user"]}') +check 200 "$DUP" "HTTP 200(不是 500)" +check 400 "$(cat /tmp/.perm-dup.json | json 'JSON.parse(d).code')" "业务码 400" +check "账号已存在:smoke_user" "$(cat /tmp/.perm-dup.json | json 'JSON.parse(d).msg')" "提示信息透传" + +echo "== 6) 授权 role_user 仅可见 m_demo(官方契约:module 为【一维】String[])==" +check 200 "$(curl --noproxy '*' -s -X PUT "$B/api/permission/Authority/Data/role_user" -H "$AUTH" -H 'Content-Type: application/json' \ + -d '{"objectType":"role","module":["m_demo"]}' | json 'JSON.parse(d).code')" "写授权(一维)" + +echo "== 6.1) 兼容历史二维 [checked, halfChecked](旧集成不应失效)==" +check 200 "$(curl --noproxy '*' -s -X PUT "$B/api/permission/Authority/Data/role_user" -H "$AUTH" -H 'Content-Type: application/json' \ + -d '{"objectType":"role","module":[["m_demo"],[]]}' | json 'JSON.parse(d).code')" "写授权(二维兼容)" + +echo "== 7) smoke_user 登录 ==" +ALOGIN=$(curl --noproxy '*' -s -X POST "$B/api/oauth/Login" -H 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "account=smoke_user" --data-urlencode "password=$(enc abc)" --data-urlencode "grant_type=password") +check 200 "$(echo "$ALOGIN" | json 'JSON.parse(d).code')" "非管理员登录成功" +ATOKEN=$(echo "$ALOGIN" | json 'JSON.parse(d).data.token') + +echo "== 8) smoke_user 菜单树(应只剩 Demo 示例)==" +check "Demo 示例:" "$(curl --noproxy '*' -s "$B/api/oauth/CurrentUser" -H "Authorization: bearer $ATOKEN" | json 'JSON.parse(d).data.menuList.map(n=>n.fullName+":"+((n.children||[]).map(c=>c.fullName).join(","))).join("|")')" "菜单已按授权收窄" + +echo "== 9) smoke_user 访问系统管理(期望 403 无菜单权限)==" +check 403 "$(curl --noproxy '*' -s "$B/api/ssw/sys/User/List" -H "Authorization: bearer $ATOKEN" | json 'JSON.parse(d).code')" "数据权限拦截" + +echo "== 10) smoke_user 访问 DemoItem(期望 200)==" +check 200 "$(curl --noproxy '*' -s "$B/api/ssw/demo/DemoItem/List" -H "Authorization: bearer $ATOKEN" | json 'JSON.parse(d).code')" "已授权业务可访问" + +echo "== 11) 未知路由(期望 HTTP 404 保留)==" +check 404 "$(curl --noproxy '*' -s -o /dev/null -w '%{http_code}' "$B/api/not-exist-xyz")" "404 不被吞掉" + +echo "== 12) 新模块 Product(HOWTO_MODULE.md 参照实现,模式 B 守卫)==" +check 200 "$(curl --noproxy '*' -s "$B/api/ssw/shop/Product/List" -H "$AUTH" | json 'JSON.parse(d).code')" "Product 列表(admin 短路)" +NEW=$(curl --noproxy '*' -s -X POST "$B/api/ssw/shop/Product/Save" -H "$AUTH" \ + -H 'Content-Type: application/json' -d '{"title":"测试产品","price":"9.90"}') +check 200 "$(echo "$NEW" | json 'JSON.parse(d).code')" "Product 新建" +check 36 "$(echo "$NEW" | json 'JSON.parse(d).data.id.length')" "主键为 36 位 UUID" +check "9.90" "$(echo "$NEW" | json 'JSON.parse(d).data.price')" "numeric 金额列往返一致" +check 600 "$(curl --noproxy '*' -s "$B/api/ssw/shop/Product/List" | json 'JSON.parse(d).code')" "无 token 拦截" +check 403 "$(curl --noproxy '*' -s "$B/api/ssw/shop/Product/List" -H "Authorization: bearer $ATOKEN" | json 'JSON.parse(d).code')" "未授权菜单的非管理员 403" + +echo "== 13) 业务模块 Book(图书超市:6 字段 + 多列约束;技能本体内置示例)==" +# 自适应:模块不存在(路由 404 + body.code 400/500)时跳过,避免派生项目误报。 +# 用 List 端点探活:若返 404/400/500 视为不存在;返 200/403 视为存在。 +PROBE=$(curl --noproxy '*' -s -o /tmp/.perm-book-probe.json -w '%{http_code}' \ + "$B/api/ssw/books/Book/List" -H "$AUTH") +PROBE_CODE="$(cat /tmp/.perm-book-probe.json | json 'JSON.parse(d).code')" +if [ "$PROBE" = "404" ] || [ "$PROBE_CODE" = "400" ] || [ "$PROBE_CODE" = "500" ]; then + echo " ⚠️ 跳过:books/Book 模块未注册(典型派生项目会删掉)。HTTP=$PROBE body.code=${PROBE_CODE:-N/A}" +else + check 200 "$(cat /tmp/.perm-book-probe.json | json 'JSON.parse(d).code')" "Book 列表(admin 短路)" + BNEW=$(curl --noproxy '*' -s -X POST "$B/api/ssw/books/Book/Save" -H "$AUTH" \ + -H 'Content-Type: application/json' \ + -d '{"title":"三体","author":"刘慈欣","isbn":"9787229030937","category":"科幻","price":"58.00","stock":100}') + check 200 "$(echo "$BNEW" | json 'JSON.parse(d).code')" "Book 新建(6 字段)" + check 36 "$(echo "$BNEW" | json 'JSON.parse(d).data.id.length')" "Book 主键为 36 位 UUID" + check "三体" "$(echo "$BNEW" | json 'JSON.parse(d).data.title')" "Book title 字段往返" + check "刘慈欣" "$(echo "$BNEW" | json 'JSON.parse(d).data.author')" "Book author 字段往返" + check "58.00" "$(echo "$BNEW" | json 'JSON.parse(d).data.price')" "Book numeric 金额列往返" + check 100 "$(echo "$BNEW" | json 'JSON.parse(d).data.stock')" "Book int 库存字段往返" + LIST=$(curl --noproxy '*' -s "$B/api/ssw/books/Book/List" -H "$AUTH" | json 'JSON.parse(d).data.length') + [ "$LIST" -ge 1 ] && echo " ✅ Book 列表含新建项 ($LIST)" && PASS=$((PASS+1)) || { echo " ❌ Book 列表为空"; FAIL=$((FAIL+1)); } + check 600 "$(curl --noproxy '*' -s "$B/api/ssw/books/Book/List" | json 'JSON.parse(d).code')" "Book 无 token 拦截" + check 403 "$(curl --noproxy '*' -s "$B/api/ssw/books/Book/List" -H "Authorization: bearer $ATOKEN" | json 'JSON.parse(d).code')" "Book 未授权菜单的非管理员 403" +fi + +echo +echo "--------------------" +echo "PASS=$PASS FAIL=$FAIL" +[ "$FAIL" -eq 0 ] && echo "全绿 ✅" || echo "有失败 ❌" +exit $([ "$FAIL" -eq 0 ] && echo 0 || echo 1) diff --git a/scripts/seed-demo.js b/scripts/seed-demo.js new file mode 100644 index 0000000..ead655f --- /dev/null +++ b/scripts/seed-demo.js @@ -0,0 +1,178 @@ +#!/usr/bin/env node +/** + * 灌入演示数据 —— 让新环境打开就能看到完整的 sswflow 场景,而不是空表。 + * 用法:node scripts/seed-demo.js [后端地址] + * 默认 http://127.0.0.1:30000 + */ +const B = process.argv[2] || 'http://127.0.0.1:30000'; +// crypto-js 装在 src/backend/node_modules 下,从项目根的 scripts/ 跑时解析不到, +// 显式指向后端依赖目录。 +const Crypto = require('../src/backend/node_modules/crypto-js'); + +function enc(pwd) { + const k = Crypto.enc.Utf8.parse(Crypto.MD5('EY8WePvjM5GGwQzn').toString()); + const s = Crypto.enc.Utf8.parse(Crypto.MD5(pwd).toString()); + return Crypto.AES.encrypt(s, k, { mode: Crypto.mode.ECB, padding: Crypto.pad.Pkcs7 }) + .ciphertext.toString(Crypto.enc.Hex); +} + +async function api(path, method = 'GET', body, token) { + const res = await fetch(`${B}${path}`, { + method, + headers: { + 'Content-Type': 'application/json', + ...(token ? { Authorization: `bearer ${token}` } : {}), + }, + body: body ? JSON.stringify(body) : undefined, + }); + return res.json(); +} + +(async () => { + const login = await api('/api/oauth/Login', 'POST'); + // Login 是表单提交,改用 fetch + URLSearchParams + const form = new URLSearchParams({ + account: 'admin', password: enc('123456'), grant_type: 'password', + }); + const lr = await fetch(`${B}/api/oauth/Login`, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: form.toString(), + }); + const lj = await lr.json(); + if (lj.code !== 200) { console.error('登录失败:', lj.msg); process.exit(1); } + const T = lj.data.token; + console.log('✓ 登录 admin'); + + const post = (p, b) => api(p, 'POST', b, T); + const put = (p, b) => api(p, 'PUT', b, T); + + // ---- 参与方 ---- + const parties = [ + { partyCode: 'P001', name: '上海数科', orgName: '上海数科信息科技有限公司', endpoint: 'https://shdsk.internal:8443', role: 'initiator', status: 'ACTIVE', selfMark: 1, computeMode: 'MPC' }, + { partyCode: 'P002', name: '深圳智算', orgName: '深圳智算科技有限公司', endpoint: 'https://szzk.internal:8443', role: 'participant', status: 'ACTIVE', selfMark: 0, computeMode: 'MPC' }, + { partyCode: 'P003', name: '北京数安', orgName: '北京数安研究院', endpoint: 'https://bjsan.internal:8443', role: 'participant', status: 'ACTIVE', selfMark: 0, computeMode: 'TEE' }, + ]; + const partyIds = []; + for (const p of parties) { + const r = await post('/api/ssw/sswflow/Party/Save', p); + if (r.code === 200) { partyIds.push(r.data.id); console.log(' ✓ 参与方', p.name); } + } + + // ---- 协作项目 ---- + const projects = [ + { projectCode: 'PRJ001', name: '联合风控建模', desc: '银行 + 电商联合反欺诈模型', ownerPartyId: partyIds[0], computeMode: 'MPC', status: 'RUNNING' }, + { projectCode: 'PRJ002', name: '跨机构特征互补', desc: '联合特征工程与画像', ownerPartyId: partyIds[1], computeMode: 'MPC', status: 'PREPARING' }, + ]; + const projectIds = []; + for (const p of projects) { + const r = await post('/api/ssw/sswflow/Project/Save', p); + if (r.code === 200) { projectIds.push(r.data.id); console.log(' ✓ 项目', p.name); } + } + + // ---- 项目成员 ---- + for (let i = 0; i < partyIds.length; i++) { + await post('/api/ssw/sswflow/ProjectParty/Save', { + projectId: projectIds[0], partyId: partyIds[i], + role: i === 0 ? 'owner' : 'participant', joinStatus: i === 0 ? 'JOINED' : 'INVITED', + }); + } + console.log(' ✓ 项目成员关系'); + + // ---- 数据源 ---- + const dsIds = []; + const dsList = [ + { name: '电商交易库', partyId: partyIds[1], type: 'MySQL', status: 'ONLINE', desc: '订单与支付流水' }, + { name: '银行信贷库', partyId: partyIds[0], type: 'PostgreSQL', status: 'ONLINE', desc: '授信与还款记录' }, + ]; + for (const d of dsList) { + const r = await post('/api/ssw/sswflow/Datasource/Save', d); + if (r.code === 200) { dsIds.push(r.data.id); console.log(' ✓ 数据源', d.name); } + } + + // ---- 数据集 + 授权 ---- + const datasetIds = []; + const dsDef = [ + { datasetCode: 'DS001', name: '交易明细表', partyId: partyIds[1], datasourceId: dsIds[0], storageType: 'MySQL', location: 'ods.trade_detail', rowCount: 1280000, externalRef: 'trade_detail_2026' }, + { datasetCode: 'DS002', name: '授信申请表', partyId: partyIds[0], datasourceId: dsIds[1], storageType: 'PostgreSQL', location: 'public.credit_apply', rowCount: 860000, externalRef: 'credit_apply' }, + ]; + for (const d of dsDef) { + const r = await post('/api/ssw/sswflow/Dataset/Save', d); + if (r.code === 200) { datasetIds.push(r.data.id); console.log(' ✓ 数据集', d.name); } + } + await post('/api/ssw/sswflow/DatasetAuth/Save', { + datasetId: datasetIds[1], projectId: projectIds[0], authStatus: 'APPROVED', + authUserId: 'admin', expireTime: new Date(Date.now() + 90 * 864e5).toISOString(), + }); + await post('/api/ssw/sswflow/DatasetAuth/Save', { + datasetId: datasetIds[0], projectId: projectIds[0], authStatus: 'PENDING', + }); + console.log(' ✓ 数据集授权'); + + // ---- 流程(两条完整 DAG)---- + const flowDefs = [ + { + name: '联合反欺诈模型训练', desc: '电商交易 + 银行授信 → 隐私求交 → 逻辑回归 → 导出', + projectId: projectIds[0], + steps: [ + { stepId: 'src-trade', operatorKey: 'source.dataset', label: '交易明细', x: 40, y: 60, params: { datasetId: datasetIds[0] } }, + { stepId: 'src-credit', operatorKey: 'source.dataset', label: '授信申请', x: 40, y: 220, params: { datasetId: datasetIds[1] } }, + { stepId: 'psi', operatorKey: 'prep.intersect', label: '隐私求交', x: 300, y: 140, params: { leftKeys: ['user_id'], rightKeys: ['cust_no'], protocol: 'ECDH', receiver: 'shdsk', keepOrder: true } }, + { stepId: 'split', operatorKey: 'prep.split', label: '训练集拆分', x: 540, y: 140, params: { testRatio: 0.2 } }, + { stepId: 'lr', operatorKey: 'model.lr.train', label: '逻辑回归训练', x: 780, y: 60, params: { labelColumn: 'is_fraud', n: 64, d: 16, epochs: 30, learningRate: 0.05 } }, + { stepId: 'eval', operatorKey: 'model.evaluate', label: '模型评估', x: 780, y: 220, params: { labelColumn: 'is_fraud' } }, + { stepId: 'export', operatorKey: 'sink.export', label: '模型导出', x: 1020, y: 140, params: { targetParty: 'shdsk', fileName: 'fraud_lr_model.bin' } }, + ], + edges: [ + { edgeId: 'e1', sourceStepId: 'src-trade', sourcePort: 'out', targetStepId: 'psi', targetPort: 'left' }, + { edgeId: 'e2', sourceStepId: 'src-credit', sourcePort: 'out', targetStepId: 'psi', targetPort: 'right' }, + { edgeId: 'e3', sourceStepId: 'psi', sourcePort: 'out', targetStepId: 'split', targetPort: 'in' }, + { edgeId: 'e4', sourceStepId: 'split', sourcePort: 'train', targetStepId: 'lr', targetPort: 'in' }, + { edgeId: 'e5', sourceStepId: 'split', sourcePort: 'test', targetStepId: 'eval', targetPort: 'in' }, + { edgeId: 'e6', sourceStepId: 'lr', sourcePort: 'model', targetStepId: 'export', targetPort: 'in' }, + ], + }, + { + name: '密态特征相关性分析', desc: 'SCQL 密态 SQL 执行统计查询', + projectId: projectIds[1], + steps: [ + { stepId: 'src2', operatorKey: 'source.dataset', label: '联合特征集', x: 60, y: 80, params: { datasetId: datasetIds[0] } }, + { stepId: 'profile', operatorKey: 'stat.profile', label: '全表统计', x: 320, y: 80, params: {} }, + { stepId: 'corr', operatorKey: 'stat.correlation', label: '相关性分析', x: 560, y: 80, params: { method: 'pearson' } }, + { stepId: 'iv', operatorKey: 'stat.iv', label: 'IV 评估', x: 800, y: 80, params: { labelColumn: 'y' } }, + ], + edges: [ + { edgeId: 'f1', sourceStepId: 'src2', sourcePort: 'out', targetStepId: 'profile', targetPort: 'in' }, + { edgeId: 'f2', sourceStepId: 'profile', sourcePort: 'report', targetStepId: 'corr', targetPort: 'in' }, + { edgeId: 'f3', sourceStepId: 'corr', sourcePort: 'report', targetStepId: 'iv', targetPort: 'in' }, + ], + }, + ]; + + const flowIds = []; + for (const f of flowDefs) { + const r = await post('/api/ssw/sswflow/Flow/Save', { + name: f.name, desc: f.desc, projectId: f.projectId, + steps: JSON.stringify(f.steps), edges: JSON.stringify(f.edges), + }); + if (r.code === 200) { flowIds.push(r.data.id); console.log(' ✓ 流程', f.name, `(${f.steps.length} 节点)`); } + } + + // ---- 周期调度 ---- + await post('/api/ssw/sswflow/FlowSchedule/Save', { + flowId: flowIds[0], projectId: projectIds[0], name: '每日凌晨重训', + cron: '0 2 * * *', enabledMark: 0, misfirePolicy: 'FIRE_NOW', runScope: 'FULL', + }); + console.log(' ✓ 周期调度'); + + // ---- 跑一次,留下运行实例和事件 ---- + const run = await post('/api/ssw/sswflow/FlowRun/Start', { + flowId: flowIds[0], trigger: 'MANUAL', mode: 'FULL', + }); + if (run.code === 200) { + console.log(' ✓ 已触发一次运行:', run.data.id); + await new Promise((r) => setTimeout(r, 6000)); + } + + console.log('\n完成。打开 http://127.0.0.1:5173 登录 admin / 123456 查看。'); +})().catch((e) => { console.error('失败:', e.message); process.exit(1); }); diff --git a/scripts/seed-infra.js b/scripts/seed-infra.js new file mode 100644 index 0000000..c08b904 --- /dev/null +++ b/scripts/seed-infra.js @@ -0,0 +1,132 @@ +#!/usr/bin/env node +/** + * 设备注册 + 链上存证 —— **拉真实数据**,不再灌演示假数据。 + * + * 用法: + * node scripts/seed-infra.js # 从控制面 / 真链同步(幂等,可重复跑) + * node scripts/seed-infra.js --list # 只看当前已有数据 + * node scripts/seed-infra.js --tx # 额外查一笔 FISCO 链上出块回执 + * + * ★★ 为什么不再灌演示数据: + * 「设备注册」的真源是 ssw-mpc 控制面的节点注册表(TEE 节点经 hostd 自报), + * 「链上存证」的真源是 ssw-mpc 的 outbox + FISCO 国密链。 + * 两者都是**外部系统的事实**,前端自己造一份只会让人误以为系统能跑 —— + * 而真源不可达时,系统必须 fail-closed(0 条 + 原因),不是拿假数据顶。 + * + * ★ 幂等:主键由真源的稳定键派生(设备 `site@host`、存证 `kind:order:decision`), + * 重复同步不产生重复行,也不复活软删行。 + */ +const path = require('path'); +const CryptoJS = require(path.join(__dirname, '../src/backend/node_modules/crypto-js')); + +const B = process.env.SSW_BE || 'http://127.0.0.1:30000'; +const ACCOUNT = process.env.SSW_ACCOUNT || 'admin'; +const PASSWORD = process.env.SSW_PASSWORD || '123456'; + +/** 与前端 cipher.ts 逐字节一致:AES-256-ECB-PKCS7(md5(明文)),key=md5('EY8WePvjM5GGwQzn') */ +function encryptPassword(plain) { + const key = CryptoJS.enc.Utf8.parse(CryptoJS.MD5('EY8WePvjM5GGwQzn').toString()); + const src = CryptoJS.enc.Utf8.parse(CryptoJS.MD5(plain).toString()); + return CryptoJS.AES.encrypt(src, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }).ciphertext.toString(CryptoJS.enc.Hex); +} + +async function http(pathname, { method = 'GET', body, token } = {}) { + const headers = {}; + if (token) headers.Authorization = `Bearer ${token}`; + if (body) headers['Content-Type'] = 'application/json'; + const res = await fetch(B + pathname, { + method, + headers, + body: body ? JSON.stringify(body) : undefined, + }); + const json = await res.json().catch(() => ({})); + if (json.code !== undefined && json.code !== 200) { + throw new Error(`${method} ${pathname} -> code=${json.code} msg=${json.msg}`); + } + return json.data; +} + +async function login() { + const form = new URLSearchParams(); + form.set('account', ACCOUNT); + form.set('password', encryptPassword(PASSWORD)); + form.set('grant_type', 'password'); + const res = await fetch(`${B}/api/oauth/Login`, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: form.toString(), + }); + const json = await res.json(); + if (!json.data || !json.data.token) throw new Error(`登录失败: ${JSON.stringify(json)}`); + return json.data.token; +} + +function pickArg(flag) { + const i = process.argv.indexOf(flag); + return i >= 0 ? process.argv[i + 1] : null; +} + +async function main() { + const token = await login(); + console.log(`已登录 ${ACCOUNT} @ ${B}`); + + if (process.argv.includes('--list')) { + const devs = await http('/api/ssw/sswdevice/Device/List', { token }); + const blocks = await http('/api/ssw/sswchain/ChainBlock/List', { token }); + console.log(`\n设备 ${devs.length} 条(真源:control-plane GET /nodes):`); + devs.forEach((d) => + console.log( + ` - ${d.key} | ${d.platform} | tcb=${d.tcb} | kbc=${d.kbc} | kbs=${d.kbsReachable ? '可达' : '不可达'} | source=${d.source}`, + ), + ); + console.log(`\n存证 ${blocks.length} 条(真源:chain outbox + FISCO 回执):`); + blocks.forEach((b) => + console.log( + ` - ${b.orderId}/${b.decisionId} | link=${b.link} | attest=${b.userDataOk ? 1 : 0}${b.measOk ? 1 : 0}${b.tcbOk ? 1 : 0}${b.chipSig ? 1 : 0}` + + ` | status=${b.status ?? '-'} @${b.blockNumber ?? '-'} | source=${b.source}`, + ), + ); + return; + } + + // ---- ① 设备:从控制面同步 ---- + const devSync = await http('/api/ssw/sswdevice/Device/Sync', { + method: 'POST', + token, + body: {}, + }); + console.log( + `\n设备同步:${devSync.synced} 条 | 来源 ${devSync.source} | 出处 ${devSync.origin}` + + (devSync.reason ? `\n ⚠ 原因:${devSync.reason}` : ''), + ); + + // ---- ② 存证:从真链同步(可带 txHash 查链上回执) ---- + const txHash = pickArg('--tx'); + const chainSync = await http('/api/ssw/sswchain/ChainBlock/Sync', { + method: 'POST', + token, + body: txHash ? { txHash } : {}, + }); + console.log( + `存证同步:${chainSync.synced} 条 | 来源 ${chainSync.source} | 链高度 ${chainSync.height ?? '-'}` + + (chainSync.txReceipt + ? ` | 链上回执 ${chainSync.txReceipt.success ? '成功(0)' : `失败(${chainSync.txReceipt.status})`} @${chainSync.txReceipt.blockNumber ?? '-'}` + : '') + + (chainSync.reason ? `\n ⚠ 原因:${chainSync.reason}` : ''), + ); + + const devs = await http('/api/ssw/sswdevice/Device/List', { token }); + const blocks = await http('/api/ssw/sswchain/ChainBlock/List', { token }); + console.log(`\n当前库中:设备 ${devs.length} 条,存证 ${blocks.length} 条`); + console.log('\n查看:'); + console.log(' 前端 http://127.0.0.1:5173/sswdevice/Device'); + console.log(' 前端 http://127.0.0.1:5173/sswchain/ChainBlock'); +} + +main().catch((e) => { + console.error('❌ ' + e.message); + process.exit(1); +}); diff --git a/scripts/sswflow-smoke.sh b/scripts/sswflow-smoke.sh new file mode 100644 index 0000000..a4b9b12 --- /dev/null +++ b/scripts/sswflow-smoke.sh @@ -0,0 +1,226 @@ +#!/usr/bin/env bash +# sswflow 业务链路冒烟 —— 验证「算子目录 → 流程 CRUD → 画布校验 → plan 编译 → 实际运行 → 产物落库」 +# +# 前置:后端已启动(node dist/main.js 或 ./run.sh dev),admin 账号可用。 +# 用法:bash scripts/sswflow-smoke.sh +# 退出码:0 全绿 / 1 有失败 / 2 前置错误 +# +# 实现注记:所有 JSON 载荷都由 node 拼装后写临时文件再 -d @file 传入, +# 避免 shell 引号转义把断言表达式搅乱(引号转义错误会伪装成业务失败)。 +set -u + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT/src/backend" || exit 2 + +B="${B:-http://127.0.0.1:30000}" +NODE_RESOLVED="$(command -v node 2>/dev/null || echo /Users/xs/.workbuddy/binaries/node/versions/22.22.2-3/bin/node)" +NODE="${NODE:-$NODE_RESOLVED}" +PASS=0; FAIL=0 +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +if ! curl --noproxy '*' -s --max-time 3 -o /dev/null "$B/api/oauth/CurrentUser"; then + echo "❌ 后端不可达($B)。先起后端再跑。" + exit 2 +fi + +# jq 风格的取值器:把 stdin JSON 交给 node 求值,表达式作为参数传入 +pick() { $NODE -e " + let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{ + try{ const j=JSON.parse(d); const v=eval(process.argv[1]); console.log(v===undefined?'':String(v)); } + catch(e){ console.log('ERR:'+e.message); } + })" "$1"; } +check() { if [ "$1" = "$2" ]; then echo " ✅ $3 ($2)"; PASS=$((PASS+1)); else echo " ❌ $3 期望=$1 实际=$2"; FAIL=$((FAIL+1)); fi; } +checkne() { if [ "$1" != "$2" ]; then echo " ✅ $3 (=$2)"; PASS=$((PASS+1)); else echo " ❌ $3 期望≠$1 实际=$2"; FAIL=$((FAIL+1)); fi; } +info() { echo " ℹ️ $1"; } + +enc() { $NODE -e "const C=require('crypto-js');const k=C.enc.Utf8.parse(C.MD5('EY8WePvjM5GGwQzn').toString());const s=C.enc.Utf8.parse(C.MD5('$1').toString());console.log(C.AES.encrypt(s,k,{mode:C.mode.ECB,padding:C.pad.Pkcs7}).ciphertext.toString(C.enc.Hex))"; } + +LOGIN=$(curl --noproxy '*' -s -X POST "$B/api/oauth/Login" \ + -H 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode "account=admin" --data-urlencode "password=$(enc 123456)" --data-urlencode "grant_type=password") +TOKEN=$(echo "$LOGIN" | pick 'j.data.token') +[ -z "$TOKEN" ] && { echo "❌ admin 登录失败"; exit 2; } +AUTH="Authorization: bearer $TOKEN" + +echo "== 1) 算子目录(19 个算子 + 能力映射)==" +CAT=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/Operator/Catalog" -H "$AUTH") +check 200 "$(echo "$CAT" | pick 'j.code')" "Catalog 返回 200" +check 19 "$(echo "$CAT" | pick 'j.data.categories.flatMap(c=>c.operators||[]).length')" "算子总数 19" +check 7 "$(echo "$CAT" | pick 'j.data.categories.length')" "分类数 7" +check 19 "$(echo "$CAT" | pick 'j.data.categories.flatMap(c=>c.operators||[]).filter(o=>o.mpc&&o.mpc.status).length')" "每个算子都有 mpc 能力状态" + +echo "== 2) 引擎信息(驱动 + 能力分布)==" +ENG=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/Engine/Info" -H "$AUTH") +check 200 "$(echo "$ENG" | pick 'j.code')" "Engine/Info 返回 200" +check 19 "$(echo "$ENG" | pick 'j.data.capabilities.length')" "能力映射 19 条" +check 19 "$(echo "$ENG" | pick 'j.data.summary.native+j.data.summary.partial+j.data.summary.local+j.data.summary.unsupported')" "四类状态之和 = 19" +info "驱动=$(echo "$ENG" | pick 'j.data.driver') 分布=$(echo "$ENG" | pick 'JSON.stringify(j.data.summary)')" + +echo "== 3) 流程 CRUD ==" +printf '%s' '{"name":"冒烟流程","desc":"sswflow-smoke","steps":"[]","edges":"[]"}' > "$TMP/new.json" +NF=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Save" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/new.json") +check 200 "$(echo "$NF" | pick 'j.code')" "新建流程" +FID=$(echo "$NF" | pick 'j.data.id') +checkne 0 "${#FID}" "流程 id 非空 (${#FID} 位)" + +# 合法国布:source.dataset(无输入) → prep.sample(in) → model.lr.train(in) → sink.export(in) +# 必填参数按 catalog 契约填齐:lr.train.labelColumn / sink.export.targetParty+fileName +$NODE -e " +const steps=[ + {stepId:'s1',operatorKey:'source.dataset',label:'数据集',x:40,y:60,params:{datasetId:'ds-001'}}, + {stepId:'s2',operatorKey:'prep.sample',label:'抽样',x:260,y:60,params:{}}, + {stepId:'s3',operatorKey:'model.lr.train',label:'逻辑回归',x:480,y:60,params:{labelColumn:'y'}}, + {stepId:'s4',operatorKey:'sink.export',label:'导出',x:700,y:60,params:{targetParty:'alice',fileName:'out.csv'}} +]; +const edges=[ + {edgeId:'e1',sourceStepId:'s1',sourcePort:'out',targetStepId:'s2',targetPort:'in'}, + {edgeId:'e2',sourceStepId:'s2',sourcePort:'out',targetStepId:'s3',targetPort:'in'}, + {edgeId:'e3',sourceStepId:'s3',sourcePort:'model',targetStepId:'s4',targetPort:'in'} +]; +require('fs').writeFileSync('$TMP/canvas.json', JSON.stringify({id:'$FID',steps,edges})); +" +CV=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Canvas" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/canvas.json") +check 200 "$(echo "$CV" | pick 'j.code')" "画布保存" + +echo "== 4) 画布校验(合法画布应通过)==" +printf '%s' "{\"id\":\"$FID\"}" > "$TMP/vid.json" +VAL=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Validate" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/vid.json") +check 200 "$(echo "$VAL" | pick 'j.code')" "校验返回 200" +check "true" "$(echo "$VAL" | pick 'j.data.valid')" "校验通过" +check 4 "$(echo "$VAL" | pick 'j.data.order.length')" "拓扑序 4 个节点" +check 0 "$(echo "$VAL" | pick 'j.data.issues.filter(i=>i.level==="ERROR").length')" "无 ERROR 级问题" + +echo "== 5) 必填参数缺失应被检出 ==" +$NODE -e " +const steps=[ + {stepId:'s1',operatorKey:'source.dataset',label:'数据集',x:40,y:60,params:{datasetId:'ds-001'}}, + {stepId:'s2',operatorKey:'model.lr.train',label:'逻辑回归',x:260,y:60,params:{}}, + {stepId:'s3',operatorKey:'sink.export',label:'导出',x:480,y:60,params:{targetParty:'alice',fileName:'out.csv'}} +]; +const edges=[ + {edgeId:'e1',sourceStepId:'s1',sourcePort:'out',targetStepId:'s2',targetPort:'in'}, + {edgeId:'e2',sourceStepId:'s2',sourcePort:'model',targetStepId:'s3',targetPort:'in'} +]; +require('fs').writeFileSync('$TMP/canvas2.json', JSON.stringify({id:'$FID',steps,edges})); +" +curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Canvas" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/canvas2.json" > /dev/null +VAL2=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Validate" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/vid.json") +check "false" "$(echo "$VAL2" | pick 'j.data.valid')" "缺必填参数 → valid=false" +checkne 0 "$(echo "$VAL2" | pick 'j.data.issues.length')" "回报 issue 明细" + +echo "== 6) 端口未连线应被检出 ==" +$NODE -e " +const steps=[ + {stepId:'s1',operatorKey:'prep.intersect',label:'求交集',x:40,y:60,params:{leftKeys:['id'],rightKeys:['id'],protocol:'psi',receiver:'alice'}}, + {stepId:'s2',operatorKey:'source.dataset',label:'数据集',x:260,y:60,params:{datasetId:'ds-001'}} +]; +const edges=[{edgeId:'e1',sourceStepId:'s2',sourcePort:'out',targetStepId:'s1',targetPort:'left'}]; +require('fs').writeFileSync('$TMP/canvas3.json', JSON.stringify({id:'$FID',steps,edges})); +" +curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Canvas" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/canvas3.json" > /dev/null +VAL3=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Validate" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/vid.json") +check "false" "$(echo "$VAL3" | pick 'j.data.valid')" "right 端口未连线 → valid=false" +checkne 0 "$(echo "$VAL3" | pick 'j.data.issues.filter(i=>i.message.includes("右表")).length')" "报出「右表」端口未连线" + +echo "== 7) 环检测 ==" +$NODE -e " +const steps=[ + {stepId:'s1',operatorKey:'prep.sample',label:'a',x:0,y:0,params:{}}, + {stepId:'s2',operatorKey:'prep.sample',label:'b',x:0,y:0,params:{}} +]; +const edges=[ + {edgeId:'e1',sourceStepId:'s1',sourcePort:'out',targetStepId:'s2',targetPort:'in'}, + {edgeId:'e2',sourceStepId:'s2',sourcePort:'out',targetStepId:'s1',targetPort:'in'} +]; +require('fs').writeFileSync('$TMP/canvas4.json', JSON.stringify({id:'$FID',steps,edges})); +" +curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Canvas" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/canvas4.json" > /dev/null +VAL4=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Validate" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/vid.json") +check "false" "$(echo "$VAL4" | pick 'j.data.valid')" "有环 → valid=false" + +echo "== 8) 恢复合法画布 + plan 编译 ==" +curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/Flow/Canvas" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/canvas.json" > /dev/null +PLAN=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/Flow/CompilePlan?id=$FID" -H "$AUTH") +check 200 "$(echo "$PLAN" | pick 'j.code')" "CompilePlan 返回 200" +check 4 "$(echo "$PLAN" | pick 'j.data.plan.split("\n").filter(l=>l.trim().startsWith("job ")).length')" "plan 含 4 个 job" +check 1 "$(echo "$PLAN" | pick 'j.data.command.includes("mpc orch run")?1:0')" "命令含 mpc orch run" +checkne 0 "$(echo "$PLAN" | pick 'j.data.sites.length')" "站点列表非空" + +echo "== 9) 实际运行(异步,等收敛)==" +printf '%s' "{\"flowId\":\"$FID\",\"trigger\":\"MANUAL\",\"mode\":\"FULL\"}" > "$TMP/run.json" +RUN=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/FlowRun/Start" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/run.json") +check 200 "$(echo "$RUN" | pick 'j.code')" "启动运行" +RID=$(echo "$RUN" | pick 'j.data.id') +checkne 0 "${#RID}" "runId 非空 (${#RID} 位)" + +STATUS="PENDING" +for i in $(seq 1 25); do + sleep 1 + ST=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Info?id=$RID" -H "$AUTH") + STATUS=$(echo "$ST" | pick 'j.data.status') + case "$STATUS" in SUCCESS|FAILED|STOPPED) break ;; esac +done +info "运行终态 = $STATUS" +check "SUCCESS" "$STATUS" "运行成功收敛" + +echo "== 10) 步骤记录(4 步全 SUCCESS,拓扑序 1..4)==" +ST=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Steps?runId=$RID" -H "$AUTH") +check 4 "$(echo "$ST" | pick 'j.data.length')" "步骤数 4" +check 4 "$(echo "$ST" | pick 'j.data.filter(s=>s.status==="SUCCESS").length')" "全部 SUCCESS" +check "1,2,3,4" "$(echo "$ST" | pick 'j.data.map(s=>s.seq).sort((a,b)=>a-b).join(",")')" "seq 为 1,2,3,4" + +echo "== 11) 事件流 ==" +EV=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Events?runId=$RID" -H "$AUTH") +checkne 0 "$(echo "$EV" | pick 'j.data.length')" "事件数 > 0" +checkne 0 "$(echo "$EV" | pick 'j.data.filter(e=>e.type==="run.status").length')" "含 run.status 事件" +checkne 0 "$(echo "$EV" | pick 'j.data.filter(e=>e.type==="step.status"&&e.status==="SUCCESS").length')" "含 step.status SUCCESS 事件" +check 1 "$(echo "$EV" | pick 'j.data.every((e,i,a)=>i===0||a[i-1].sortCode<=e.sortCode)?1:0')" "sortCode 单调递增" + +echo "== 12) 产物落库 ==" +AR=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Artifacts?runId=$RID" -H "$AUTH") +checkne 0 "$(echo "$AR" | pick 'j.data.length')" "产物数 > 0" + +echo "== 13) 运行模式 SINGLE / UPSTREAM / DOWNSTREAM / RESUME ==" +printf '%s' "{\"flowId\":\"$FID\",\"trigger\":\"MANUAL\",\"mode\":\"SINGLE\",\"stepIds\":[\"s3\"]}" > "$TMP/m1.json" +printf '%s' "{\"flowId\":\"$FID\",\"trigger\":\"MANUAL\",\"mode\":\"UPSTREAM\",\"stepIds\":[\"s4\"]}" > "$TMP/m2.json" +printf '%s' "{\"flowId\":\"$FID\",\"trigger\":\"MANUAL\",\"mode\":\"DOWNSTREAM\",\"stepIds\":[\"s2\"]}" > "$TMP/m3.json" +printf '%s' "{\"flowId\":\"$FID\",\"trigger\":\"MANUAL\",\"mode\":\"RESUME\",\"baseRunId\":\"$RID\"}" > "$TMP/m4.json" +# 逐模式单独记 runId:后续要按模式核对范围语义,不能复用循环里的临时变量 +for f in m1 m2 m3 m4; do + case $f in + m1) L=SINGLE ;; + m2) L=UPSTREAM ;; + m3) L=DOWNSTREAM ;; + m4) L=RESUME ;; + esac + R2=$(curl --noproxy '*' -s -X POST "$B/api/ssw/sswflow/FlowRun/Start" -H "$AUTH" -H 'Content-Type: application/json' -d @"$TMP/$f.json") + check 200 "$(echo "$R2" | pick 'j.code')" "$L 模式启动" + eval "RUNID_${f}=\$(echo \"\$R2\" | pick 'j.data.id')" +done + +echo "== 14) 范围语义(SINGLE 只跑 1 个节点,其余 SKIPPED)==" +sleep 3 +STX=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Steps?runId=$RUNID_m1" -H "$AUTH") +check 4 "$(echo "$STX" | pick 'j.data.length')" "SINGLE 仍预建 4 条步骤记录" +check 3 "$(echo "$STX" | pick 'j.data.filter(s=>s.status==="SKIPPED").length')" "SINGLE 模式 3 节点 SKIPPED" +check 1 "$(echo "$STX" | pick 'j.data.filter(s=>s.status==="SUCCESS").length')" "SINGLE 模式 1 节点 SUCCESS" + +echo "== 14.1) UPSTREAM / DOWNSTREAM 范围 ==" +STU=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Steps?runId=$RUNID_m2" -H "$AUTH") +check 4 "$(echo "$STU" | pick 'j.data.filter(s=>s.status==="SUCCESS").length')" "UPSTREAM(s4) 全链 4 节点执行" +STD=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/FlowRun/Steps?runId=$RUNID_m3" -H "$AUTH") +check 3 "$(echo "$STD" | pick 'j.data.filter(s=>s.status==="SUCCESS").length')" "DOWNSTREAM(s2) 3 节点执行" +check 1 "$(echo "$STD" | pick 'j.data.filter(s=>s.status==="SKIPPED").length')" "DOWNSTREAM(s2) 1 节点 SKIPPED" + +echo "== 15) 软删契约 ==" +DEL=$(curl --noproxy '*' -s -X DELETE "$B/api/ssw/sswflow/Flow/Delete?id=$FID" -H "$AUTH") +check 200 "$(echo "$DEL" | pick 'j.code')" "删除流程" +LEFT=$(curl --noproxy '*' -s "$B/api/ssw/sswflow/Flow/List" -H "$AUTH" | pick "j.data.find(f=>f.id==='$FID')?'still-there':'gone'") +check "gone" "$LEFT" "软删后不再出现在 List" + +echo +echo "--------------------" +echo "PASS=$PASS FAIL=$FAIL" +[ "$FAIL" -eq 0 ] && echo "全绿 ✅" || echo "有失败 ❌" +exit $([ "$FAIL" -eq 0 ] && echo 0 || echo 1) diff --git a/src/backend/db/schema.sql b/src/backend/db/schema.sql new file mode 100644 index 0000000..b758de0 --- /dev/null +++ b/src/backend/db/schema.sql @@ -0,0 +1,301 @@ +-- JNPF 原生 schema(Postgres 方言) +-- 本文件由 scripts/gen-schema.js 从 src/backend/src/**/*.entity.ts 自动生成,请勿手改。 +-- 改列结构请改实体后重跑:node scripts/gen-schema.js +-- +-- 契约(对齐 JNPF / ssw-mvp): +-- f_ 前缀列名、主键 f_id VARCHAR(50)、软删 f_delete_mark(0=正常 1=已删) +-- MVP 期由 TypeORM synchronize 自动建表;迁 JNPF 时关掉 synchronize,直接复用本文件。 + +CREATE TABLE IF NOT EXISTS demo_item ( + f_id VARCHAR(50) PRIMARY KEY, + f_title VARCHAR(255), + f_status VARCHAR(32), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS book_shop_book ( + f_id VARCHAR(50) PRIMARY KEY, + f_title VARCHAR(255), + f_author VARCHAR(100), + f_isbn VARCHAR(32), + f_category VARCHAR(50), + f_price NUMERIC, + f_stock INT DEFAULT 0, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS demo_item ( + f_id VARCHAR(50) PRIMARY KEY, + f_title VARCHAR(255), + f_status VARCHAR(32), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS shop_product ( + f_id VARCHAR(50) PRIMARY KEY, + f_title VARCHAR(255), + f_price NUMERIC, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswchain_chain_block ( + f_id VARCHAR(50) PRIMARY KEY, + f_order_id VARCHAR(200), + f_decision_id VARCHAR(200), + f_result_hash VARCHAR(200), + f_input_hash VARCHAR(200), + f_user_data VARCHAR(400), + f_user_data_ok INT, + f_meas_ok INT, + f_tcb_ok INT, + f_chip_sig INT, + f_link VARCHAR(32), + f_link_binding VARCHAR(200), + f_signatures TEXT, + f_digest VARCHAR(200), + f_hash_suite VARCHAR(32), + f_tx_hash VARCHAR(200), + f_status INT, + f_block_number BIGINT, + f_gas_used VARCHAR(64), + f_contract_address VARCHAR(100), + f_source VARCHAR(32), + f_source_reason VARCHAR(500), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswdevice_device ( + f_id VARCHAR(50) PRIMARY KEY, + f_key VARCHAR(200), + f_site VARCHAR(100), + f_host VARCHAR(200), + f_platform VARCHAR(64), + f_tcb INT, + f_capacity INT, + f_last_seen BIGINT, + f_device_present INT, + f_qemu_present INT, + f_firmware_present INT, + f_image_present INT, + f_kbs_reachable INT, + f_kbc VARCHAR(128), + f_kbs_endpoint VARCHAR(500), + f_measurement VARCHAR(128), + f_descriptor TEXT, + f_online INT, + f_source VARCHAR(32), + f_source_reason VARCHAR(500), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_artifact ( + f_id VARCHAR(50) PRIMARY KEY, + f_run_id VARCHAR(50), + f_step_id VARCHAR(50), + f_port_key VARCHAR(50), + f_type VARCHAR(32), + f_title VARCHAR(255), + f_summary VARCHAR(2000), + f_columns TEXT, + f_rows TEXT, + f_metrics TEXT, + f_uri VARCHAR(1000), + f_row_count INT DEFAULT 0, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_dataset ( + f_id VARCHAR(50) PRIMARY KEY, + f_dataset_code VARCHAR(100), + f_name VARCHAR(255), + f_party_id VARCHAR(50), + f_datasource_id VARCHAR(50), + f_storage_type VARCHAR(50), + f_location VARCHAR(500), + f_desc VARCHAR(1000), + f_row_count INT DEFAULT 0, + f_columns TEXT, + f_external_ref VARCHAR(500), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_dataset_auth ( + f_id VARCHAR(50) PRIMARY KEY, + f_dataset_id VARCHAR(50), + f_project_id VARCHAR(50), + f_auth_status VARCHAR(32), + f_auth_time TIMESTAMP, + f_auth_user_id VARCHAR(50), + f_expire_time TIMESTAMP, + f_reject_reason VARCHAR(1000), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_datasource ( + f_id VARCHAR(50) PRIMARY KEY, + f_name VARCHAR(255), + f_party_id VARCHAR(50), + f_type VARCHAR(50), + f_config TEXT, + f_status VARCHAR(32), + f_desc VARCHAR(1000), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_flow ( + f_id VARCHAR(50) PRIMARY KEY, + f_project_id VARCHAR(50), + f_name VARCHAR(255), + f_desc VARCHAR(1000), + f_steps TEXT, + f_edges TEXT, + f_last_run_id VARCHAR(50), + f_last_run_status VARCHAR(32), + f_last_run_time TIMESTAMP, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_flow_run ( + f_id VARCHAR(50) PRIMARY KEY, + f_flow_id VARCHAR(50), + f_flow_name VARCHAR(255), + f_project_id VARCHAR(50), + f_status VARCHAR(32), + f_trigger VARCHAR(32), + f_operator VARCHAR(50), + f_start_time TIMESTAMP, + f_end_time TIMESTAMP, + f_cost_ms INT DEFAULT 0, + f_error_msg VARCHAR(2000), + f_cancelled_mark INT DEFAULT 0, + f_steps_snapshot TEXT, + f_edges_snapshot TEXT, + f_base_run_id VARCHAR(50), + f_run_mode VARCHAR(32), + f_selected_steps TEXT, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_flow_schedule ( + f_id VARCHAR(50) PRIMARY KEY, + f_flow_id VARCHAR(50), + f_project_id VARCHAR(50), + f_name VARCHAR(255), + f_cron VARCHAR(100), + f_enabled_mark INT DEFAULT 0, + f_next_fire_time TIMESTAMP, + f_last_fire_time TIMESTAMP, + f_last_run_id VARCHAR(50), + f_last_status VARCHAR(32), + f_misfire_policy VARCHAR(32), + f_run_scope VARCHAR(32), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_flow_step_run ( + f_id VARCHAR(50) PRIMARY KEY, + f_run_id VARCHAR(50), + f_step_id VARCHAR(50), + f_operator_key VARCHAR(100), + f_label VARCHAR(255), + f_status VARCHAR(32), + f_progress INT DEFAULT 0, + f_seq INT DEFAULT 0, + f_start_time TIMESTAMP, + f_end_time TIMESTAMP, + f_cost_ms INT DEFAULT 0, + f_error_msg VARCHAR(2000), + f_parties TEXT, + f_params_snapshot TEXT, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_party ( + f_id VARCHAR(50) PRIMARY KEY, + f_party_code VARCHAR(100), + f_name VARCHAR(255), + f_organize_id VARCHAR(50), + f_org_name VARCHAR(255), + f_endpoint VARCHAR(500), + f_role VARCHAR(32), + f_status VARCHAR(32), + f_self_mark INT DEFAULT 0, + f_compute_mode VARCHAR(50), + f_node_config TEXT, + f_cert_pem TEXT, + f_desc VARCHAR(1000), + f_last_heartbeat_time TIMESTAMP, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_project ( + f_id VARCHAR(50) PRIMARY KEY, + f_project_code VARCHAR(100), + f_name VARCHAR(255), + f_desc VARCHAR(1000), + f_owner_party_id VARCHAR(50), + f_compute_mode VARCHAR(50), + f_status VARCHAR(32), + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_project_party ( + f_id VARCHAR(50) PRIMARY KEY, + f_project_id VARCHAR(50), + f_party_id VARCHAR(50), + f_role VARCHAR(32), + f_join_status VARCHAR(32), + f_invite_time TIMESTAMP, + f_join_time TIMESTAMP, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS sswflow_run_event ( + f_id VARCHAR(50) PRIMARY KEY, + f_run_id VARCHAR(50), + f_step_id VARCHAR(50), + f_type VARCHAR(50), + f_status VARCHAR(32), + f_progress INT DEFAULT 0, + f_level VARCHAR(16), + f_message VARCHAR(2000), + f_ts TIMESTAMP, + f_sort_code INT DEFAULT 0, + f_creator_user_id VARCHAR(50), + f_creator_time TIMESTAMP, + f_delete_mark INT DEFAULT 0 +); diff --git a/src/backend/nest-cli.json b/src/backend/nest-cli.json new file mode 100644 index 0000000..d50e6ab --- /dev/null +++ b/src/backend/nest-cli.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src", + "compilerOptions": { "deleteOutDir": true } +} diff --git a/src/backend/package-lock.json b/src/backend/package-lock.json new file mode 100644 index 0000000..59fffe5 --- /dev/null +++ b/src/backend/package-lock.json @@ -0,0 +1,5091 @@ +{ + "name": "ssw-jnpf-lite-react-backend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ssw-jnpf-lite-react-backend", + "version": "0.1.0", + "dependencies": { + "@electric-sql/pglite": "^0.5.8", + "@nestjs/common": "^10.4.0", + "@nestjs/core": "^10.4.0", + "@nestjs/platform-express": "^10.4.0", + "@nestjs/typeorm": "^10.0.2", + "crypto-js": "^4.2.0", + "reflect-metadata": "^0.2.2", + "rxjs": "^7.8.1", + "typeorm": "^0.3.20", + "typeorm-pglite": "^0.3.4" + }, + "devDependencies": { + "@nestjs/cli": "^10.4.0", + "@nestjs/schematics": "^10.1.0", + "@types/crypto-js": "^4.2.2", + "@types/express": "^4.17.21", + "@types/node": "^20.14.0", + "typescript": "^5.4.0" + } + }, + "node_modules/@angular-devkit/core": { + "version": "17.3.11", + "resolved": "https://registry.npmmirror.com/@angular-devkit/core/-/core-17.3.11.tgz", + "integrity": "sha512-vTNDYNsLIWpYk2I969LMQFH29GTsLzxNk/0cLw5q56ARF0v5sIWfHYwGTS88jdDqIpuuettcSczbxeA7EuAmqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "8.12.0", + "ajv-formats": "2.1.1", + "jsonc-parser": "3.2.1", + "picomatch": "4.0.1", + "rxjs": "7.8.1", + "source-map": "0.7.4" + }, + "engines": { + "node": "^18.13.0 || >=20.9.0", + "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", + "yarn": ">= 1.13.0" + }, + "peerDependencies": { + "chokidar": "^3.5.2" + }, + "peerDependenciesMeta": { + "chokidar": { + "optional": true + } + } + }, + "node_modules/@angular-devkit/core/node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmmirror.com/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@angular-devkit/schematics": { + "version": "17.3.11", + "resolved": "https://registry.npmmirror.com/@angular-devkit/schematics/-/schematics-17.3.11.tgz", + "integrity": "sha512-I5wviiIqiFwar9Pdk30Lujk8FczEEc18i22A5c6Z9lbmhPQdTroDnEQdsfXjy404wPe8H62s0I15o4pmMGfTYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@angular-devkit/core": "17.3.11", + "jsonc-parser": "3.2.1", + "magic-string": "0.30.8", + "ora": "5.4.1", + "rxjs": "7.8.1" + }, + "engines": { + "node": "^18.13.0 || >=20.9.0", + "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", + "yarn": ">= 1.13.0" + } + }, + "node_modules/@angular-devkit/schematics-cli": { + "version": "17.3.11", + "resolved": "https://registry.npmmirror.com/@angular-devkit/schematics-cli/-/schematics-cli-17.3.11.tgz", + "integrity": "sha512-kcOMqp+PHAKkqRad7Zd7PbpqJ0LqLaNZdY1+k66lLWmkEBozgq8v4ASn/puPWf9Bo0HpCiK+EzLf0VHE8Z/y6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@angular-devkit/core": "17.3.11", + "@angular-devkit/schematics": "17.3.11", + "ansi-colors": "4.1.3", + "inquirer": "9.2.15", + "symbol-observable": "4.0.0", + "yargs-parser": "21.1.1" + }, + "bin": { + "schematics": "bin/schematics.js" + }, + "engines": { + "node": "^18.13.0 || >=20.9.0", + "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", + "yarn": ">= 1.13.0" + } + }, + "node_modules/@angular-devkit/schematics-cli/node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmmirror.com/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@angular-devkit/schematics-cli/node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@angular-devkit/schematics-cli/node_modules/inquirer": { + "version": "9.2.15", + "resolved": "https://registry.npmmirror.com/inquirer/-/inquirer-9.2.15.tgz", + "integrity": "sha512-vI2w4zl/mDluHt9YEQ/543VTCwPKWiHzKtm9dM2V0NdFcqEexDAjUHzO1oA60HRNaVifGXXM1tRRNluLVHa0Kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ljharb/through": "^2.3.12", + "ansi-escapes": "^4.3.2", + "chalk": "^5.3.0", + "cli-cursor": "^3.1.0", + "cli-width": "^4.1.0", + "external-editor": "^3.1.0", + "figures": "^3.2.0", + "lodash": "^4.17.21", + "mute-stream": "1.0.0", + "ora": "^5.4.1", + "run-async": "^3.0.0", + "rxjs": "^7.8.1", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@angular-devkit/schematics-cli/node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@angular-devkit/schematics-cli/node_modules/run-async": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/run-async/-/run-async-3.0.0.tgz", + "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/@angular-devkit/schematics/node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmmirror.com/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@borewit/text-codec": { + "version": "0.2.2", + "resolved": "https://registry.npmmirror.com/@borewit/text-codec/-/text-codec-0.2.2.tgz", + "integrity": "sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@electric-sql/pglite": { + "version": "0.5.8", + "resolved": "https://registry.npmmirror.com/@electric-sql/pglite/-/pglite-0.5.8.tgz", + "integrity": "sha512-n9tsbUOhwx2epK1V0ZG9Ar4SHWUju04dhmzZXiSBXwBoleOvIfals33NAaWgagQVAL4Rbvx/Ptsu3P+pA09f6Q==", + "license": "Apache-2.0" + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmmirror.com/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.3.0", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-6.3.0.tgz", + "integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "license": "MIT" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.11", + "resolved": "https://registry.npmmirror.com/@jridgewell/source-map/-/source-map-0.3.11.tgz", + "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@ljharb/through": { + "version": "2.3.14", + "resolved": "https://registry.npmmirror.com/@ljharb/through/-/through-2.3.14.tgz", + "integrity": "sha512-ajBvlKpWucBB17FuQYUShqpqy8GRgYEpJW0vWJbUu1CV9lWyrDCapy0lScU8T8Z6qn49sSwJB3+M+evYIdGg+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/@lukeed/csprng": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/@lukeed/csprng/-/csprng-1.1.0.tgz", + "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@nestjs/cli": { + "version": "10.4.9", + "resolved": "https://registry.npmmirror.com/@nestjs/cli/-/cli-10.4.9.tgz", + "integrity": "sha512-s8qYd97bggqeK7Op3iD49X2MpFtW4LVNLAwXFkfbRxKME6IYT7X0muNTJ2+QfI8hpbNx9isWkrLWIp+g5FOhiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@angular-devkit/core": "17.3.11", + "@angular-devkit/schematics": "17.3.11", + "@angular-devkit/schematics-cli": "17.3.11", + "@nestjs/schematics": "^10.0.1", + "chalk": "4.1.2", + "chokidar": "3.6.0", + "cli-table3": "0.6.5", + "commander": "4.1.1", + "fork-ts-checker-webpack-plugin": "9.0.2", + "glob": "10.4.5", + "inquirer": "8.2.6", + "node-emoji": "1.11.0", + "ora": "5.4.1", + "tree-kill": "1.2.2", + "tsconfig-paths": "4.2.0", + "tsconfig-paths-webpack-plugin": "4.2.0", + "typescript": "5.7.2", + "webpack": "5.97.1", + "webpack-node-externals": "3.0.0" + }, + "bin": { + "nest": "bin/nest.js" + }, + "engines": { + "node": ">= 16.14" + }, + "peerDependencies": { + "@swc/cli": "^0.1.62 || ^0.3.0 || ^0.4.0 || ^0.5.0", + "@swc/core": "^1.3.62" + }, + "peerDependenciesMeta": { + "@swc/cli": { + "optional": true + }, + "@swc/core": { + "optional": true + } + } + }, + "node_modules/@nestjs/cli/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/@nestjs/common": { + "version": "10.4.22", + "resolved": "https://registry.npmmirror.com/@nestjs/common/-/common-10.4.22.tgz", + "integrity": "sha512-fxJ4v85nDHaqT1PmfNCQ37b/jcv2OojtXTaK1P2uAXhzLf9qq6WNUOFvxBrV4fhQek1EQoT1o9oj5xAZmv3NRw==", + "license": "MIT", + "dependencies": { + "file-type": "20.4.1", + "iterare": "1.2.1", + "tslib": "2.8.1", + "uid": "2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "class-transformer": "*", + "class-validator": "*", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, + "node_modules/@nestjs/core": { + "version": "10.4.22", + "resolved": "https://registry.npmmirror.com/@nestjs/core/-/core-10.4.22.tgz", + "integrity": "sha512-6IX9+VwjiKtCjx+mXVPncpkQ5ZjKfmssOZPFexmT+6T9H9wZ3svpYACAo7+9e7Nr9DZSoRZw3pffkJP7Z0UjaA==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@nuxtjs/opencollective": "0.3.2", + "fast-safe-stringify": "2.1.1", + "iterare": "1.2.1", + "path-to-regexp": "3.3.0", + "tslib": "2.8.1", + "uid": "2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/microservices": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "@nestjs/websockets": "^10.0.0", + "reflect-metadata": "^0.1.12 || ^0.2.0", + "rxjs": "^7.1.0" + }, + "peerDependenciesMeta": { + "@nestjs/microservices": { + "optional": true + }, + "@nestjs/platform-express": { + "optional": true + }, + "@nestjs/websockets": { + "optional": true + } + } + }, + "node_modules/@nestjs/platform-express": { + "version": "10.4.22", + "resolved": "https://registry.npmmirror.com/@nestjs/platform-express/-/platform-express-10.4.22.tgz", + "integrity": "sha512-ySSq7Py/DFozzZdNDH67m/vHoeVdphDniWBnl6q5QVoXldDdrZIHLXLRMPayTDh5A95nt7jjJzmD4qpTbNQ6tA==", + "license": "MIT", + "dependencies": { + "body-parser": "1.20.4", + "cors": "2.8.5", + "express": "4.22.1", + "multer": "2.0.2", + "tslib": "2.8.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nest" + }, + "peerDependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0" + } + }, + "node_modules/@nestjs/schematics": { + "version": "10.2.3", + "resolved": "https://registry.npmmirror.com/@nestjs/schematics/-/schematics-10.2.3.tgz", + "integrity": "sha512-4e8gxaCk7DhBxVUly2PjYL4xC2ifDFexCqq1/u4TtivLGXotVk0wHdYuPYe1tHTHuR1lsOkRbfOCpkdTnigLVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@angular-devkit/core": "17.3.11", + "@angular-devkit/schematics": "17.3.11", + "comment-json": "4.2.5", + "jsonc-parser": "3.3.1", + "pluralize": "8.0.0" + }, + "peerDependencies": { + "typescript": ">=4.8.2" + } + }, + "node_modules/@nestjs/schematics/node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@nestjs/typeorm": { + "version": "10.0.2", + "resolved": "https://registry.npmmirror.com/@nestjs/typeorm/-/typeorm-10.0.2.tgz", + "integrity": "sha512-H738bJyydK4SQkRCTeh1aFBxoO1E9xdL/HaLGThwrqN95os5mEyAtK7BLADOS+vldP4jDZ2VQPLj4epWwRqCeQ==", + "license": "MIT", + "dependencies": { + "uuid": "9.0.1" + }, + "peerDependencies": { + "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0", + "@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0", + "reflect-metadata": "^0.1.13 || ^0.2.0", + "rxjs": "^7.2.0", + "typeorm": "^0.3.0" + } + }, + "node_modules/@nuxtjs/opencollective": { + "version": "0.3.2", + "resolved": "https://registry.npmmirror.com/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", + "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "consola": "^2.15.0", + "node-fetch": "^2.6.1" + }, + "bin": { + "opencollective": "bin/opencollective.js" + }, + "engines": { + "node": ">=8.0.0", + "npm": ">=5.0.0" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmmirror.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@sqltools/formatter": { + "version": "1.2.5", + "resolved": "https://registry.npmmirror.com/@sqltools/formatter/-/formatter-1.2.5.tgz", + "integrity": "sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==", + "license": "MIT" + }, + "node_modules/@tokenizer/inflate": { + "version": "0.2.7", + "resolved": "https://registry.npmmirror.com/@tokenizer/inflate/-/inflate-0.2.7.tgz", + "integrity": "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "fflate": "^0.8.2", + "token-types": "^6.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/@tokenizer/inflate/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@tokenizer/inflate/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/@tokenizer/token": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/@tokenizer/token/-/token-0.3.0.tgz", + "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", + "license": "MIT" + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmmirror.com/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmmirror.com/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/crypto-js": { + "version": "4.2.2", + "resolved": "https://registry.npmmirror.com/@types/crypto-js/-/crypto-js-4.2.2.tgz", + "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/eslint": { + "version": "9.6.1", + "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-9.6.1.tgz", + "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/eslint-scope": { + "version": "3.7.7", + "resolved": "https://registry.npmmirror.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", + "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/eslint": "*", + "@types/estree": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/express": { + "version": "4.17.25", + "resolved": "https://registry.npmmirror.com/@types/express/-/express-4.17.25.tgz", + "integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "^1" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.9", + "resolved": "https://registry.npmmirror.com/@types/express-serve-static-core/-/express-serve-static-core-4.19.9.tgz", + "integrity": "sha512-QP2ESEe/ImWY0HDwNAnK9PvEffUyhLTnWkk7KXzHfyeWAnlrDe1fN77bXl6ia8KT3wPlmA7t9/VPRpnf4Ex9sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmmirror.com/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "20.19.43", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.19.43.tgz", + "integrity": "sha512-6oYBAi5ikg4Pl+kGsoYtawUMBT2zZMCvPNF7pVLnHZfd1zf38DRiWn/gT01RYCdUqkv7Fhr+C9ot4/tb+2sVvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmmirror.com/@types/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-GZHUBZR9hckSUhrxmp1nG6NwdpM9fCunJwyThLW1X3AyHgd9IlHb6VANpQQqDr2o/qQp6McZ3y/IA2rVzKzSbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.10", + "resolved": "https://registry.npmmirror.com/@types/serve-static/-/serve-static-1.15.10.tgz", + "integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "<1" + } + }, + "node_modules/@types/serve-static/node_modules/@types/send": { + "version": "0.17.6", + "resolved": "https://registry.npmmirror.com/@types/send/-/send-0.17.6.tgz", + "integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/@webassemblyjs/ast": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/ast/-/ast-1.14.1.tgz", + "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/helper-numbers": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2" + } + }, + "node_modules/@webassemblyjs/floating-point-hex-parser": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz", + "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webassemblyjs/helper-api-error": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz", + "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webassemblyjs/helper-buffer": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.14.1.tgz", + "integrity": "sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webassemblyjs/helper-numbers": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz", + "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/floating-point-hex-parser": "1.13.2", + "@webassemblyjs/helper-api-error": "1.13.2", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/helper-wasm-bytecode": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz", + "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webassemblyjs/helper-wasm-section": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.14.1.tgz", + "integrity": "sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/wasm-gen": "1.14.1" + } + }, + "node_modules/@webassemblyjs/ieee754": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/ieee754/-/ieee754-1.13.2.tgz", + "integrity": "sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "node_modules/@webassemblyjs/leb128": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/leb128/-/leb128-1.13.2.tgz", + "integrity": "sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/utf8": { + "version": "1.13.2", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/utf8/-/utf8-1.13.2.tgz", + "integrity": "sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webassemblyjs/wasm-edit": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.14.1.tgz", + "integrity": "sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/helper-wasm-section": "1.14.1", + "@webassemblyjs/wasm-gen": "1.14.1", + "@webassemblyjs/wasm-opt": "1.14.1", + "@webassemblyjs/wasm-parser": "1.14.1", + "@webassemblyjs/wast-printer": "1.14.1" + } + }, + "node_modules/@webassemblyjs/wasm-gen": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.14.1.tgz", + "integrity": "sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/ieee754": "1.13.2", + "@webassemblyjs/leb128": "1.13.2", + "@webassemblyjs/utf8": "1.13.2" + } + }, + "node_modules/@webassemblyjs/wasm-opt": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.14.1.tgz", + "integrity": "sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-buffer": "1.14.1", + "@webassemblyjs/wasm-gen": "1.14.1", + "@webassemblyjs/wasm-parser": "1.14.1" + } + }, + "node_modules/@webassemblyjs/wasm-parser": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.14.1.tgz", + "integrity": "sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@webassemblyjs/helper-api-error": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2", + "@webassemblyjs/ieee754": "1.13.2", + "@webassemblyjs/leb128": "1.13.2", + "@webassemblyjs/utf8": "1.13.2" + } + }, + "node_modules/@webassemblyjs/wast-printer": { + "version": "1.14.1", + "resolved": "https://registry.npmmirror.com/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz", + "integrity": "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@webassemblyjs/ast": "1.14.1", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmmirror.com/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmmirror.com/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/acorn": { + "version": "8.18.0", + "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.18.0.tgz", + "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmmirror.com/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmmirror.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "4.4.0", + "resolved": "https://registry.npmmirror.com/ansis/-/ansis-4.4.0.tgz", + "integrity": "sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==", + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/app-root-path": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/app-root-path/-/app-root-path-3.1.0.tgz", + "integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/array-timsort": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/array-timsort/-/array-timsort-1.0.3.tgz", + "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.24", + "resolved": "https://registry.npmmirror.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.24.tgz", + "integrity": "sha512-hYrgxie335U08WqICoGqKRzV1HFXv6zdxwJE4ekCb80CM9a0SVVsN4QPwT67RraRo+9h8IATk6uxHJw7QSkdOg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmmirror.com/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.29.0", + "resolved": "https://registry.npmmirror.com/browserslist/-/browserslist-4.29.0.tgz", + "integrity": "sha512-3GSvyjvDI4Dur1Meg2BekJquu5uF+9R9a1+5M1Mde192eZoXbeXjzgOsgqPS2V8D5wrrip0gR5Hf/GhWQ9ZzaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.23", + "caniuse-lite": "^1.0.30001810", + "electron-to-chromium": "^1.5.427", + "node-releases": "^2.0.55", + "update-browserslist-db": "^1.3.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmmirror.com/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmmirror.com/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true, + "license": "MIT" + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chrome-trace-event": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", + "integrity": "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0" + } + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmmirror.com/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-table3": { + "version": "0.6.5", + "resolved": "https://registry.npmmirror.com/cli-table3/-/cli-table3-0.6.5.tgz", + "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "string-width": "^4.2.0" + }, + "engines": { + "node": "10.* || >= 12.*" + }, + "optionalDependencies": { + "@colors/colors": "1.5.0" + } + }, + "node_modules/cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 10" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmmirror.com/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/comment-json": { + "version": "4.2.5", + "resolved": "https://registry.npmmirror.com/comment-json/-/comment-json-4.2.5.tgz", + "integrity": "sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-timsort": "^1.0.3", + "core-util-is": "^1.0.3", + "esprima": "^4.0.1", + "has-own-prop": "^2.0.0", + "repeat-string": "^1.6.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "engines": [ + "node >= 6.0" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/consola": { + "version": "2.15.3", + "resolved": "https://registry.npmmirror.com/consola/-/consola-2.15.3.tgz", + "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmmirror.com/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmmirror.com/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/cosmiconfig": { + "version": "8.3.6", + "resolved": "https://registry.npmmirror.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz", + "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "import-fresh": "^3.3.0", + "js-yaml": "^4.1.0", + "parse-json": "^5.2.0", + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.", + "license": "MIT" + }, + "node_modules/dayjs": { + "version": "1.11.23", + "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.23.tgz", + "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmmirror.com/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/dedent": { + "version": "1.7.2", + "resolved": "https://registry.npmmirror.com/dedent/-/dedent-1.7.2.tgz", + "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==", + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmmirror.com/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "license": "MIT" + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.430", + "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz", + "integrity": "sha512-e1QEj72Y4zd8RlNZVmoTg+iCOSVwpk05IOiiQwdrkwCSVlZfPthevErhE+nckGd2YbsXfp1SkisznhGVIXP2NQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.25.1", + "resolved": "https://registry.npmmirror.com/enhanced-resolve/-/enhanced-resolve-5.25.1.tgz", + "integrity": "sha512-nGXts5znJzmWPu+mIE9izCOzdg63oJca2mDzGWWTth7sr4aCToKcoyFVBQwN75Ij5Pf6p510EwkTqViTRzDV+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/error-ex": { + "version": "1.3.4", + "resolved": "https://registry.npmmirror.com/error-ex/-/error-ex-1.3.4.tgz", + "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmmirror.com/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmmirror.com/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmmirror.com/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmmirror.com/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "license": "MIT", + "dependencies": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.8", + "resolved": "https://registry.npmmirror.com/fast-uri/-/fast-uri-3.1.8.tgz", + "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmmirror.com/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "license": "MIT" + }, + "node_modules/figures": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/file-type": { + "version": "20.4.1", + "resolved": "https://registry.npmmirror.com/file-type/-/file-type-20.4.1.tgz", + "integrity": "sha512-hw9gNZXUfZ02Jo0uafWLaFVPter5/k2rfcrjFJJHX/77xtSDOfJuEFb6oKlFV86FLP1SuyHMW1PSk0U9M5tKkQ==", + "license": "MIT", + "dependencies": { + "@tokenizer/inflate": "^0.2.6", + "strtok3": "^10.2.0", + "token-types": "^6.0.0", + "uint8array-extras": "^1.4.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/file-type?sponsor=1" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmmirror.com/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fork-ts-checker-webpack-plugin": { + "version": "9.0.2", + "resolved": "https://registry.npmmirror.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-9.0.2.tgz", + "integrity": "sha512-Uochze2R8peoN1XqlSi/rGUkDQpRogtLFocP9+PGu68zk1BDAKXfdeCdyVZpgTk8V8WFVQXdEz426VKjXLO1Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.16.7", + "chalk": "^4.1.2", + "chokidar": "^3.5.3", + "cosmiconfig": "^8.2.0", + "deepmerge": "^4.2.2", + "fs-extra": "^10.0.0", + "memfs": "^3.4.1", + "minimatch": "^3.0.4", + "node-abort-controller": "^3.0.1", + "schema-utils": "^3.1.1", + "semver": "^7.3.5", + "tapable": "^2.2.1" + }, + "engines": { + "node": ">=12.13.0", + "yarn": ">=1.0.0" + }, + "peerDependencies": { + "typescript": ">3.6.0", + "webpack": "^5.11.0" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmmirror.com/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmmirror.com/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs-monkey": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/fs-monkey/-/fs-monkey-1.1.0.tgz", + "integrity": "sha512-QMUezzXWII9EV5aTFXW1UBVUO77wYPpjqIF8/AviUCThNeSYZykpoTixUeaNNBwmCev0AMDWMAni+f8Hxb1IFw==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmmirror.com/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.1.7", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.1.7.tgz", + "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-own-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/has-own-prop/-/has-own-prop-2.0.0.tgz", + "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/inquirer": { + "version": "8.2.6", + "resolved": "https://registry.npmmirror.com/inquirer/-/inquirer-8.2.6.tgz", + "integrity": "sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.1", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.21", + "mute-stream": "0.0.8", + "ora": "^5.4.1", + "run-async": "^2.4.0", + "rxjs": "^7.5.5", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6", + "wrap-ansi": "^6.0.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmmirror.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmmirror.com/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmmirror.com/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmmirror.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/iterare": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/iterare/-/iterare-1.2.1.tgz", + "integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==", + "license": "ISC", + "engines": { + "node": ">=6" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmmirror.com/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/jest-worker": { + "version": "27.5.1", + "resolved": "https://registry.npmmirror.com/jest-worker/-/jest-worker-27.5.1.tgz", + "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.3.2", + "resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.1", + "resolved": "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.2.1.tgz", + "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmmirror.com/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmmirror.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/loader-runner": { + "version": "4.3.2", + "resolved": "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.2.tgz", + "integrity": "sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.11.5" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, + "node_modules/magic-string": { + "version": "0.30.8", + "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.8.tgz", + "integrity": "sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmmirror.com/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/memfs": { + "version": "3.5.3", + "resolved": "https://registry.npmmirror.com/memfs/-/memfs-3.5.3.tgz", + "integrity": "sha512-UERzLsxzllchadvbPs5aolHh65ISpKpM+ccLbOJ8/vvpBKmAWf+la7dXFy7Mr0ySHbdHrFv5kGFCUHHe6GFEmw==", + "dev": true, + "license": "Unlicense", + "dependencies": { + "fs-monkey": "^1.0.4" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmmirror.com/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/multer": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/multer/-/multer-2.0.2.tgz", + "integrity": "sha512-u7f2xaZ/UG8oLXHvtF/oWTRvT44p9ecwBBqTwgJVq0+4BW1g8OW01TyMEGWBHbyMOYVHXslaut7qEQ1meATXgw==", + "license": "MIT", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.6.0", + "concat-stream": "^2.0.0", + "mkdirp": "^0.5.6", + "object-assign": "^4.1.1", + "type-is": "^1.6.18", + "xtend": "^4.0.2" + }, + "engines": { + "node": ">= 10.16.0" + } + }, + "node_modules/mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmmirror.com/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true, + "license": "ISC" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmmirror.com/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-abort-controller": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/node-abort-controller/-/node-abort-controller-3.1.1.tgz", + "integrity": "sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-emoji": { + "version": "1.11.0", + "resolved": "https://registry.npmmirror.com/node-emoji/-/node-emoji-1.11.0.tgz", + "integrity": "sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmmirror.com/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-releases": { + "version": "2.0.55", + "resolved": "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.55.tgz", + "integrity": "sha512-mIrE/Cw9y+9Au6dS5vDKDhQza9YvG6w+ZrS6X+ZzA7yFW/soAeaups4Qzn1bL6g5FVy8WtP79+0j82oPIbqRjQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmmirror.com/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "license": "BlueOak-1.0.0" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmmirror.com/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmmirror.com/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmmirror.com/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-to-regexp": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", + "license": "MIT" + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.1.tgz", + "integrity": "sha512-xUXwsxNjwTQ8K3GnT4pCJm+xq3RUPQbmkYJTP5aFIfNIvbcc/4MUxgBaaRSZJ6yGJZiGSyYlM6MzwTsRk8SYCg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.8", + "resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmmirror.com/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmmirror.com/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/readdirp/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/reflect-metadata": { + "version": "0.2.2", + "resolved": "https://registry.npmmirror.com/reflect-metadata/-/reflect-metadata-0.2.2.tgz", + "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", + "license": "Apache-2.0" + }, + "node_modules/repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmmirror.com/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/restore-cursor/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmmirror.com/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmmirror.com/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/schema-utils": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/schema-utils/-/schema-utils-3.3.0.tgz", + "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/schema-utils/node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/schema-utils/node_modules/ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "ajv": "^6.9.1" + } + }, + "node_modules/schema-utils/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmmirror.com/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmmirror.com/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/sha.js": { + "version": "2.4.12", + "resolved": "https://registry.npmmirror.com/sha.js/-/sha.js-2.4.12.tgz", + "integrity": "sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==", + "license": "(MIT AND BSD-3-Clause)", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1", + "to-buffer": "^1.2.0" + }, + "bin": { + "sha.js": "bin.js" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 8" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmmirror.com/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sql-highlight": { + "version": "6.1.0", + "resolved": "https://registry.npmmirror.com/sql-highlight/-/sql-highlight-6.1.0.tgz", + "integrity": "sha512-ed7OK4e9ywpE7pgRMkMQmZDPKSVdm0oX5IEtZiKnFucSF0zu6c80GZBe38UqHuVhTWJ9xsKgSMjCG2bml86KvA==", + "funding": [ + "https://github.com/scriptcoded/sql-highlight?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/scriptcoded" + } + ], + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/strtok3": { + "version": "10.3.5", + "resolved": "https://registry.npmmirror.com/strtok3/-/strtok3-10.3.5.tgz", + "integrity": "sha512-ki4hZQfh5rX0QDLLkOCj+h+CVNkqmp/CMf8v8kZpkNVK6jGQooMytqzLZYUVYIZcFZ6yDB70EfD8POcFXiF5oA==", + "license": "MIT", + "dependencies": { + "@tokenizer/token": "^0.3.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/symbol-observable": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/symbol-observable/-/symbol-observable-4.0.0.tgz", + "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/terser": { + "version": "5.51.2", + "resolved": "https://registry.npmmirror.com/terser/-/terser-5.51.2.tgz", + "integrity": "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.15.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser-webpack-plugin": { + "version": "5.6.1", + "resolved": "https://registry.npmmirror.com/terser-webpack-plugin/-/terser-webpack-plugin-5.6.1.tgz", + "integrity": "sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "jest-worker": "^27.4.5", + "schema-utils": "^4.3.0", + "terser": "^5.31.1" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + }, + "peerDependenciesMeta": { + "@minify-html/node": { + "optional": true + }, + "@swc/core": { + "optional": true + }, + "@swc/css": { + "optional": true + }, + "@swc/html": { + "optional": true + }, + "clean-css": { + "optional": true + }, + "cssnano": { + "optional": true + }, + "csso": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "html-minifier-terser": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "postcss": { + "optional": true + }, + "uglify-js": { + "optional": true + } + } + }, + "node_modules/terser-webpack-plugin/node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/terser-webpack-plugin/node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/terser-webpack-plugin/node_modules/schema-utils": { + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/schema-utils/-/schema-utils-4.5.0.tgz", + "integrity": "sha512-zJlMCZ0cAR5p/Y4oVpRoqioDMJcGxaXRrQ/4rP4WyR84vc5z/DolXdbvXeDpTwbtocDFr2rhPqHPErDCUtz2kA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.15", + "ajv": "^8.20.0", + "ajv-formats": "^3.0.1", + "ajv-keywords": "^5.1.0" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmmirror.com/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmmirror.com/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/to-buffer": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/to-buffer/-/to-buffer-1.2.2.tgz", + "integrity": "sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==", + "license": "MIT", + "dependencies": { + "isarray": "^2.0.5", + "safe-buffer": "^5.2.1", + "typed-array-buffer": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/token-types": { + "version": "6.1.2", + "resolved": "https://registry.npmmirror.com/token-types/-/token-types-6.1.2.tgz", + "integrity": "sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww==", + "license": "MIT", + "dependencies": { + "@borewit/text-codec": "^0.2.1", + "@tokenizer/token": "^0.3.0", + "ieee754": "^1.2.1" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "json5": "^2.2.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tsconfig-paths-webpack-plugin": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.2.0.tgz", + "integrity": "sha512-zbem3rfRS8BgeNK50Zz5SIQgXzLafiHjOwUAvk/38/o1jHn/V5QAgVUcz884or7WYcPaH3N2CIfUc2u0ul7UcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.7.0", + "tapable": "^2.2.1", + "tsconfig-paths": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmmirror.com/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmmirror.com/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmmirror.com/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, + "node_modules/typeorm": { + "version": "0.3.31", + "resolved": "https://registry.npmmirror.com/typeorm/-/typeorm-0.3.31.tgz", + "integrity": "sha512-6u9EFtdLBgHjnPm78NStVeM+I/1MolTzKykDDcydzKUkh6E++YS6XViU/fePJbvDvEGU4Xq34KOM/CLeer9I2A==", + "license": "MIT", + "dependencies": { + "@sqltools/formatter": "^1.2.5", + "ansis": "^4.3.1", + "app-root-path": "^3.1.0", + "buffer": "^6.0.3", + "dayjs": "^1.11.21", + "debug": "^4.4.3", + "dedent": "^1.7.2", + "dotenv": "^16.6.1", + "glob": "^10.5.0", + "reflect-metadata": "^0.2.2", + "sha.js": "^2.4.12", + "sql-highlight": "^6.1.0", + "tslib": "^2.8.1", + "uuid": "^11.1.1", + "yargs": "^17.7.3" + }, + "bin": { + "typeorm": "cli.js", + "typeorm-ts-node-commonjs": "cli-ts-node-commonjs.js", + "typeorm-ts-node-esm": "cli-ts-node-esm.js" + }, + "engines": { + "node": ">=16.13.0" + }, + "funding": { + "url": "https://opencollective.com/typeorm" + }, + "peerDependencies": { + "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", + "@sap/hana-client": "^2.14.22", + "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", + "ioredis": "^5.0.4", + "mongodb": "^5.8.0 || ^6.0.0", + "mssql": "^9.1.1 || ^10.0.0 || ^11.0.0 || ^12.0.0", + "mysql2": "^2.2.5 || ^3.0.1", + "oracledb": "^6.3.0 || ^7.0.0", + "pg": "^8.5.1", + "pg-native": "^3.0.0", + "pg-query-stream": "^4.0.0", + "redis": "^3.1.1 || ^4.0.0 || ^5.0.14", + "sql.js": "^1.4.0", + "sqlite3": "^5.0.3 || ^6.0.0", + "ts-node": "^10.7.0", + "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0" + }, + "peerDependenciesMeta": { + "@google-cloud/spanner": { + "optional": true + }, + "@sap/hana-client": { + "optional": true + }, + "better-sqlite3": { + "optional": true + }, + "ioredis": { + "optional": true + }, + "mongodb": { + "optional": true + }, + "mssql": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-native": { + "optional": true + }, + "pg-query-stream": { + "optional": true + }, + "redis": { + "optional": true + }, + "sql.js": { + "optional": true + }, + "sqlite3": { + "optional": true + }, + "ts-node": { + "optional": true + }, + "typeorm-aurora-data-api-driver": { + "optional": true + } + } + }, + "node_modules/typeorm-pglite": { + "version": "0.3.4", + "resolved": "https://registry.npmmirror.com/typeorm-pglite/-/typeorm-pglite-0.3.4.tgz", + "integrity": "sha512-fiiCFVep7LZzIjAOw2WwepXPpgXXYCbq6cv+HffF02TPh72j1epJeaGbYjE3AMxkqcGl5SKdCwXHyw8juRJAZA==", + "license": "MIT", + "peerDependencies": { + "@electric-sql/pglite": ">= 0.2.13" + } + }, + "node_modules/typeorm/node_modules/brace-expansion": { + "version": "2.1.7", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.1.7.tgz", + "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typeorm/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/typeorm/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/typeorm/node_modules/glob": { + "version": "10.5.0", + "resolved": "https://registry.npmmirror.com/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typeorm/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typeorm/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/typeorm/node_modules/uuid": { + "version": "11.1.1", + "resolved": "https://registry.npmmirror.com/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/uid": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/uid/-/uid-2.0.2.tgz", + "integrity": "sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==", + "license": "MIT", + "dependencies": { + "@lukeed/csprng": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/uint8array-extras": { + "version": "1.5.0", + "resolved": "https://registry.npmmirror.com/uint8array-extras/-/uint8array-extras-1.5.0.tgz", + "integrity": "sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.3", + "resolved": "https://registry.npmmirror.com/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", + "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmmirror.com/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/watchpack": { + "version": "2.5.2", + "resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.5.2.tgz", + "integrity": "sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, + "license": "MIT", + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/webpack": { + "version": "5.97.1", + "resolved": "https://registry.npmmirror.com/webpack/-/webpack-5.97.1.tgz", + "integrity": "sha512-EksG6gFY3L1eFMROS/7Wzgrii5mBAFe4rIr3r2BTfo7bcc+DWwFZ4OJ/miOuHJO/A85HwyI4eQ0F6IKXesO7Fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/eslint-scope": "^3.7.7", + "@types/estree": "^1.0.6", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wasm-edit": "^1.14.1", + "@webassemblyjs/wasm-parser": "^1.14.1", + "acorn": "^8.14.0", + "browserslist": "^4.24.0", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.17.1", + "es-module-lexer": "^1.2.1", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.11", + "json-parse-even-better-errors": "^2.3.1", + "loader-runner": "^4.2.0", + "mime-types": "^2.1.27", + "neo-async": "^2.6.2", + "schema-utils": "^3.2.0", + "tapable": "^2.1.1", + "terser-webpack-plugin": "^5.3.10", + "watchpack": "^2.4.1", + "webpack-sources": "^3.2.3" + }, + "bin": { + "webpack": "bin/webpack.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } + } + }, + "node_modules/webpack-node-externals": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/webpack-node-externals/-/webpack-node-externals-3.0.0.tgz", + "integrity": "sha512-LnL6Z3GGDPht/AigwRh2dvL9PQPFQ8skEpVrWZXLWBYmqcaojHNN0onvHzie6rq7EWKrrBfPYqNEzTJgiwEQDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/webpack-sources": { + "version": "3.5.1", + "resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.5.1.tgz", + "integrity": "sha512-jyuiGJdtvY434z5bUZrjz67v76/ePNvFZTp9Mdz29IlH4+GPsgyGjiv0fKI+M7BdkU6ADjulUcKAd3tUK3WlEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.23", + "resolved": "https://registry.npmmirror.com/which-typed-array/-/which-typed-array-1.1.23.tgz", + "integrity": "sha512-JMh8aK+1B/0bk/YNupICmH5MgCq6yNLKYQUfsZtSDLLCCmxUkHjUY+oOlIa90lO7lHN1woAfpenLdlKpXy9o+A==", + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmmirror.com/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.3", + "resolved": "https://registry.npmmirror.com/yargs/-/yargs-17.7.3.tgz", + "integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==", + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmmirror.com/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/src/backend/package.json b/src/backend/package.json new file mode 100644 index 0000000..d6b39ae --- /dev/null +++ b/src/backend/package.json @@ -0,0 +1,31 @@ +{ + "name": "ssw-jnpf-lite-react-backend", + "version": "0.1.0", + "private": true, + "scripts": { + "build": "nest build", + "start": "nest start", + "start:dev": "nest start --watch", + "start:prod": "node dist/main.js" + }, + "dependencies": { + "@electric-sql/pglite": "^0.5.8", + "@nestjs/common": "^10.4.0", + "@nestjs/core": "^10.4.0", + "@nestjs/platform-express": "^10.4.0", + "@nestjs/typeorm": "^10.0.2", + "crypto-js": "^4.2.0", + "reflect-metadata": "^0.2.2", + "rxjs": "^7.8.1", + "typeorm": "^0.3.20", + "typeorm-pglite": "^0.3.4" + }, + "devDependencies": { + "@nestjs/cli": "^10.4.0", + "@nestjs/schematics": "^10.1.0", + "@types/crypto-js": "^4.2.2", + "@types/express": "^4.17.21", + "@types/node": "^20.14.0", + "typescript": "^5.4.0" + } +} diff --git a/src/backend/src/app.module.ts b/src/backend/src/app.module.ts new file mode 100644 index 0000000..1ca0d19 --- /dev/null +++ b/src/backend/src/app.module.ts @@ -0,0 +1,38 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { PGliteDriver } from 'typeorm-pglite'; +import { AuthModule } from './auth/auth.module'; +import { DemoModule } from './demo/demo.module'; +import { SysModule } from './sys/sys.module'; +import { ShopModule } from './shop/shop.module'; +import { BooksModule } from './books/books.module'; +import { SswflowModule } from './sswflow/sswflow.module'; +import { SswdeviceModule } from './sswdevice/sswdevice.module'; +import { SswchainModule } from './sswchain/sswchain.module'; + +@Module({ + imports: [ + TypeOrmModule.forRoot({ + // 嵌入式 Postgres(WASM,零服务进程 / 零 docker),引擎即真 PostgreSQL, + // 故 f_ 列 / varchar(50) / db/schema.sql 的 Postgres 方言契约完全保留。 + type: 'postgres', + driver: new PGliteDriver({ + // memory:// = 纯内存(重启即清空,适合原型);如需持久化设 PGLLITE_DIR=./.pglite + dataDir: process.env.PGLLITE_DIR || 'memory://', + }).driver, + autoLoadEntities: true, + // MVP 期自动建表方便迭代;迁 JNPF 时关掉,改用 db/schema.sql 显式建表 + synchronize: process.env.PG_SYNC === 'false' ? false : true, + entities: [__dirname + '/**/*.entity{.ts,.js}'], + }), + AuthModule, + DemoModule, + SysModule, + ShopModule, + BooksModule, + SswflowModule, + SswdeviceModule, + SswchainModule, + ], +}) +export class AppModule {} diff --git a/src/backend/src/auth/auth.controller.ts b/src/backend/src/auth/auth.controller.ts new file mode 100644 index 0000000..a28b587 --- /dev/null +++ b/src/backend/src/auth/auth.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Get, Post, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from './auth.service'; +import { PermissionService } from '../sys/permission.service'; + +/** + * 轻量登录端点 —— 契约与 JNPF /api/oauth/* 一致: + * POST /api/oauth/Login(x-www-form-urlencoded: account/password(加密hex)/grant_type) + * GET /api/oauth/CurrentUser -> { userInfo, menuList } ← menuList 由 PermissionService 按 base_authorize 计算 + * 迁 JNPF 时删除本控制器,由 jnpf-oauth-controller 接管(路径/返回同形,前端零改)。 + */ +@Controller('api/oauth') +export class AuthController { + constructor( + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + @Post('Login') + async login(@Body() body: Record) { + const account = body['account']; + const encrypted = body['password']; + const grantType = body['grant_type']; + if (!account || !encrypted) return ActionResult.fail(400, '缺少 account / password'); + if (grantType && grantType !== 'password') return ActionResult.fail(400, '不支持的 grant_type'); + try { + const data = await this.auth.login(account, encrypted); + return ActionResult.success(data); + } catch (e: any) { + return ActionResult.fail(400, e.message || '登录失败'); + } + } + + @Get('CurrentUser') + async currentUser(@Req() req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + const menuList = await this.perm.buildMenuList(u.userId, u.isAdmin); + return ActionResult.success({ + userInfo: { + userId: u.userId, + userAccount: u.account, + userName: u.account, + isAdministrator: u.isAdmin === 1, + }, + menuList, + }); + } +} diff --git a/src/backend/src/auth/auth.module.ts b/src/backend/src/auth/auth.module.ts new file mode 100644 index 0000000..e92d111 --- /dev/null +++ b/src/backend/src/auth/auth.module.ts @@ -0,0 +1,14 @@ +import { Module, forwardRef } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { AuthController } from './auth.controller'; +import { AuthService } from './auth.service'; +import { BaseUserEntity } from '../sys/base-user.entity'; +import { SysModule } from '../sys/sys.module'; + +@Module({ + imports: [TypeOrmModule.forFeature([BaseUserEntity]), forwardRef(() => SysModule)], + controllers: [AuthController], + providers: [AuthService], + exports: [AuthService], +}) +export class AuthModule {} diff --git a/src/backend/src/auth/auth.service.ts b/src/backend/src/auth/auth.service.ts new file mode 100644 index 0000000..2521a17 --- /dev/null +++ b/src/backend/src/auth/auth.service.ts @@ -0,0 +1,54 @@ +import { Injectable } from '@nestjs/common'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { decryptToMd5, md5Hex } from '../common/cipher'; +import { BaseUserEntity } from '../sys/base-user.entity'; + +/** + * 登录与 token 校验 —— MVP 用内存态 Map 模拟 JNPF 的 Sa-Token(无 Redis)。 + * 登录比对改为查 base_user 表(密码存 md5(明文),与登录 cipher 解出的值比对)。 + * 迁 JNPF 时整个 AuthService 删掉,由 jnpf-oauth 的 Sa-Token 接管(token→userId 映射也一并消失)。 + */ +export interface TokenUser { + userId: string; + account: string; + isAdmin: number; +} + +@Injectable() +export class AuthService { + private tokens = new Map(); + + constructor( + @InjectRepository(BaseUserEntity) + private readonly userRepo: Repository, + ) {} + + async login( + account: string, + encrypted: string, + ): Promise<{ token: string; expiresIn: number; tokenTypeName: string }> { + const user = await this.userRepo.findOne({ + where: { account, deleteMark: 0 } as any, + }); + if (!user) throw new Error('账号或密码错误'); + const plainMd5 = decryptToMd5(encrypted); + if (!user.password || plainMd5.toLowerCase() !== user.password.toLowerCase()) { + throw new Error('账号或密码错误'); + } + const token = 'lite-' + md5Hex(account + Date.now() + Math.random()); + this.tokens.set(token, { + userId: user.id, + account: user.account, + isAdmin: user.isAdministrator, + }); + return { token, expiresIn: 7200, tokenTypeName: 'bearer' }; + } + + /** 校验 Authorization 头(去掉 bearer 前缀)→ 返回用户信息;未登录返回 null(对应 Sa-Token 的 600 拦截) */ + resolve(authHeader?: string): TokenUser | null { + if (!authHeader) return null; + const token = authHeader.replace(/^bearer /i, ''); + return this.tokens.get(token) || null; + } +} diff --git a/src/backend/src/books/book.controller.ts b/src/backend/src/books/book.controller.ts new file mode 100644 index 0000000..0cfcdee --- /dev/null +++ b/src/backend/src/books/book.controller.ts @@ -0,0 +1,62 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { BookService } from './book.service'; + +const MODULE_KEY = 'books/Book'; // == base_module.f_url_address == 前端 Route path(去前导斜杠) + +/** + * Book 业务 Controller —— 端点对齐 JNPF: + * GET /api/ssw/books/Book/List + * POST /api/ssw/books/Book/Save + * DELETE /api/ssw/books/Book/Delete?id= + * 采用「登录 + 菜单权限」守卫(HOWTO_MODULE.md 模式 B)。 + */ +@Controller('api/ssw/books/Book') +export class BookController { + constructor( + private readonly svc: BookService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} \ No newline at end of file diff --git a/src/backend/src/books/book.entity.ts b/src/backend/src/books/book.entity.ts new file mode 100644 index 0000000..af30fd9 --- /dev/null +++ b/src/backend/src/books/book.entity.ts @@ -0,0 +1,41 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * Book 业务实体 —— 图书超市 (MVP 业务模块)。 + * 列名 / 主键 / numeric 金额 / 软删字段严格对齐 JNPF 形态。 + * 迁 JNPF:本类对应 extends jnpf.base.entity.SuperEntity 的 Java 实体, + * 字段 @TableField("f_title"),表名 book_shop_book。 + */ +@Entity({ name: 'book_shop_book' }) +export class BookEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_title', type: 'varchar', length: 255, nullable: true }) + title: string; + + @Column({ name: 'f_author', type: 'varchar', length: 100, nullable: true }) + author: string; + + @Column({ name: 'f_isbn', type: 'varchar', length: 32, nullable: true }) + isbn: string; + + @Column({ name: 'f_category', type: 'varchar', length: 50, nullable: true }) + category: string; + + // numeric 在 TypeORM 中映射为 string(避免浮点误差) + @Column({ name: 'f_price', type: 'numeric', precision: 12, scale: 2, nullable: true }) + price: string; + + @Column({ name: 'f_stock', type: 'int', nullable: true, default: 0 }) + stock: number; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; +} \ No newline at end of file diff --git a/src/backend/src/books/book.service.ts b/src/backend/src/books/book.service.ts new file mode 100644 index 0000000..36fe6bf --- /dev/null +++ b/src/backend/src/books/book.service.ts @@ -0,0 +1,52 @@ +import { Injectable } from '@nestjs/common'; +import { randomUUID } from 'crypto'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { BookEntity } from './book.entity'; + +@Injectable() +export class BookService { + constructor( + @InjectRepository(BookEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + // 软删过滤 + 创建时间倒序;迁 JNPF 对应 SuperServiceImpl.page(...) + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async save(item: Partial): Promise { + // 主键 36 位 UUID(varchar(50) 装得下) + if (!item.id) { + const ent = this.repo.create({ + id: randomUUID(), + title: item.title, + author: item.author, + isbn: item.isbn, + category: item.category, + price: item.price ?? '0.00', + stock: item.stock ?? 0, + creatorUserId: item.creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as BookEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, id: item.id } as any); + return (await this.repo.save(created)) as unknown as BookEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as BookEntity; + } + + async remove(id: string): Promise { + // 软删:f_delete_mark = 1 + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} \ No newline at end of file diff --git a/src/backend/src/books/books.module.ts b/src/backend/src/books/books.module.ts new file mode 100644 index 0000000..a681bce --- /dev/null +++ b/src/backend/src/books/books.module.ts @@ -0,0 +1,14 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { BookEntity } from './book.entity'; +import { BookService } from './book.service'; +import { BookController } from './book.controller'; +import { AuthModule } from '../auth/auth.module'; +import { SysModule } from '../sys/sys.module'; + +@Module({ + imports: [TypeOrmModule.forFeature([BookEntity]), AuthModule, SysModule], + controllers: [BookController], + providers: [BookService], +}) +export class BooksModule {} \ No newline at end of file diff --git a/src/backend/src/common/action-result.filter.ts b/src/backend/src/common/action-result.filter.ts new file mode 100644 index 0000000..d91cc24 --- /dev/null +++ b/src/backend/src/common/action-result.filter.ts @@ -0,0 +1,70 @@ +import { + ArgumentsHost, + Catch, + ExceptionFilter, + HttpException, + Logger, +} from '@nestjs/common'; +import { ActionResult } from './action-result'; +import { BizException } from './business.exception'; + +/** + * 全局异常过滤器 —— 复刻 JNPF `jnpf.exception.ResultExceptionHand`(@RestControllerAdvice)的语义: + * 1. 所有异常都返回 **HTTP 200 + `ActionResult{code,msg,data}`**(官方也是这个形状,前端只认 body.code) + * 2. 业务异常(BizException)保留自身 code 与 message + * 3. 权限异常 code=403(官方 PEIMISSIONEXP) + * 4. 其余未捕获异常 code=400 + 通用提示,真实堆栈只进服务端日志(避免泄漏内部信息,对应官方 MsgCode.AD102) + * 5. 未知路由(404)保留 HTTP 404 + * + * 迁 JNPF 时本文件删掉,官方 ResultExceptionHand 接管,返回形状一致 -> 前端零改。 + */ +@Catch() +export class ActionResultFilter implements ExceptionFilter { + private readonly logger = new Logger('Exception'); + + catch(exception: any, host: ArgumentsHost) { + const res = host.switchToHttp().getResponse(); + + // 1) 业务异常:透传自己的 code / msg + if (exception instanceof BizException) { + return res.status(200).json(ActionResult.fail(exception.code, exception.message)); + } + + // 2) 权限异常(对齐官方 PEIMISSIONEXP=403) + if (exception?.status === 403) { + return res.status(200).json(ActionResult.fail(403, this.msgOf(exception))); + } + + // 3) 会话/登录类 HTTP 异常 -> 600(对齐官方 SESSIONOVERDUE=600) + if (exception?.status === 401) { + return res.status(200).json(ActionResult.fail(600, this.msgOf(exception))); + } + + // 4) 未知路由:保留 404(对齐官方 error() 对 NOT_FOUND 的处理) + if (exception instanceof HttpException && exception.getStatus() === 404) { + return res.status(404).json(ActionResult.fail(404, '接口不存在')); + } + + // 5) 其它 HttpException(参数校验等)-> 400 + if (exception instanceof HttpException) { + return res + .status(200) + .json(ActionResult.fail(400, this.msgOf(exception))); + } + + // 6) 兜底:未捕获异常 -> 400 + 通用提示(真实错误只进日志) + this.logger.error(`未捕获异常: ${exception?.message}`, exception?.stack); + return res.status(200).json(ActionResult.fail(400, '系统异常,请联系管理员')); + } + + private msgOf(exception: any): string { + try { + const body = exception?.getResponse?.(); + const msg = typeof body === 'string' ? body : body?.message; + if (Array.isArray(msg)) return msg.join('; '); + return msg || exception?.message || '请求失败'; + } catch { + return exception?.message || '请求失败'; + } + } +} diff --git a/src/backend/src/common/action-result.ts b/src/backend/src/common/action-result.ts new file mode 100644 index 0000000..ee4316a --- /dev/null +++ b/src/backend/src/common/action-result.ts @@ -0,0 +1,24 @@ +/** + * 统一返回结构 —— 与 JNPF / ssw-jnpf-lite 的 ActionResult 完全一致: + * { code, msg, data };成功 code:200;未登录/鉴权失败 code:600。 + * 迁 JNPF 时,NestJS 的 ActionResult 直接对应 jnpf.base.ActionResult。 + */ +export class ActionResult { + code: number; + msg: string; + data: T; + + constructor(code = 200, msg = '成功', data: T = null as any) { + this.code = code; + this.msg = msg; + this.data = data; + } + + static success(data: D): ActionResult { + return new ActionResult(200, '成功', data); + } + + static fail(code: number, msg: string): ActionResult { + return new ActionResult(code, msg, null); + } +} diff --git a/src/backend/src/common/business.exception.ts b/src/backend/src/common/business.exception.ts new file mode 100644 index 0000000..fa379f7 --- /dev/null +++ b/src/backend/src/common/business.exception.ts @@ -0,0 +1,15 @@ +/** + * 业务异常 —— 对应 JNPF 的 `jnpf.exception.ImportException / DataException / LoginException`。 + * code 取官方 `ActionResultCode`:FAIL=400 / VALIDATEERROR=401 / PEIMISSIONEXP=403 / EXCEPTION=500。 + * 抛出后由 `ActionResultFilter` 统一转成 `ActionResult{code,msg,data}`(HTTP 200),前端拦截器据此 reject。 + * 迁 JNPF 时本类删掉,改抛官方 `LoginException` / `DataException`(同一套 @ExceptionHandler 捕获)。 + */ +export class BizException extends Error { + readonly code: number; + + constructor(message: string, code = 400) { + super(message); + this.name = 'BizException'; + this.code = code; + } +} diff --git a/src/backend/src/common/cipher.ts b/src/backend/src/common/cipher.ts new file mode 100644 index 0000000..4fc0f29 --- /dev/null +++ b/src/backend/src/common/cipher.ts @@ -0,0 +1,36 @@ +import * as CryptoJS from 'crypto-js'; + +/** + * 登录密码加密 —— 与 JNPF 前端 cipher.ts / dacli / ssw-jnpf-lite(Vue) 完全一致: + * md5(plain) -> AES-256-ECB-PKCS7(key = md5("EY8WePvjM5GGwQzn") 32字节UTF8) -> ciphertext Hex + * + * 检验向量:encryptPassword('123456') === + * 'd4958348e22108119b3ef57b022c83f4bf857dd0b247eaab15b9a43d47ee3c503900f7135bf0de255bc33620c3cdc02b' + * (已在 /tmp/cipher-verify 用 node 验证 MATCH=true) + */ +const CIPHER_KEY = 'EY8WePvjM5GGwQzn'; + +export function md5Hex(str: string): string { + return CryptoJS.MD5(str).toString(); +} + +export function encryptPassword(plain: string): string { + const key = CryptoJS.enc.Utf8.parse(md5Hex(CIPHER_KEY)); + const src = CryptoJS.enc.Utf8.parse(md5Hex(plain)); + return CryptoJS.AES.encrypt(src, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }) + .ciphertext.toString(CryptoJS.enc.Hex); +} + +/** 解密前端加密串 -> md5(plain),用于登录比对(逆向复刻 cipher.ts) */ +export function decryptToMd5(encryptedHex: string): string { + const key = CryptoJS.enc.Utf8.parse(md5Hex(CIPHER_KEY)); + const decrypted = CryptoJS.AES.decrypt( + { ciphertext: CryptoJS.enc.Hex.parse(encryptedHex) } as any, + key, + { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }, + ); + return decrypted.toString(CryptoJS.enc.Utf8); +} diff --git a/src/backend/src/demo/demo-item.controller.ts b/src/backend/src/demo/demo-item.controller.ts new file mode 100644 index 0000000..3888931 --- /dev/null +++ b/src/backend/src/demo/demo-item.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { DemoItemService } from './demo-item.service'; + +/** + * 示例业务 Controller —— 端点命名对齐 JNPF: + * GET /api/ssw/demo/DemoItem/List + * POST /api/ssw/demo/DemoItem/Save + * DELETE /api/ssw/demo/DemoItem/Delete?id= + * 迁 JNPF 时,本控制器对应一个 extends jnpf CrudController 的 Java Controller, + * 端点路径/ActionResult 返回与前端完全同形。 + */ +@Controller('api/ssw/demo/DemoItem') +export class DemoItemController { + constructor( + private readonly svc: DemoItemService, + private readonly auth: AuthService, + ) {} + + private guard(req: any) { + if (!this.auth.resolve(req.headers['authorization'])) { + return ActionResult.fail(600, '未登录'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/demo/demo-item.entity.ts b/src/backend/src/demo/demo-item.entity.ts new file mode 100644 index 0000000..3df7852 --- /dev/null +++ b/src/backend/src/demo/demo-item.entity.ts @@ -0,0 +1,27 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 示例业务实体 —— 列名采用 JNPF 约定(f_ 前缀 + varchar(50) 主键)。 + * 迁 JNPF 时:本类直接对应一个 extends jnpf.base.entity.SuperEntity 的 Java 实体, + * f_id/f_title/f_status/f_creator_time/f_delete_mark 与 JNPF 字段一一对应。 + */ +@Entity({ name: 'demo_item' }) +export class DemoItemEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_title', type: 'varchar', length: 255, nullable: true }) + title: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; +} diff --git a/src/backend/src/demo/demo-item.service.ts b/src/backend/src/demo/demo-item.service.ts new file mode 100644 index 0000000..fef6dea --- /dev/null +++ b/src/backend/src/demo/demo-item.service.ts @@ -0,0 +1,48 @@ +import { Injectable } from '@nestjs/common'; +import { randomUUID } from 'crypto'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { DemoItemEntity } from './demo-item.entity'; + +@Injectable() +export class DemoItemService { + constructor( + @InjectRepository(DemoItemEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + // 软删过滤 + 按创建时间倒序;迁 JNPF 时对应 SuperServiceImpl.page(...) + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async save(item: Partial): Promise { + // JNPF 主键 f_id 用 36 位 UUID(varchar(50));MVP 用 randomUUID() + if (!item.id) { + const ent = this.repo.create({ + id: randomUUID(), + title: item.title, + status: item.status ?? '草稿', + creatorUserId: 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as DemoItemEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, id: item.id } as any); + return (await this.repo.save(created)) as unknown as DemoItemEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as DemoItemEntity; + } + + async remove(id: string): Promise { + // 软删:f_delete_mark = 1(JNPF 逻辑删除约定) + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/demo/demo.module.ts b/src/backend/src/demo/demo.module.ts new file mode 100644 index 0000000..ca5a92a --- /dev/null +++ b/src/backend/src/demo/demo.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { DemoItemEntity } from './demo-item.entity'; +import { DemoItemService } from './demo-item.service'; +import { DemoItemController } from './demo-item.controller'; +import { AuthModule } from '../auth/auth.module'; + +@Module({ + imports: [TypeOrmModule.forFeature([DemoItemEntity]), AuthModule], + controllers: [DemoItemController], + providers: [DemoItemService], +}) +export class DemoModule {} diff --git a/src/backend/src/main.ts b/src/backend/src/main.ts new file mode 100644 index 0000000..620de48 --- /dev/null +++ b/src/backend/src/main.ts @@ -0,0 +1,17 @@ +import 'reflect-metadata'; +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; +import { ActionResultFilter } from './common/action-result.filter'; + +async function bootstrap() { + const app = await NestFactory.create(AppModule); + app.enableCors(); + // 对齐 JNPF ResultExceptionHand:所有异常统一返回 ActionResult 形状 + app.useGlobalFilters(new ActionResultFilter()); + const port = process.env.PORT ? +process.env.PORT : 30000; + await app.listen(port); + // 打印 127.0.0.1 而非 localhost:macOS 上 localhost 可能解析到 IPv6 ::1, + // 而后端/vite 固定 IPv4,直拷此 URL 首次就能通(README 同款提示)。 + console.log(`ssw-jnpf-lite-react backend on http://127.0.0.1:${port}`); +} +bootstrap(); diff --git a/src/backend/src/shop/product.controller.ts b/src/backend/src/shop/product.controller.ts new file mode 100644 index 0000000..8cb127e --- /dev/null +++ b/src/backend/src/shop/product.controller.ts @@ -0,0 +1,62 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { ProductService } from './product.service'; + +const MODULE_KEY = 'shop/Product'; // == base_module.f_url_address == 前端 Route path(去前导斜杠) + +/** + * Product 业务 Controller —— 端点对齐 JNPF: + * GET /api/ssw/shop/Product/List + * POST /api/ssw/shop/Product/Save + * DELETE /api/ssw/shop/Product/Delete?id= + * 采用「登录 + 菜单权限」守卫(HOWTO_MODULE.md 模式 B)。 + */ +@Controller('api/ssw/shop/Product') +export class ProductController { + constructor( + private readonly svc: ProductService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/shop/product.entity.ts b/src/backend/src/shop/product.entity.ts new file mode 100644 index 0000000..a14d57c --- /dev/null +++ b/src/backend/src/shop/product.entity.ts @@ -0,0 +1,28 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * Product 业务实体 —— HOWTO_MODULE.md 的参照实现。 + * 与 demo-item.entity.ts 的差别:多了 numeric 金额列、独立 appCode(shop)。 + * 迁 JNPF:本类对应 extends jnpf.base.entity.SuperEntity 的 Java 实体。 + */ +@Entity({ name: 'shop_product' }) +export class ProductEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_title', type: 'varchar', length: 255, nullable: true }) + title: string; + + // numeric 在 TypeORM 中映射为 string(避免浮点误差) + @Column({ name: 'f_price', type: 'numeric', precision: 12, scale: 2, nullable: true }) + price: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; +} diff --git a/src/backend/src/shop/product.service.ts b/src/backend/src/shop/product.service.ts new file mode 100644 index 0000000..4538f33 --- /dev/null +++ b/src/backend/src/shop/product.service.ts @@ -0,0 +1,48 @@ +import { Injectable } from '@nestjs/common'; +import { randomUUID } from 'crypto'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { ProductEntity } from './product.entity'; + +@Injectable() +export class ProductService { + constructor( + @InjectRepository(ProductEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + // 软删过滤 + 创建时间倒序;迁 JNPF 对应 SuperServiceImpl.page(...) + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async save(item: Partial): Promise { + // 主键 36 位 UUID(varchar(50) 装得下) + if (!item.id) { + const ent = this.repo.create({ + id: randomUUID(), + title: item.title, + price: item.price ?? '0.00', + creatorUserId: item.creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as ProductEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, id: item.id } as any); + return (await this.repo.save(created)) as unknown as ProductEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as ProductEntity; + } + + async remove(id: string): Promise { + // 软删:f_delete_mark = 1 + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/shop/shop.module.ts b/src/backend/src/shop/shop.module.ts new file mode 100644 index 0000000..7c49738 --- /dev/null +++ b/src/backend/src/shop/shop.module.ts @@ -0,0 +1,14 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { ProductEntity } from './product.entity'; +import { ProductService } from './product.service'; +import { ProductController } from './product.controller'; +import { AuthModule } from '../auth/auth.module'; +import { SysModule } from '../sys/sys.module'; + +@Module({ + imports: [TypeOrmModule.forFeature([ProductEntity]), AuthModule, SysModule], + controllers: [ProductController], + providers: [ProductService], +}) +export class ShopModule {} diff --git a/src/backend/src/sswchain/chainblock.controller.ts b/src/backend/src/sswchain/chainblock.controller.ts new file mode 100644 index 0000000..94687c5 --- /dev/null +++ b/src/backend/src/sswchain/chainblock.controller.ts @@ -0,0 +1,76 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { ChainBlockService } from './chainblock.service'; + +const MODULE_KEY = 'sswchain/ChainBlock'; // == base_module.f_url_address == 前端 Route path(去前导斜杠) + +/** + * 区块链浏览器 · 区块 Controller —— 端点对齐 JNPF: + * GET /api/ssw/sswchain/ChainBlock/List + * POST /api/ssw/sswchain/ChainBlock/Save + * DELETE /api/ssw/sswchain/ChainBlock/Delete?id= + * 采用「登录 + 菜单权限」守卫(HOWTO_MODULE.md 模式 B)。 + * 浏览器只读场景为主;Save 仅供演示灌入区块(真实环境由链节点/监听服务回写)。 + */ +@Controller('api/ssw/sswchain/ChainBlock') +export class ChainBlockController { + constructor( + private readonly svc: ChainBlockService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + /** + * 从**真链**同步存证数据(outbox 状态 + 链高度 + 合约只读读回)。 + * + * ★ 这是「链上存证」的真数据源入口:读不到就返回 0 条 + 原因, + * 绝不拿假数据充数(fail-closed)。 + */ + @Post('Sync') + async sync(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.syncFromChain(body || {})); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswchain/chainblock.entity.ts b/src/backend/src/sswchain/chainblock.entity.ts new file mode 100644 index 0000000..371405f --- /dev/null +++ b/src/backend/src/sswchain/chainblock.entity.ts @@ -0,0 +1,129 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 链上存证(sswchain_chain_block)—— **Receipt / 回执**视图。 + * + * ★★ 命名沿用 `chain_block` 是历史包袱;**它不是区块浏览器**。 + * ssw-mpc 的 `mpc chain` 子命令里**没有**通用区块浏览命令 + * (digest / submit / flush / status / admit / keygen / sign / align / tlcp / + * governance / opa / contract),链上对象是 `Receipt` / `Member` / + * `PolicyBundleRecord` 三类。 + * ⇒ 本表存的是「链上登记的回执」与「FISCO 交易回执」。 + * + * ★ Receipt 字段严格对齐 ssw-mpc `crates/mpc-chain/src/objects.rs`: + * order_id / decision_id / result_hash[32] / input_hash[32] / user_data[64] / + * attest{user_data_ok, meas_ok, tcb_ok, chip_sig} / link / link_binding[32] / + * signatures + * + * ★★ 「验证通过」必须拆成四句,**不许合并成一个 ok=1**: + * user_data_ok / meas_ok / tcb_ok / chip_sig 各报各的。 + * `chip_sig = 0` 的含义是「绑定成立但没做芯片验签」,不是「没绑定」。 + * + * ★ FISCO 回执字段来自 `crates/mpc-chain/src/rpc.rs` 的 `toJsonResp`: + * `transactionHash`(**不是** txHash)/ `status`(**0 = 成功**,与 web3 相反)/ + * `blockNumber` / `gasUsed`(hex 串,无 0x 前缀)/ `contractAddress`。 + */ +@Entity({ name: 'sswchain_chain_block' }) +export class ChainBlockEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + // ---------------- Receipt(链上对象) ---------------- + + /** 计算订单 ID。 */ + @Column({ name: 'f_order_id', type: 'varchar', length: 200, nullable: true }) + orderId: string; + + /** 决策 ID(与 orderId 一起构成幂等键)。 */ + @Column({ name: 'f_decision_id', type: 'varchar', length: 200, nullable: true }) + decisionId: string; + + /** 结果摘要(32 字节 hex)。 */ + @Column({ name: 'f_result_hash', type: 'varchar', length: 200, nullable: true }) + resultHash: string; + + /** 输入摘要(32 字节 hex)。 */ + @Column({ name: 'f_input_hash', type: 'varchar', length: 200, nullable: true }) + inputHash: string; + + /** 原始 64 字节绑定值(国密链没有 sha256 预编译,链上不能重算)。 */ + @Column({ name: 'f_user_data', type: 'varchar', length: 400, nullable: true }) + userData: string; + + /** 用户数据校验结果(0/1)。 */ + @Column({ name: 'f_user_data_ok', type: 'int', nullable: true }) + userDataOk: number; + + /** 镜像度量校验结果(0/1)。 */ + @Column({ name: 'f_meas_ok', type: 'int', nullable: true }) + measOk: number; + + /** TCB 门槛校验结果(0/1)。 */ + @Column({ name: 'f_tcb_ok', type: 'int', nullable: true }) + tcbOk: number; + + /** 芯片验签结果(0/1)—— 0 = 绑定成立但没做芯片验签。 */ + @Column({ name: 'f_chip_sig', type: 'int', nullable: true }) + chipSig: number; + + /** 实际链路路径(p2p / relay / unknown),不是策略档位。 */ + @Column({ name: 'f_link', type: 'varchar', length: 32, nullable: true }) + link: string; + + /** 链下密码学绑定摘要(32 字节 hex)。 */ + @Column({ name: 'f_link_binding', type: 'varchar', length: 200, nullable: true }) + linkBinding: string; + + /** 各方签名(不进 canonical body,是产物不是被签内容)。 */ + @Column({ name: 'f_signatures', type: 'text', nullable: true }) + signatures: string; + + /** 链上对象规范摘要(SM3,64 hex)—— 链上登记的摘要就是这个。 */ + @Column({ name: 'f_digest', type: 'varchar', length: 200, nullable: true }) + digest: string; + + /** 摘要算法套件(sm3)。 */ + @Column({ name: 'f_hash_suite', type: 'varchar', length: 32, nullable: true }) + hashSuite: string; + + // ---------------- FISCO 交易回执 ---------------- + + /** 交易哈希 —— FISCO 自有字段名 `transactionHash`。 */ + @Column({ name: 'f_tx_hash', type: 'varchar', length: 200, nullable: true }) + txHash: string; + + /** TransactionStatus 枚举值:**0 = 执行成功**(与 web3 的 0x1 相反)。 */ + @Column({ name: 'f_status', type: 'int', nullable: true }) + status: number; + + /** 出块高度(> 0 才算已上链)。 */ + @Column({ name: 'f_block_number', type: 'bigint', nullable: true }) + blockNumber: string; + + /** gasUsed(hex 串,无 0x 前缀)。 */ + @Column({ name: 'f_gas_used', type: 'varchar', length: 64, nullable: true }) + gasUsed: string; + + /** 合约地址(部署类回执有值)。 */ + @Column({ name: 'f_contract_address', type: 'varchar', length: 100, nullable: true }) + contractAddress: string; + + // ---------------- 出处 ---------------- + + /** 数据来源:chain-cli(真链)/ mock(不可达降级)。 */ + @Column({ name: 'f_source', type: 'varchar', length: 32, nullable: true }) + source: string; + + /** 真源读失败原因(source=mock 时有值)。 */ + @Column({ name: 'f_source_reason', type: 'varchar', length: 500, nullable: true }) + sourceReason: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; +} diff --git a/src/backend/src/sswchain/chainblock.service.ts b/src/backend/src/sswchain/chainblock.service.ts new file mode 100644 index 0000000..3072307 --- /dev/null +++ b/src/backend/src/sswchain/chainblock.service.ts @@ -0,0 +1,298 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import * as fs from 'fs'; +import * as path from 'path'; +import { ChainBlockEntity } from './chainblock.entity'; +import { + decodeReceiptPayload, + DecodedReceipt, + digestReceipt, + fetchChainOutbox, + fetchFiscoReceipt, + isFiscoTxSuccess, + probeChainHeight, + readContract, +} from '../sswflow/engine/ssw-mpc-adapter'; +import { mpcSettings, MpcSettings } from '../sswflow/engine/mpc-client'; + +/** + * 链上存证服务 —— 列表带软删过滤、删除软删、主键 36 位 UUID。 + * + * ★ 数据来源分两种,**前端必须能区分**: + * ① `syncFromChain()`:真链 —— 读 ssw-mpc 的 outbox(待上链表)+ 探链高度, + * 可选地只读读回合约里的某条回执。读不到就 0 条 + source=mock + 原因。 + * ② `save()`:人工登记 —— 落一条回执(链下算好的 Receipt)。 + * + * ★★ 语义边界(写在这里防止下游误读): + * outbox 的 `Confirmed` 只代表**已广播**,不代表已出块确认; + * 出块确认看 FISCO 回执三件套(status==0 + transactionHash 非空 + blockNumber>0)。 + */ +@Injectable() +export class ChainBlockService { + constructor( + @InjectRepository(ChainBlockEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as ChainBlockEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as ChainBlockEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as ChainBlockEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } + + /** 链配置路径(ssw-mpc 的 chain.json)。 */ + private chainConfig(settings: MpcSettings): string { + return process.env.MPC_FISCO_CHAIN_CONFIG + || path.join(settings.workDir, 'tools/fisco-realnode/example.chain.json'); + } + + /** outbox 路径(ssw-mpc 的待上链表)。 */ + private outboxPath(settings: MpcSettings): string { + return process.env.MPC_FISCO_OUTBOX + || path.join(settings.stateRoot, 'chain-outbox.txt'); + } + + /** + * 从真链同步存证数据。 + * + * ★ 同步内容: + * ① outbox 条目状态(Pending / Confirmed / attempts / lastError) + * ② 链当前高度(`getBlockNumber` 裸调用) + * ③ 可选:只读读回合约里的某条回执(`chain contract read`) + * + * ★ fail-closed:真源读不到 ⇒ 0 条 + source=mock + 原因,绝不拿假数据充数。 + */ + async syncFromChain(options?: { + settings?: MpcSettings; + contract?: string; + abi?: string; + method?: string; + arg?: string[]; + receiptFile?: string; + /** 指定 txHash 时额外查一次 FISCO 链上回执(自有端点 `getTransactionReceipt`)。 */ + txHash?: string; + /** 这笔 txHash 对应的 orderId(用于把回执落到正确的 outbox 行)。 */ + targetOrderId?: string; + /** 这笔 txHash 对应的 decisionId。 */ + targetDecisionId?: string; + /** FISCO groupID,默认读 chain.json 的 `group_id`。 */ + groupId?: string; + /** FISCO nodeName,默认 `node0`(与 `mpc chain contract` 的默认值一致)。 */ + nodeName?: string; + }): Promise<{ + synced: number; + source: string; + origin: string; + reason?: string; + height: number | null; + outbox: any[]; + readBack: any; + digest: any; + txReceipt: any; + }> { + const settings = options?.settings || mpcSettings(); + const cfg = this.chainConfig(settings); + const outbox = await fetchChainOutbox(this.outboxPath(settings), settings); + const height = await probeChainHeight(this.rpcEndpoint(settings)); + + let readBack: any = null; + if (options?.contract && options?.abi && options?.method) { + const r = await readContract( + { + config: cfg, + contract: options.contract, + method: options.method, + abi: options.abi, + arg: options.arg, + }, + settings, + ); + readBack = { output: r.data?.output ?? null, selector: r.data?.selector ?? '', reason: r.reason }; + } + + let digest: any = null; + if (options?.receiptFile && fs.existsSync(options.receiptFile)) { + const r = await digestReceipt(options.receiptFile, cfg, settings); + digest = { ...(r.data || {}), reason: r.reason }; + } + + // ★ 链上出块回执(可选):给定 txHash 时查一次 FISCO 自有端点。 + let txReceipt: any = null; + if (options?.txHash) { + const groupId = options.groupId || this.chainGroupId(settings); + const nodeName = options.nodeName || process.env.MPC_FISCO_NODE || 'node0'; + const r = await fetchFiscoReceipt( + this.rpcEndpoint(settings), + groupId, + nodeName, + options.txHash, + ); + txReceipt = { + txHash: options.txHash, + groupId, + nodeName, + // ★ 三件套缺一不可;字段缺失一律按「没有」处理。 + success: r.data ? isFiscoTxSuccess(r.data as any) : false, + transactionHash: r.data?.transactionHash ?? null, + status: r.data?.status ?? null, + blockNumber: r.data?.blockNumber ?? null, + gasUsed: r.data?.gasUsed ?? null, + contractAddress: r.data?.contractAddress ?? null, + origin: r.origin, + reason: r.reason, + }; + } + + // 真源判定:outbox 与链高任一读到即算真源。 + const real = outbox.source === 'chain-cli' && !outbox.reason; + const source = real ? 'chain-cli' : 'mock'; + const reason = outbox.reason || height.reason; + + let synced = 0; + for (const e of outbox.data) { + // outbox 键 = `kind:order_id:decision_id`。 + const parts = String(e.key || '').split(':'); + const orderId = parts[1] || ''; + const decisionId = parts[2] || ''; + const id = this.idFor(e.key); + const existing = await this.repo.findOne({ where: { id } as any }); + + // ★ 从 payload 反解 Receipt(outbox 里存的是 canonical_bytes,字段全在里面)。 + // 解不开就只留 key 派生的两个字段,并把原因写进 sourceReason —— 不编造。 + let decoded: DecodedReceipt | null = null; + let decodeReason: string | null = null; + if (e.payloadHex) { + try { + decoded = decodeReceiptPayload(e.payloadHex); + } catch (err: any) { + decodeReason = `Receipt 反解失败:${err?.message}`; + } + } else { + decodeReason = 'outbox 条目没有 payload'; + } + + const payload = { + orderId: decoded?.order_id ?? orderId, + decisionId: decoded?.decision_id ?? decisionId, + resultHash: decoded?.result_hash ?? null, + inputHash: decoded?.input_hash ?? null, + userData: decoded?.user_data ?? null, + // ★ 四个验证位**分开报**,不许合并成一个 ok。 + userDataOk: decoded ? (decoded.attest.user_data_ok ? 1 : 0) : null, + measOk: decoded ? (decoded.attest.meas_ok ? 1 : 0) : null, + tcbOk: decoded ? (decoded.attest.tcb_ok ? 1 : 0) : null, + chipSig: decoded ? (decoded.attest.chip_sig ? 1 : 0) : null, + link: decoded?.link ?? null, + linkBinding: decoded?.link_binding ?? null, + signatures: decoded ? decoded.signatures.join(',') : null, + // outbox 状态映射到链上语义:Confirmed=已广播(不是已出块确认)。 + status: e.state === 'Confirmed' ? 0 : null, + source, + sourceReason: reason || decodeReason || null, + creatorTime: new Date(), + deleteMark: 0, + } as any; + + // ★ 链上出块回执落到**对应**的那一行:按 orderId/decisionId 匹配, + // 匹配不上就不落(绝不把 A 的回执写到 B 的行上)。 + if (txReceipt) { + const hitOrder = options?.targetOrderId ? payload.orderId === options.targetOrderId : true; + const hitDecision = options?.targetDecisionId + ? payload.decisionId === options.targetDecisionId + : true; + if (hitOrder && hitDecision) { + payload.txHash = txReceipt.transactionHash || options?.txHash || null; + payload.blockNumber = txReceipt.blockNumber ?? null; + payload.gasUsed = txReceipt.gasUsed ?? null; + payload.contractAddress = txReceipt.contractAddress || null; + // ★ FISCO 回执的 status 优先于 outbox 状态 —— 前者是链上执行结果, + // 后者只说明「已广播」。 + payload.status = txReceipt.status ?? payload.status; + } + } + + if (existing) { + if (existing.deleteMark === 1) continue; + Object.assign(existing, payload, { id: existing.id, creatorTime: existing.creatorTime }); + await this.repo.save(existing); + } else { + await this.repo.save(this.repo.create({ ...payload, id }) as any); + } + synced++; + } + + return { + synced, + source, + origin: outbox.origin, + reason, + height: height.data, + outbox: outbox.data, + readBack, + digest, + txReceipt, + }; + } + + /** FISCO groupID(从 chain.json 读 `group_id`)。 */ + private chainGroupId(settings: MpcSettings): string { + const cfg = this.chainConfig(settings); + try { + const raw = JSON.parse(fs.readFileSync(cfg, 'utf8')); + return raw.group_id || 'group0'; + } catch { + return 'group0'; + } + } + + /** FISCO RPC 端点(从 chain.json 读)。 */ + private rpcEndpoint(settings: MpcSettings): string { + const cfg = this.chainConfig(settings); + try { + const raw = JSON.parse(fs.readFileSync(cfg, 'utf8')); + return raw.rpc_endpoint || '127.0.0.1:20200'; + } catch { + return '127.0.0.1:20200'; + } + } + + /** outbox 键 → 本表主键(稳定派生,反复同步不换 id)。 */ + private idFor(key: string): string { + // f_id 是 VARCHAR(50):前缀 5 + 十六进制 45 = 50,正好不溢出。 + const hex = Buffer.from(key || 'unknown', 'utf8').toString('hex').slice(0, 45); + return `rcpt-${hex}`; + } +} + +export { isFiscoTxSuccess }; diff --git a/src/backend/src/sswchain/sswchain.module.ts b/src/backend/src/sswchain/sswchain.module.ts new file mode 100644 index 0000000..caff464 --- /dev/null +++ b/src/backend/src/sswchain/sswchain.module.ts @@ -0,0 +1,15 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { ChainBlockEntity } from './chainblock.entity'; +import { ChainBlockService } from './chainblock.service'; +import { ChainBlockController } from './chainblock.controller'; +import { AuthModule } from '../auth/auth.module'; +import { SysModule } from '../sys/sys.module'; + +/** 区块链浏览器模块(appCode=sswchain)—— 1 张 f_ 表 + 1 控制器(区块浏览)。 */ +@Module({ + imports: [TypeOrmModule.forFeature([ChainBlockEntity]), AuthModule, SysModule], + controllers: [ChainBlockController], + providers: [ChainBlockService], +}) +export class SswchainModule {} diff --git a/src/backend/src/sswdevice/device.controller.ts b/src/backend/src/sswdevice/device.controller.ts new file mode 100644 index 0000000..939a965 --- /dev/null +++ b/src/backend/src/sswdevice/device.controller.ts @@ -0,0 +1,76 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { DeviceService } from './device.service'; + +const MODULE_KEY = 'sswdevice/Device'; // == base_module.f_url_address == 前端 Route path(去前导斜杠) + +/** + * 设备注册 Controller —— 端点对齐 JNPF: + * GET /api/ssw/sswdevice/Device/List + * POST /api/ssw/sswdevice/Device/Save + * DELETE /api/ssw/sswdevice/Device/Delete?id= + * 采用「登录 + 菜单权限」守卫(HOWTO_MODULE.md 模式 B)。 + */ +@Controller('api/ssw/sswdevice/Device') +export class DeviceController { + constructor( + private readonly svc: DeviceService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + /** + * 从 ssw-mpc 控制面同步**真实** TEE 节点注册表。 + * + * ★ 这是「设备注册」的真数据源入口:设备不是我们自己填的,是 TEE 节点 + * 向 hostd 自报、再由控制面汇总的。读不到就返回 0 条 + 原因, + * 绝不拿假数据充数(fail-closed)。 + */ + @Post('Sync') + async sync(@Req() req: any) { + const g = await this.guardModule(req); + if (g) return g; + return ActionResult.success(await this.svc.syncFromControlPlane()); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswdevice/device.entity.ts b/src/backend/src/sswdevice/device.entity.ts new file mode 100644 index 0000000..ec3f042 --- /dev/null +++ b/src/backend/src/sswdevice/device.entity.ts @@ -0,0 +1,121 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 设备注册(sswdevice_device)—— **TEE 节点注册表**。 + * + * ★ 字段严格对齐 ssw-mpc `crates/mpc-tee/src/schedule.rs` 的 `TeeNode` + * 与 `crates/mpc-hostd/src/control_plane_api.rs` 的 `node_to_json`。 + * **不是** ssw-mvp 的「边缘终端 / 网关 / 计算节点」分类 —— 那是旧实现的自造分类, + * 与 ssw-mpc 的真实语义不符。 + * + * ★ 真实取值(2026-11-10 海光真机 192.168.1.102 控制面实读): + * platform = `sev-snp` / `hygon-csv`(= TeeNode.kind) + * kbc = `cc_kbc` / `offline_fs_kbc::null`(不是 online / offline) + * key = `site@host`(注册表主键) + * tcb = 整数版本号(海光 CSV2 = 3,AMD SNP = 5) + * + * ★ 「设备」在此处的含义:**一个 TEE 节点**。节点通过 hostd 向控制面自报, + * 描述符里的能力位**默认全 false,漏填即被 admit 拒绝**(fail-closed)。 + * 所以这里存的是「节点自报的能力」,不是「我们自己填的标签」。 + */ +@Entity({ name: 'sswdevice_device' }) +export class DeviceEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + /** 注册表主键 `site@host`(控制面给的唯一键)。 */ + @Column({ name: 'f_key', type: 'varchar', length: 200, nullable: true }) + key: string; + + /** 站点名(alice / bob …)。 */ + @Column({ name: 'f_site', type: 'varchar', length: 100, nullable: true }) + site: string; + + /** 主机地址。 */ + @Column({ name: 'f_host', type: 'varchar', length: 200, nullable: true }) + host: string; + + /** 平台种类:sev-snp / hygon-csv(= TeeNode.kind)。 */ + @Column({ name: 'f_platform', type: 'varchar', length: 64, nullable: true }) + platform: string; + + /** 可信计算基版本号(整数)。 */ + @Column({ name: 'f_tcb', type: 'int', nullable: true }) + tcb: number; + + /** 并发容量。 */ + @Column({ name: 'f_capacity', type: 'int', nullable: true }) + capacity: number; + + /** 最近一次自报时间(unix 秒)。 */ + @Column({ name: 'f_last_seen', type: 'bigint', nullable: true }) + lastSeen: string; + + /** TEE 设备在位。 */ + @Column({ name: 'f_device_present', type: 'int', nullable: true }) + devicePresent: number; + + /** qemu 在位。 */ + @Column({ name: 'f_qemu_present', type: 'int', nullable: true }) + qemuPresent: number; + + /** 固件在位。 */ + @Column({ name: 'f_firmware_present', type: 'int', nullable: true }) + firmwarePresent: number; + + /** 镜像在位。 */ + @Column({ name: 'f_image_present', type: 'int', nullable: true }) + imagePresent: number; + + /** 密钥代理可达。 */ + @Column({ name: 'f_kbs_reachable', type: 'int', nullable: true }) + kbsReachable: number; + + /** 密钥代理模式(真实值形如 cc_kbc / offline_fs_kbc::null)。 */ + @Column({ name: 'f_kbc', type: 'varchar', length: 128, nullable: true }) + kbc: string; + + /** 密钥代理地址。 */ + @Column({ name: 'f_kbs_endpoint', type: 'varchar', length: 500, nullable: true }) + kbsEndpoint: string; + + /** 镜像度量(64 hex)。 */ + @Column({ name: 'f_measurement', type: 'varchar', length: 128, nullable: true }) + measurement: string; + + /** TeeNode 原始描述符(key=value 行式文本),权威副本。 */ + @Column({ name: 'f_descriptor', type: 'text', nullable: true }) + descriptor: string; + + /** + * 当前是否**在控制面注册表里**(1=在,0=已掉线)。 + * + * ★ 为什么需要这一列:ssw-mpc 控制面的 `GET /nodes` 返回的是 + * **当前活跃节点**——`NodeRegistry::prune_stale()` 会把超过 + * `node_ttl_secs`(默认 90s)未心跳的节点**剔除**。 + * 所以 `/nodes` 是「此刻在线清单」,不是「注册过的档案」。 + * 同步时真源里消失的节点必须标成离线,否则库里会留僵尸行, + * 前端会让人误以为该设备还在线。 + * + * ★ 1=在线;0=真源里已没有它(掉线/TTL 过期);null=从未同步过(人工登记)。 + */ + @Column({ name: 'f_online', type: 'int', nullable: true }) + online: number; + + /** 数据来源:control-plane(真接口)/ mock(不可达降级)。 */ + @Column({ name: 'f_source', type: 'varchar', length: 32, nullable: true }) + source: string; + + /** 真源读失败原因(source=mock 时有值)。 */ + @Column({ name: 'f_source_reason', type: 'varchar', length: 500, nullable: true }) + sourceReason: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; +} diff --git a/src/backend/src/sswdevice/device.service.ts b/src/backend/src/sswdevice/device.service.ts new file mode 100644 index 0000000..08073fd --- /dev/null +++ b/src/backend/src/sswdevice/device.service.ts @@ -0,0 +1,190 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { DeviceEntity } from './device.entity'; +import { + controlPlaneOptions, + fetchControlPlaneNodes, + fetchControlPlaneSessions, + fetchControlPlaneReport, + parseDescriptor, + TeeNodeView, + ControlPlaneOptions, +} from '../sswflow/engine/ssw-mpc-adapter'; + +/** + * 设备注册服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * + * ★ 数据来源分两种,**前端必须能区分**: + * ① `syncFromControlPlane()`:真接口 —— 从 ssw-mpc 控制面 `/nodes` 读真实注册表。 + * 这是**唯一**的真设备来源;读不到就空数组 + 标 source=mock + 写明原因。 + * ② `save()`:人工登记 —— 只能写**描述性备注类**字段,不能凭空造能力位。 + * 能力位(device_present 等)来自节点自报,人工登记时一律不填。 + */ +@Injectable() +export class DeviceService { + constructor( + @InjectRepository(DeviceEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + // ★ 真源权威字段:人工登记**不能**改。 + // online 由同步逻辑按控制面 /nodes 决定;source 记录数据出处。 + // 人工可以填的是描述性字段(站点/主机/平台/度量/描述符等)。 + const { online: _online, source: _source, sourceReason: _sourceReason, ...rest } = item as any; + + if (!item.id) { + const ent = this.repo.create({ + ...rest, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + // 人工登记的行:从未同步过 ⇒ online 留空(前端显示「未登记」)。 + online: null, + } as any); + return (await this.repo.save(ent)) as unknown as DeviceEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ + ...rest, + creatorTime: new Date(), + deleteMark: 0, + online: null, + } as any); + return (await this.repo.save(created)) as unknown as DeviceEntity; + } + Object.assign(existing, rest); + return (await this.repo.save(existing)) as unknown as DeviceEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } + + /** + * 从 ssw-mpc 控制面同步真实节点注册表。 + * + * ★ 幂等:主键用控制面给的 `key`(`site@host`)派生,不新造 id —— + * 重复同步不会产生重复行,也不会复活软删行(软删行跳过,等真节点重新自报再出现)。 + * + * ★ fail-closed:控制面读不到 ⇒ 返回 0 条 + source=mock + 原因, + * **绝不**用假数据填充列表。 + * + * ★ 下线语义:`GET /nodes` 返回的是**当前活跃节点**(控制面 + * `prune_stale()` 会剔除超过 TTL 90s 未心跳的节点),所以真源里 + * 消失的节点要标成 `online=0`,而不是留在库里装作还在线。 + * **只有真源读取成功时才做下线**,控制面不可达时绝不误标。 + */ + async syncFromControlPlane(opts?: ControlPlaneOptions): Promise<{ + synced: number; + offline: number; + source: string; + origin: string; + reason?: string; + sessions: any[]; + report: any; + }> { + const options = opts || controlPlaneOptions(); + const nodes = await fetchControlPlaneNodes(options); + const sessions = await fetchControlPlaneSessions(options); + const report = await fetchControlPlaneReport(options); + + let synced = 0; + const seenIds = new Set(); + for (const n of nodes.data) { + const ent = this.toEntity(n, nodes.source, nodes.reason); + const id = this.idFor(n.key); + seenIds.add(id); + const existing = await this.repo.findOne({ where: { id } as any }); + if (existing) { + if (existing.deleteMark === 1) { + // 软删过的行不自动复活 —— 人工确认后再启用。 + continue; + } + Object.assign(existing, ent, { id: existing.id, creatorTime: existing.creatorTime }); + await this.repo.save(existing); + } else { + await this.repo.save(this.repo.create({ ...ent, id }) as any); + } + synced++; + } + + // ★ 下线:真源里已经没有的节点标成离线。 + // 只在**真源读取成功**(source !== 'mock')时做 —— 控制面不可达时 + // 拿到的 0 条节点不代表所有设备都掉线,此时标离线就是误报。 + let offline = 0; + if (nodes.source !== 'mock') { + const stale = await this.repo.find({ + where: { deleteMark: 0, source: 'control-plane' } as any, + }); + for (const row of stale) { + if (seenIds.has(row.id)) continue; + if (row.online === 0) continue; // 已经离线过,不重复计数 + await this.repo.update({ id: row.id } as any, { online: 0 } as any); + offline++; + } + } + + return { + synced, + offline, + source: nodes.source, + origin: nodes.origin, + reason: nodes.reason, + sessions: sessions.data, + report: report.data, + }; + } + + /** 控制面注册表主键 `site@host` → 本表主键。稳定派生,反复同步不换 id。 */ + private idFor(key: string): string { + // f_id 是 VARCHAR(50):前缀 4 + 十六进制 46 = 50,正好不溢出。 + const hex = Buffer.from(key || 'unknown', 'utf8').toString('hex').slice(0, 46); + return `tee-${hex}`; + } + + /** TeeNode(控制面 JSON)→ 本表实体。 */ + private toEntity(n: TeeNodeView, source: string, reason?: string): Partial { + const desc = parseDescriptor(n.descriptor || ''); + return { + key: n.key || `${n.site}@${n.host}`, + site: n.site || '', + host: n.host || '', + platform: n.platform || '', + tcb: Number.isFinite(n.tcb) ? n.tcb : null, + capacity: Number.isFinite(n.capacity) ? n.capacity : null, + lastSeen: n.last_seen ? String(n.last_seen) : null, + devicePresent: n.device_present ? 1 : 0, + qemuPresent: n.qemu_present ? 1 : 0, + firmwarePresent: n.firmware_present ? 1 : 0, + imagePresent: n.image_present ? 1 : 0, + kbsReachable: n.kbs_reachable ? 1 : 0, + kbc: n.kbc || '', + // kbs_endpoint 只在 descriptor 里(node_to_json 没有这个字段)。 + kbsEndpoint: desc.kbs_endpoint || null, + measurement: n.measurement || '', + descriptor: n.descriptor || '', + // ★ 出现在真源里 ⇒ 此刻在线。 + online: 1, + source, + sourceReason: reason || null, + creatorTime: new Date(), + deleteMark: 0, + } as any; + } +} diff --git a/src/backend/src/sswdevice/sswdevice.module.ts b/src/backend/src/sswdevice/sswdevice.module.ts new file mode 100644 index 0000000..3203d84 --- /dev/null +++ b/src/backend/src/sswdevice/sswdevice.module.ts @@ -0,0 +1,15 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { DeviceEntity } from './device.entity'; +import { DeviceService } from './device.service'; +import { DeviceController } from './device.controller'; +import { AuthModule } from '../auth/auth.module'; +import { SysModule } from '../sys/sys.module'; + +/** 设备注册模块(appCode=sswdevice)—— 1 张 f_ 表 + 1 控制器。 */ +@Module({ + imports: [TypeOrmModule.forFeature([DeviceEntity]), AuthModule, SysModule], + controllers: [DeviceController], + providers: [DeviceService], +}) +export class SswdeviceModule {} diff --git a/src/backend/src/sswflow/artifact.controller.ts b/src/backend/src/sswflow/artifact.controller.ts new file mode 100644 index 0000000..cee8d01 --- /dev/null +++ b/src/backend/src/sswflow/artifact.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { ArtifactService } from './artifact.service'; + +const MODULE_KEY = 'sswflow/Artifact'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 步骤产物 —— /api/ssw/sswflow/Artifact/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/Artifact') +export class ArtifactController { + constructor( + private readonly svc: ArtifactService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/artifact.entity.ts b/src/backend/src/sswflow/artifact.entity.ts new file mode 100644 index 0000000..672e3ab --- /dev/null +++ b/src/backend/src/sswflow/artifact.entity.ts @@ -0,0 +1,54 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 步骤产物(sswflow_artifact)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../ArtifactEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_artifact' }) +export class ArtifactEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_run_id', type: 'varchar', length: 50, nullable: true }) + runId: string; + + @Column({ name: 'f_step_id', type: 'varchar', length: 50, nullable: true }) + stepId: string; + + @Column({ name: 'f_port_key', type: 'varchar', length: 50, nullable: true }) + portKey: string; + + @Column({ name: 'f_type', type: 'varchar', length: 32, nullable: true }) + type: string; + + @Column({ name: 'f_title', type: 'varchar', length: 255, nullable: true }) + title: string; + + @Column({ name: 'f_summary', type: 'varchar', length: 2000, nullable: true }) + summary: string; + + @Column({ name: 'f_columns', type: 'text', nullable: true }) + columns: string; + + @Column({ name: 'f_rows', type: 'text', nullable: true }) + rows: string; + + @Column({ name: 'f_metrics', type: 'text', nullable: true }) + metrics: string; + + @Column({ name: 'f_uri', type: 'varchar', length: 1000, nullable: true }) + uri: string; + + @Column({ name: 'f_row_count', type: 'int', nullable: true, default: 0 }) + rowCount: number; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/artifact.service.ts b/src/backend/src/sswflow/artifact.service.ts new file mode 100644 index 0000000..fa58ba1 --- /dev/null +++ b/src/backend/src/sswflow/artifact.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { ArtifactEntity } from './artifact.entity'; + +/** 步骤产物服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class ArtifactService { + constructor( + @InjectRepository(ArtifactEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as ArtifactEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as ArtifactEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as ArtifactEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/catalog/catalog.json b/src/backend/src/sswflow/catalog/catalog.json new file mode 100644 index 0000000..79c8e8c --- /dev/null +++ b/src/backend/src/sswflow/catalog/catalog.json @@ -0,0 +1,381 @@ +{ + "specVersion": "ssw-op/1.0", + "categories": [ + { + "key": "source", + "label": "数据接入", + "operators": [ + { + "key": "source.dataset", + "label": "数据集输入", + "desc": "从参与方已登记的数据集读取一张表,作为流程的起点。", + "engine": "mpc", + "terminal": false, + "inputs": [], + "outputs": [ + { "key": "out", "label": "数据表", "type": "table" } + ], + "params": [ + { "key": "datasetId", "label": "数据集", "type": "DATASET", "required": true, "help": "选择本方或合作方已授权的数据集" }, + { "key": "partition", "label": "分区过滤", "type": "STRING", "required": false, "placeholder": "如 dt=20260731" } + ] + } + ] + }, + { + "key": "prep", + "label": "数据预处理", + "operators": [ + { + "key": "prep.intersect", + "label": "隐私求交", + "desc": "在不泄露非交集样本的前提下,计算两方数据集的样本交集。", + "engine": "mpc", + "inputs": [ + { "key": "left", "label": "左表", "type": "table" }, + { "key": "right", "label": "右表", "type": "table" } + ], + "outputs": [ + { "key": "out", "label": "对齐表", "type": "table" } + ], + "params": [ + { "key": "leftKeys", "label": "左表关联键", "type": "COLUMNS", "bindPort": "left", "required": true }, + { "key": "rightKeys", "label": "右表关联键", "type": "COLUMNS", "bindPort": "right", "required": true }, + { + "key": "protocol", "label": "求交协议", "type": "SELECT", "required": true, "default": "ECDH", + "options": [ + { "value": "ECDH", "label": "ECDH(通信量小,适合大表)" }, + { "value": "OPRF", "label": "OPRF(计算快,带宽要求高)" }, + { "value": "BLIND", "label": "盲签名(兼容旧版参与方)" } + ] + }, + { "key": "keepOrder", "label": "保持原表顺序", "type": "BOOL", "default": false }, + { "key": "allowDuplicate", "label": "允许键重复", "type": "BOOL", "default": false }, + { "key": "receiver", "label": "结果接收方", "type": "PARTY", "required": true } + ] + }, + { + "key": "prep.sample", + "label": "数据采样", + "desc": "按比例抽取样本,支持随机采样与按标签分层采样。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "out", "label": "采样表", "type": "table" } ], + "params": [ + { + "key": "method", "label": "采样方式", "type": "SELECT", "default": "random", + "options": [ + { "value": "random", "label": "随机采样" }, + { "value": "stratify", "label": "分层采样" } + ] + }, + { "key": "rate", "label": "采样比例", "type": "SLIDER", "default": 0.8, "min": 0.05, "max": 1, "step": 0.05 }, + { "key": "stratifyBy", "label": "分层字段", "type": "COLUMNS", "bindPort": "in", "single": true, "visibleWhen": { "param": "method", "in": ["stratify"] } }, + { "key": "randomSeed", "label": "随机种子", "type": "INT", "default": 1024 } + ] + }, + { + "key": "prep.split", + "label": "训练集拆分", + "desc": "将样本切分为训练集与测试集两份输出。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ + { "key": "train", "label": "训练集", "type": "table" }, + { "key": "test", "label": "测试集", "type": "table" } + ], + "params": [ + { "key": "trainRate", "label": "训练集占比", "type": "SLIDER", "default": 0.7, "min": 0.1, "max": 0.95, "step": 0.05 }, + { "key": "shuffle", "label": "打乱顺序", "type": "BOOL", "default": true } + ] + }, + { + "key": "prep.fillna", + "label": "缺失值填充", + "desc": "对指定字段的缺失值按策略填充。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "out", "label": "输出表", "type": "table" } ], + "params": [ + { "key": "columns", "label": "处理字段", "type": "COLUMNS", "bindPort": "in", "required": true }, + { + "key": "strategy", "label": "填充策略", "type": "SELECT", "default": "mean", + "options": [ + { "value": "mean", "label": "均值" }, + { "value": "median", "label": "中位数" }, + { "value": "mode", "label": "众数" }, + { "value": "constant", "label": "固定值" } + ] + }, + { "key": "fillValue", "label": "填充值", "type": "STRING", "visibleWhen": { "param": "strategy", "in": ["constant"] }, "placeholder": "如 0" } + ] + }, + { + "key": "prep.binning", + "label": "分箱编码", + "desc": "对连续特征做等频或卡方分箱,输出分箱规则与编码后的表。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ + { "key": "out", "label": "编码表", "type": "table" }, + { "key": "rule", "label": "分箱规则", "type": "rule" } + ], + "params": [ + { "key": "columns", "label": "分箱字段", "type": "COLUMNS", "bindPort": "in", "required": true }, + { + "key": "binMethod", "label": "分箱方式", "type": "SELECT", "default": "quantile", + "options": [ + { "value": "quantile", "label": "等频分箱" }, + { "value": "uniform", "label": "等距分箱" }, + { "value": "chimerge", "label": "卡方分箱" } + ] + }, + { "key": "binCount", "label": "分箱数", "type": "INT", "default": 10, "min": 2, "max": 100 } + ] + } + ] + }, + { + "key": "stat", + "label": "统计分析", + "operators": [ + { + "key": "stat.profile", + "label": "全表统计", + "desc": "输出各字段的缺失率、均值、分位数等描述性统计。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "report", "label": "统计报告", "type": "report" } ], + "params": [ + { "key": "columns", "label": "统计字段", "type": "COLUMNS", "bindPort": "in", "help": "留空表示全部字段" } + ] + }, + { + "key": "stat.correlation", + "label": "相关性分析", + "desc": "计算字段间的皮尔逊相关系数矩阵。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "report", "label": "相关矩阵", "type": "report" } ], + "params": [ + { "key": "columns", "label": "参与字段", "type": "COLUMNS", "bindPort": "in" } + ] + }, + { + "key": "stat.iv", + "label": "特征 IV 评估", + "desc": "基于分箱结果计算特征的 WOE 与 IV 值,用于特征筛选。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "report", "label": "IV 报告", "type": "report" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "binCount", "label": "分箱数", "type": "INT", "default": 10, "min": 2, "max": 50 } + ] + }, + { + "key": "stat.scql", + "label": "密态 SQL (SCQL)", + "desc": "受限 SQL 方言:PSI-JOIN / 掩码 WHERE / 公开域 GROUP BY / k-匿名抑制;唯一出口是最终结果表。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "report", "label": "SCQL 结果", "type": "report" } ], + "params": [ + { "key": "tableName", "label": "表别名", "type": "STRING", "default": "t", "help": "SQL 语句里 FROM 后面使用的表名" }, + { "key": "key", "label": "主键列", "type": "STRING", "default": "uid" }, + { "key": "query", "label": "SQL 查询", "type": "STRING", "required": true, "placeholder": "如 SELECT t.city, COUNT(*) AS n FROM t GROUP BY t.city" }, + { "key": "minGroupSize", "label": "k-匿名 k", "type": "INT", "default": 0, "min": 0, "max": 100, "help": "组内行数 < k 时整组抑制" } + ] + } + ] + }, + { + "key": "model", + "label": "联合建模", + "operators": [ + { + "key": "model.lr.train", + "label": "逻辑回归训练", + "desc": "纵向联邦逻辑回归,各方仅持有本地特征切片,梯度密态聚合。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "训练集", "type": "table" } ], + "outputs": [ { "key": "model", "label": "模型", "type": "model" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "epochs", "label": "迭代轮数", "type": "INT", "default": 20, "min": 1, "max": 500 }, + { "key": "learningRate", "label": "学习率", "type": "FLOAT", "default": 0.1, "min": 0.0001, "max": 10 }, + { "key": "batchSize", "label": "批大小", "type": "INT", "default": 1024, "min": 32, "max": 65536 }, + { + "key": "regularization", "label": "正则方式", "type": "SELECT", "default": "l2", + "options": [ + { "value": "none", "label": "不使用" }, + { "value": "l1", "label": "L1" }, + { "value": "l2", "label": "L2" } + ] + }, + { "key": "lambda", "label": "正则强度", "type": "FLOAT", "default": 0.01, "visibleWhen": { "param": "regularization", "in": ["l1", "l2"] } } + ] + }, + { + "key": "model.gbdt.train", + "label": "梯度提升树训练", + "desc": "纵向联邦 GBDT,分裂增益在密态下比较,不泄露特征分布。Nax 暂不支持树模型,会回退到模拟引擎。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "训练集", "type": "table" } ], + "outputs": [ { "key": "model", "label": "模型", "type": "model" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "treeNum", "label": "树数量", "type": "INT", "default": 50, "min": 1, "max": 1000 }, + { "key": "maxDepth", "label": "树深度", "type": "INT", "default": 5, "min": 1, "max": 16 }, + { "key": "learningRate", "label": "学习率", "type": "FLOAT", "default": 0.3 }, + { "key": "subsample", "label": "行采样比例", "type": "SLIDER", "default": 1, "min": 0.1, "max": 1, "step": 0.05 } + ] + }, + { + "key": "model.mlp.train", + "label": "密文 MLP 训练", + "desc": "基于 Nax SecureMLP 的多层感知机:[d→h→1],sigmoid/tanh 隐藏层,权重全程密文,输出层固定 sigmoid。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "训练集", "type": "table" } ], + "outputs": [ { "key": "model", "label": "MLP 模型", "type": "model" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "epochs", "label": "迭代轮数", "type": "INT", "default": 150, "min": 10, "max": 1000 }, + { "key": "learningRate", "label": "学习率", "type": "FLOAT", "default": 0.15, "min": 0.001, "max": 1 }, + { "key": "hiddenSize", "label": "隐藏层大小", "type": "INT", "default": 16, "min": 4, "max": 256 }, + { + "key": "activation", "label": "隐藏层激活", "type": "SELECT", "default": "sigmoid", + "options": [ + { "value": "sigmoid", "label": "Sigmoid(多项式逼近)" }, + { "value": "tanh", "label": "Tanh(多项式逼近)" } + ] + } + ] + }, + { + "key": "model.fedavg.train", + "label": "横向联邦 (FedAvg)", + "desc": "基于 Nax FedAvg 的横向联邦逻辑回归:本地训练 + 安全聚合(mask 或 Paillier),样本分散在多家分行。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "样本表", "type": "table" } ], + "outputs": [ { "key": "model", "label": "联邦模型", "type": "model" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "rounds", "label": "联邦轮数", "type": "INT", "default": 15, "min": 1, "max": 200 }, + { "key": "localEpochs", "label": "每轮本地 epoch", "type": "INT", "default": 3, "min": 1, "max": 20 }, + { "key": "learningRate", "label": "学习率", "type": "FLOAT", "default": 1.0, "min": 0.01, "max": 5 }, + { + "key": "secure", "label": "安全聚合", "type": "SELECT", "default": "mask", + "options": [ + { "value": "mask", "label": "成对掩码(快,不防聚合方合谋)" }, + { "value": "paillier", "label": "Paillier 同态(慢,抗合谋更强)" } + ] + } + ] + }, + { + "key": "model.predict", + "label": "模型预测", + "desc": "加载模型对输入表打分,输出预测结果表。", + "engine": "mpc", + "inputs": [ + { "key": "model", "label": "模型", "type": "model" }, + { "key": "in", "label": "待预测表", "type": "table" } + ], + "outputs": [ { "key": "out", "label": "预测结果", "type": "table" } ], + "params": [ + { "key": "scoreColumn", "label": "得分列名", "type": "STRING", "default": "score" }, + { "key": "keepColumns", "label": "保留字段", "type": "COLUMNS", "bindPort": "in" } + ] + }, + { + "key": "model.evaluate", + "label": "二分类评估", + "desc": "输出 AUC、KS、准确率等指标与分位表现。", + "engine": "mpc", + "inputs": [ { "key": "in", "label": "预测结果", "type": "table" } ], + "outputs": [ { "key": "report", "label": "评估报告", "type": "report" } ], + "params": [ + { "key": "labelColumn", "label": "标签字段", "type": "COLUMNS", "bindPort": "in", "single": true, "required": true }, + { "key": "scoreColumn", "label": "得分字段", "type": "STRING", "default": "score" }, + { "key": "bucketNum", "label": "分位桶数", "type": "INT", "default": 10, "min": 2, "max": 100 } + ] + } + ] + }, + { + "key": "sink", + "label": "结果输出", + "operators": [ + { + "key": "sink.export", + "label": "结果导出", + "desc": "将结果落地到指定参与方的存储,需通过出域审批。", + "engine": "local", + "terminal": true, + "inputs": [ { "key": "in", "label": "输入", "type": "table" } ], + "outputs": [], + "params": [ + { "key": "targetParty", "label": "接收方", "type": "PARTY", "required": true }, + { "key": "fileName", "label": "文件名", "type": "STRING", "required": true, "placeholder": "如 joint_score.csv" }, + { + "key": "format", "label": "文件格式", "type": "SELECT", "default": "csv", + "options": [ + { "value": "csv", "label": "CSV" }, + { "value": "parquet", "label": "Parquet" } + ] + }, + { "key": "needApproval", "label": "需出域审批", "type": "BOOL", "default": true } + ] + } + ] + }, + { + "key": "tee", + "label": "机密计算 (TEE)", + "operators": [ + { + "key": "tee.privacy_aggregate", + "label": "机密聚合", + "desc": "在 TEE 机密容器内对多方数据做聚合(求和/均值/计数),仅加密结果经远程证明门控出域,原始数据不出域。", + "engine": "tee", + "inputs": [ { "key": "in", "label": "输入表", "type": "table" } ], + "outputs": [ { "key": "out", "label": "聚合结果", "type": "table" } ], + "params": [ + { "key": "method", "label": "聚合方式", "type": "SELECT", "default": "sum", "options": [ { "value": "sum", "label": "求和" }, { "value": "mean", "label": "均值" }, { "value": "count", "label": "计数" } ] }, + { "key": "columns", "label": "聚合列", "type": "COLUMNS", "bindPort": "in", "required": true }, + { "key": "deliveryType", "label": "交付类型", "type": "SELECT", "default": "PRIVACY_COMPUTE", "options": [ { "value": "PRIVACY_COMPUTE", "label": "隐私计算" }, { "value": "SANDBOX", "label": "沙箱" } ] } + ] + } + ] + }, + { + "key": "zkp", + "label": "零知识证明", + "operators": [ + { + "key": "zkp.prove", + "label": "零知识证明 (ZKP)", + "desc": "在不泄露秘密的前提下,向审计/监管方证明「持有某授权私钥」或「曾如实提交过某敏感值」。基于 Nax 安全素数群的 Schnorr 身份证明与 Pedersen 承诺,满足合规「权责可证、最小化披露」。", + "engine": "mpc", + "terminal": false, + "inputs": [ + { "key": "secretRef", "label": "密钥/敏感值引用", "type": "any" } + ], + "outputs": [ + { "key": "proof", "label": "零知识证明", "type": "proof" } + ], + "params": [ + { "key": "scheme", "label": "证明方案", "type": "SELECT", "default": "schnorr", "required": true, "options": [ + { "value": "schnorr", "label": "Schnorr 身份证明(证明持有私钥 x,公钥 y=g^x)" }, + { "value": "pedersen", "label": "Pedersen 承诺 + 知识证明(隐藏敏感值 v 后证明确实提交过)" } + ] }, + { "key": "party", "label": "参与方", "type": "STRING", "required": false, "placeholder": "如 hospitalA" }, + { "key": "purpose", "label": "数据用途", "type": "STRING", "required": false, "placeholder": "如 联合统计糖尿病患病率" }, + { "key": "statement", "label": "绑定声明", "type": "STRING", "required": false, "placeholder": "可选;不填则由系统按 party/purpose/nonce 生成,防重放" } + ] + } + ] + } + ] +} diff --git a/src/backend/src/sswflow/catalog/operator-catalog.ts b/src/backend/src/sswflow/catalog/operator-catalog.ts new file mode 100644 index 0000000..ed04efd --- /dev/null +++ b/src/backend/src/sswflow/catalog/operator-catalog.ts @@ -0,0 +1,1104 @@ +/** + * 算子协议目录 —— 原样抽取自 ssw-mvp + * boot/ssw-sswflow/ssw-sswflow-biz/src/main/resources/operators/catalog.json + * 这是画布节点类型、端口、参数的「唯一事实来源」;原始 JSON 留在本目录 catalog.json 备查。 + * 本 TS 常量供 NestJS 运行时零 IO 读取(nest build 不会复制 .json,故不用 readFileSync)。 + */ +export const OPERATOR_CATALOG: any = { + "specVersion": "ssw-op/1.0", + "categories": [ + { + "key": "source", + "label": "数据接入", + "operators": [ + { + "key": "source.dataset", + "label": "数据集输入", + "desc": "从参与方已登记的数据集读取一张表,作为流程的起点。", + "engine": "mpc", + "terminal": false, + "inputs": [], + "outputs": [ + { + "key": "out", + "label": "数据表", + "type": "table" + } + ], + "params": [ + { + "key": "datasetId", + "label": "数据集", + "type": "DATASET", + "required": true, + "help": "选择本方或合作方已授权的数据集" + }, + { + "key": "partition", + "label": "分区过滤", + "type": "STRING", + "required": false, + "placeholder": "如 dt=20260731" + } + ] + } + ] + }, + { + "key": "prep", + "label": "数据预处理", + "operators": [ + { + "key": "prep.intersect", + "label": "隐私求交", + "desc": "在不泄露非交集样本的前提下,计算两方数据集的样本交集。", + "engine": "mpc", + "inputs": [ + { + "key": "left", + "label": "左表", + "type": "table" + }, + { + "key": "right", + "label": "右表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "对齐表", + "type": "table" + } + ], + "params": [ + { + "key": "leftKeys", + "label": "左表关联键", + "type": "COLUMNS", + "bindPort": "left", + "required": true + }, + { + "key": "rightKeys", + "label": "右表关联键", + "type": "COLUMNS", + "bindPort": "right", + "required": true + }, + { + "key": "protocol", + "label": "求交协议", + "type": "SELECT", + "required": true, + "default": "ECDH", + "options": [ + { + "value": "ECDH", + "label": "ECDH(通信量小,适合大表)" + }, + { + "value": "OPRF", + "label": "OPRF(计算快,带宽要求高)" + }, + { + "value": "BLIND", + "label": "盲签名(兼容旧版参与方)" + } + ] + }, + { + "key": "keepOrder", + "label": "保持原表顺序", + "type": "BOOL", + "default": false + }, + { + "key": "allowDuplicate", + "label": "允许键重复", + "type": "BOOL", + "default": false + }, + { + "key": "receiver", + "label": "结果接收方", + "type": "PARTY", + "required": true + } + ] + }, + { + "key": "prep.sample", + "label": "数据采样", + "desc": "按比例抽取样本,支持随机采样与按标签分层采样。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "采样表", + "type": "table" + } + ], + "params": [ + { + "key": "method", + "label": "采样方式", + "type": "SELECT", + "default": "random", + "options": [ + { + "value": "random", + "label": "随机采样" + }, + { + "value": "stratify", + "label": "分层采样" + } + ] + }, + { + "key": "rate", + "label": "采样比例", + "type": "SLIDER", + "default": 0.8, + "min": 0.05, + "max": 1, + "step": 0.05 + }, + { + "key": "stratifyBy", + "label": "分层字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "visibleWhen": { + "param": "method", + "in": [ + "stratify" + ] + } + }, + { + "key": "randomSeed", + "label": "随机种子", + "type": "INT", + "default": 1024 + } + ] + }, + { + "key": "prep.split", + "label": "训练集拆分", + "desc": "将样本切分为训练集与测试集两份输出。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "train", + "label": "训练集", + "type": "table" + }, + { + "key": "test", + "label": "测试集", + "type": "table" + } + ], + "params": [ + { + "key": "trainRate", + "label": "训练集占比", + "type": "SLIDER", + "default": 0.7, + "min": 0.1, + "max": 0.95, + "step": 0.05 + }, + { + "key": "shuffle", + "label": "打乱顺序", + "type": "BOOL", + "default": true + } + ] + }, + { + "key": "prep.fillna", + "label": "缺失值填充", + "desc": "对指定字段的缺失值按策略填充。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "输出表", + "type": "table" + } + ], + "params": [ + { + "key": "columns", + "label": "处理字段", + "type": "COLUMNS", + "bindPort": "in", + "required": true + }, + { + "key": "strategy", + "label": "填充策略", + "type": "SELECT", + "default": "mean", + "options": [ + { + "value": "mean", + "label": "均值" + }, + { + "value": "median", + "label": "中位数" + }, + { + "value": "mode", + "label": "众数" + }, + { + "value": "constant", + "label": "固定值" + } + ] + }, + { + "key": "fillValue", + "label": "填充值", + "type": "STRING", + "visibleWhen": { + "param": "strategy", + "in": [ + "constant" + ] + }, + "placeholder": "如 0" + } + ] + }, + { + "key": "prep.binning", + "label": "分箱编码", + "desc": "对连续特征做等频或卡方分箱,输出分箱规则与编码后的表。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "编码表", + "type": "table" + }, + { + "key": "rule", + "label": "分箱规则", + "type": "rule" + } + ], + "params": [ + { + "key": "columns", + "label": "分箱字段", + "type": "COLUMNS", + "bindPort": "in", + "required": true + }, + { + "key": "binMethod", + "label": "分箱方式", + "type": "SELECT", + "default": "quantile", + "options": [ + { + "value": "quantile", + "label": "等频分箱" + }, + { + "value": "uniform", + "label": "等距分箱" + }, + { + "value": "chimerge", + "label": "卡方分箱" + } + ] + }, + { + "key": "binCount", + "label": "分箱数", + "type": "INT", + "default": 10, + "min": 2, + "max": 100 + } + ] + } + ] + }, + { + "key": "stat", + "label": "统计分析", + "operators": [ + { + "key": "stat.profile", + "label": "全表统计", + "desc": "输出各字段的缺失率、均值、分位数等描述性统计。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "report", + "label": "统计报告", + "type": "report" + } + ], + "params": [ + { + "key": "columns", + "label": "统计字段", + "type": "COLUMNS", + "bindPort": "in", + "help": "留空表示全部字段" + } + ] + }, + { + "key": "stat.correlation", + "label": "相关性分析", + "desc": "计算字段间的皮尔逊相关系数矩阵。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "report", + "label": "相关矩阵", + "type": "report" + } + ], + "params": [ + { + "key": "columns", + "label": "参与字段", + "type": "COLUMNS", + "bindPort": "in" + } + ] + }, + { + "key": "stat.iv", + "label": "特征 IV 评估", + "desc": "基于分箱结果计算特征的 WOE 与 IV 值,用于特征筛选。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "report", + "label": "IV 报告", + "type": "report" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "binCount", + "label": "分箱数", + "type": "INT", + "default": 10, + "min": 2, + "max": 50 + } + ] + }, + { + "key": "stat.scql", + "label": "密态 SQL (SCQL)", + "desc": "受限 SQL 方言:PSI-JOIN / 掩码 WHERE / 公开域 GROUP BY / k-匿名抑制;唯一出口是最终结果表。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "report", + "label": "SCQL 结果", + "type": "report" + } + ], + "params": [ + { + "key": "tableName", + "label": "表别名", + "type": "STRING", + "default": "t", + "help": "SQL 语句里 FROM 后面使用的表名" + }, + { + "key": "key", + "label": "主键列", + "type": "STRING", + "default": "uid" + }, + { + "key": "query", + "label": "SQL 查询", + "type": "STRING", + "required": true, + "placeholder": "如 SELECT t.city, COUNT(*) AS n FROM t GROUP BY t.city" + }, + { + "key": "minGroupSize", + "label": "k-匿名 k", + "type": "INT", + "default": 0, + "min": 0, + "max": 100, + "help": "组内行数 < k 时整组抑制" + } + ] + } + ] + }, + { + "key": "model", + "label": "联合建模", + "operators": [ + { + "key": "model.lr.train", + "label": "逻辑回归训练", + "desc": "纵向联邦逻辑回归,各方仅持有本地特征切片,梯度密态聚合。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "训练集", + "type": "table" + } + ], + "outputs": [ + { + "key": "model", + "label": "模型", + "type": "model" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "epochs", + "label": "迭代轮数", + "type": "INT", + "default": 20, + "min": 1, + "max": 500 + }, + { + "key": "learningRate", + "label": "学习率", + "type": "FLOAT", + "default": 0.1, + "min": 0.0001, + "max": 10 + }, + { + "key": "batchSize", + "label": "批大小", + "type": "INT", + "default": 1024, + "min": 32, + "max": 65536 + }, + { + "key": "regularization", + "label": "正则方式", + "type": "SELECT", + "default": "l2", + "options": [ + { + "value": "none", + "label": "不使用" + }, + { + "value": "l1", + "label": "L1" + }, + { + "value": "l2", + "label": "L2" + } + ] + }, + { + "key": "lambda", + "label": "正则强度", + "type": "FLOAT", + "default": 0.01, + "visibleWhen": { + "param": "regularization", + "in": [ + "l1", + "l2" + ] + } + } + ] + }, + { + "key": "model.gbdt.train", + "label": "梯度提升树训练", + "desc": "纵向联邦 GBDT,分裂增益在密态下比较,不泄露特征分布。Nax 暂不支持树模型,会回退到模拟引擎。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "训练集", + "type": "table" + } + ], + "outputs": [ + { + "key": "model", + "label": "模型", + "type": "model" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "treeNum", + "label": "树数量", + "type": "INT", + "default": 50, + "min": 1, + "max": 1000 + }, + { + "key": "maxDepth", + "label": "树深度", + "type": "INT", + "default": 5, + "min": 1, + "max": 16 + }, + { + "key": "learningRate", + "label": "学习率", + "type": "FLOAT", + "default": 0.3 + }, + { + "key": "subsample", + "label": "行采样比例", + "type": "SLIDER", + "default": 1, + "min": 0.1, + "max": 1, + "step": 0.05 + } + ] + }, + { + "key": "model.mlp.train", + "label": "密文 MLP 训练", + "desc": "基于 Nax SecureMLP 的多层感知机:[d→h→1],sigmoid/tanh 隐藏层,权重全程密文,输出层固定 sigmoid。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "训练集", + "type": "table" + } + ], + "outputs": [ + { + "key": "model", + "label": "MLP 模型", + "type": "model" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "epochs", + "label": "迭代轮数", + "type": "INT", + "default": 150, + "min": 10, + "max": 1000 + }, + { + "key": "learningRate", + "label": "学习率", + "type": "FLOAT", + "default": 0.15, + "min": 0.001, + "max": 1 + }, + { + "key": "hiddenSize", + "label": "隐藏层大小", + "type": "INT", + "default": 16, + "min": 4, + "max": 256 + }, + { + "key": "activation", + "label": "隐藏层激活", + "type": "SELECT", + "default": "sigmoid", + "options": [ + { + "value": "sigmoid", + "label": "Sigmoid(多项式逼近)" + }, + { + "value": "tanh", + "label": "Tanh(多项式逼近)" + } + ] + } + ] + }, + { + "key": "model.fedavg.train", + "label": "横向联邦 (FedAvg)", + "desc": "基于 Nax FedAvg 的横向联邦逻辑回归:本地训练 + 安全聚合(mask 或 Paillier),样本分散在多家分行。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "样本表", + "type": "table" + } + ], + "outputs": [ + { + "key": "model", + "label": "联邦模型", + "type": "model" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "rounds", + "label": "联邦轮数", + "type": "INT", + "default": 15, + "min": 1, + "max": 200 + }, + { + "key": "localEpochs", + "label": "每轮本地 epoch", + "type": "INT", + "default": 3, + "min": 1, + "max": 20 + }, + { + "key": "learningRate", + "label": "学习率", + "type": "FLOAT", + "default": 1.0, + "min": 0.01, + "max": 5 + }, + { + "key": "secure", + "label": "安全聚合", + "type": "SELECT", + "default": "mask", + "options": [ + { + "value": "mask", + "label": "成对掩码(快,不防聚合方合谋)" + }, + { + "value": "paillier", + "label": "Paillier 同态(慢,抗合谋更强)" + } + ] + } + ] + }, + { + "key": "model.predict", + "label": "模型预测", + "desc": "加载模型对输入表打分,输出预测结果表。", + "engine": "mpc", + "inputs": [ + { + "key": "model", + "label": "模型", + "type": "model" + }, + { + "key": "in", + "label": "待预测表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "预测结果", + "type": "table" + } + ], + "params": [ + { + "key": "scoreColumn", + "label": "得分列名", + "type": "STRING", + "default": "score" + }, + { + "key": "keepColumns", + "label": "保留字段", + "type": "COLUMNS", + "bindPort": "in" + } + ] + }, + { + "key": "model.evaluate", + "label": "二分类评估", + "desc": "输出 AUC、KS、准确率等指标与分位表现。", + "engine": "mpc", + "inputs": [ + { + "key": "in", + "label": "预测结果", + "type": "table" + } + ], + "outputs": [ + { + "key": "report", + "label": "评估报告", + "type": "report" + } + ], + "params": [ + { + "key": "labelColumn", + "label": "标签字段", + "type": "COLUMNS", + "bindPort": "in", + "single": true, + "required": true + }, + { + "key": "scoreColumn", + "label": "得分字段", + "type": "STRING", + "default": "score" + }, + { + "key": "bucketNum", + "label": "分位桶数", + "type": "INT", + "default": 10, + "min": 2, + "max": 100 + } + ] + } + ] + }, + { + "key": "sink", + "label": "结果输出", + "operators": [ + { + "key": "sink.export", + "label": "结果导出", + "desc": "将结果落地到指定参与方的存储,需通过出域审批。", + "engine": "local", + "terminal": true, + "inputs": [ + { + "key": "in", + "label": "输入", + "type": "table" + } + ], + "outputs": [], + "params": [ + { + "key": "targetParty", + "label": "接收方", + "type": "PARTY", + "required": true + }, + { + "key": "fileName", + "label": "文件名", + "type": "STRING", + "required": true, + "placeholder": "如 joint_score.csv" + }, + { + "key": "format", + "label": "文件格式", + "type": "SELECT", + "default": "csv", + "options": [ + { + "value": "csv", + "label": "CSV" + }, + { + "value": "parquet", + "label": "Parquet" + } + ] + }, + { + "key": "needApproval", + "label": "需出域审批", + "type": "BOOL", + "default": true + } + ] + } + ] + }, + { + "key": "tee", + "label": "机密计算 (TEE)", + "operators": [ + { + "key": "tee.privacy_aggregate", + "label": "机密聚合", + "desc": "在 TEE 机密容器内对多方数据做聚合(求和/均值/计数),仅加密结果经远程证明门控出域,原始数据不出域。", + "engine": "tee", + "inputs": [ + { + "key": "in", + "label": "输入表", + "type": "table" + } + ], + "outputs": [ + { + "key": "out", + "label": "聚合结果", + "type": "table" + } + ], + "params": [ + { + "key": "method", + "label": "聚合方式", + "type": "SELECT", + "default": "sum", + "options": [ + { + "value": "sum", + "label": "求和" + }, + { + "value": "mean", + "label": "均值" + }, + { + "value": "count", + "label": "计数" + } + ] + }, + { + "key": "columns", + "label": "聚合列", + "type": "COLUMNS", + "bindPort": "in", + "required": true + }, + { + "key": "deliveryType", + "label": "交付类型", + "type": "SELECT", + "default": "PRIVACY_COMPUTE", + "options": [ + { + "value": "PRIVACY_COMPUTE", + "label": "隐私计算" + }, + { + "value": "SANDBOX", + "label": "沙箱" + } + ] + } + ] + } + ] + }, + { + "key": "zkp", + "label": "零知识证明", + "operators": [ + { + "key": "zkp.prove", + "label": "零知识证明 (ZKP)", + "desc": "在不泄露秘密的前提下,向审计/监管方证明「持有某授权私钥」或「曾如实提交过某敏感值」。基于 Nax 安全素数群的 Schnorr 身份证明与 Pedersen 承诺,满足合规「权责可证、最小化披露」。", + "engine": "mpc", + "terminal": false, + "inputs": [ + { + "key": "secretRef", + "label": "密钥/敏感值引用", + "type": "any" + } + ], + "outputs": [ + { + "key": "proof", + "label": "零知识证明", + "type": "proof" + } + ], + "params": [ + { + "key": "scheme", + "label": "证明方案", + "type": "SELECT", + "default": "schnorr", + "required": true, + "options": [ + { + "value": "schnorr", + "label": "Schnorr 身份证明(证明持有私钥 x,公钥 y=g^x)" + }, + { + "value": "pedersen", + "label": "Pedersen 承诺 + 知识证明(隐藏敏感值 v 后证明确实提交过)" + } + ] + }, + { + "key": "party", + "label": "参与方", + "type": "STRING", + "required": false, + "placeholder": "如 hospitalA" + }, + { + "key": "purpose", + "label": "数据用途", + "type": "STRING", + "required": false, + "placeholder": "如 联合统计糖尿病患病率" + }, + { + "key": "statement", + "label": "绑定声明", + "type": "STRING", + "required": false, + "placeholder": "可选;不填则由系统按 party/purpose/nonce 生成,防重放" + } + ] + } + ] + } + ] +}; + +export function allOperators(): any[] { + return OPERATOR_CATALOG.categories.flatMap((c: any) => + (c.operators || []).map((o: any) => ({ ...o, category: c.key, categoryLabel: c.label })), + ); +} + +export function findOperator(key: string): any { + return allOperators().find((o: any) => o.key === key) || null; +} diff --git a/src/backend/src/sswflow/dataset.controller.ts b/src/backend/src/sswflow/dataset.controller.ts new file mode 100644 index 0000000..96cdbbb --- /dev/null +++ b/src/backend/src/sswflow/dataset.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { DatasetService } from './dataset.service'; + +const MODULE_KEY = 'sswflow/Dataset'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 数据集 —— /api/ssw/sswflow/Dataset/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/Dataset') +export class DatasetController { + constructor( + private readonly svc: DatasetService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/dataset.entity.ts b/src/backend/src/sswflow/dataset.entity.ts new file mode 100644 index 0000000..336485f --- /dev/null +++ b/src/backend/src/sswflow/dataset.entity.ts @@ -0,0 +1,51 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 数据集(sswflow_dataset)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../DatasetEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_dataset' }) +export class DatasetEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_dataset_code', type: 'varchar', length: 100, nullable: true }) + datasetCode: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_party_id', type: 'varchar', length: 50, nullable: true }) + partyId: string; + + @Column({ name: 'f_datasource_id', type: 'varchar', length: 50, nullable: true }) + datasourceId: string; + + @Column({ name: 'f_storage_type', type: 'varchar', length: 50, nullable: true }) + storageType: string; + + @Column({ name: 'f_location', type: 'varchar', length: 500, nullable: true }) + location: string; + + @Column({ name: 'f_desc', type: 'varchar', length: 1000, nullable: true }) + desc: string; + + @Column({ name: 'f_row_count', type: 'int', nullable: true, default: 0 }) + rowCount: number; + + @Column({ name: 'f_columns', type: 'text', nullable: true }) + columns: string; + + @Column({ name: 'f_external_ref', type: 'varchar', length: 500, nullable: true }) + externalRef: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/dataset.service.ts b/src/backend/src/sswflow/dataset.service.ts new file mode 100644 index 0000000..2952403 --- /dev/null +++ b/src/backend/src/sswflow/dataset.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { DatasetEntity } from './dataset.entity'; + +/** 数据集服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class DatasetService { + constructor( + @InjectRepository(DatasetEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as DatasetEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as DatasetEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as DatasetEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/datasetauth.controller.ts b/src/backend/src/sswflow/datasetauth.controller.ts new file mode 100644 index 0000000..9189479 --- /dev/null +++ b/src/backend/src/sswflow/datasetauth.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { DatasetAuthService } from './datasetauth.service'; + +const MODULE_KEY = 'sswflow/DatasetAuth'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 数据集授权 —— /api/ssw/sswflow/DatasetAuth/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/DatasetAuth') +export class DatasetAuthController { + constructor( + private readonly svc: DatasetAuthService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/datasetauth.entity.ts b/src/backend/src/sswflow/datasetauth.entity.ts new file mode 100644 index 0000000..299e757 --- /dev/null +++ b/src/backend/src/sswflow/datasetauth.entity.ts @@ -0,0 +1,42 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 数据集授权(sswflow_dataset_auth)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../DatasetAuthEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_dataset_auth' }) +export class DatasetAuthEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_dataset_id', type: 'varchar', length: 50, nullable: true }) + datasetId: string; + + @Column({ name: 'f_project_id', type: 'varchar', length: 50, nullable: true }) + projectId: string; + + @Column({ name: 'f_auth_status', type: 'varchar', length: 32, nullable: true }) + authStatus: string; + + @Column({ name: 'f_auth_time', type: 'timestamp', nullable: true }) + authTime: Date; + + @Column({ name: 'f_auth_user_id', type: 'varchar', length: 50, nullable: true }) + authUserId: string; + + @Column({ name: 'f_expire_time', type: 'timestamp', nullable: true }) + expireTime: Date; + + @Column({ name: 'f_reject_reason', type: 'varchar', length: 1000, nullable: true }) + rejectReason: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/datasetauth.service.ts b/src/backend/src/sswflow/datasetauth.service.ts new file mode 100644 index 0000000..87fc0b9 --- /dev/null +++ b/src/backend/src/sswflow/datasetauth.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { DatasetAuthEntity } from './datasetauth.entity'; + +/** 数据集授权服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class DatasetAuthService { + constructor( + @InjectRepository(DatasetAuthEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as DatasetAuthEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as DatasetAuthEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as DatasetAuthEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/datasource.controller.ts b/src/backend/src/sswflow/datasource.controller.ts new file mode 100644 index 0000000..9fbc432 --- /dev/null +++ b/src/backend/src/sswflow/datasource.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { DatasourceService } from './datasource.service'; + +const MODULE_KEY = 'sswflow/Datasource'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 数据源 —— /api/ssw/sswflow/Datasource/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/Datasource') +export class DatasourceController { + constructor( + private readonly svc: DatasourceService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/datasource.entity.ts b/src/backend/src/sswflow/datasource.entity.ts new file mode 100644 index 0000000..d199032 --- /dev/null +++ b/src/backend/src/sswflow/datasource.entity.ts @@ -0,0 +1,39 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 数据源(sswflow_datasource)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../DatasourceEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_datasource' }) +export class DatasourceEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_party_id', type: 'varchar', length: 50, nullable: true }) + partyId: string; + + @Column({ name: 'f_type', type: 'varchar', length: 50, nullable: true }) + type: string; + + @Column({ name: 'f_config', type: 'text', nullable: true }) + config: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_desc', type: 'varchar', length: 1000, nullable: true }) + desc: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/datasource.service.ts b/src/backend/src/sswflow/datasource.service.ts new file mode 100644 index 0000000..e641bc9 --- /dev/null +++ b/src/backend/src/sswflow/datasource.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { DatasourceEntity } from './datasource.entity'; + +/** 数据源服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class DatasourceService { + constructor( + @InjectRepository(DatasourceEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as DatasourceEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as DatasourceEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as DatasourceEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/engine.controller.ts b/src/backend/src/sswflow/engine.controller.ts new file mode 100644 index 0000000..a628242 --- /dev/null +++ b/src/backend/src/sswflow/engine.controller.ts @@ -0,0 +1,20 @@ +import { Controller, Get, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { EngineRegistry } from './engine/engine-registry'; + +/** 引擎状态自检:当前驱动、ssw-mpc 二进制探测、19 个算子的原生/降级分布。 */ +@Controller('api/ssw/sswflow/Engine') +export class EngineController { + constructor( + private readonly auth: AuthService, + private readonly engines: EngineRegistry, + ) {} + + @Get('Info') + async info(@Req() req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + return ActionResult.success(await this.engines.info()); + } +} diff --git a/src/backend/src/sswflow/engine/compute-engine.ts b/src/backend/src/sswflow/engine/compute-engine.ts new file mode 100644 index 0000000..034e2db --- /dev/null +++ b/src/backend/src/sswflow/engine/compute-engine.ts @@ -0,0 +1,69 @@ +/** + * 隐私计算引擎适配接口 —— 对应 ssw-mvp `engine/ComputeEngine.java` + * + * 原实现的三个引擎:SimulationComputeEngine(本地模拟)/ NaxComputeEngine(NAX 多方算术)/ + * TeeComputeEngine(TEE)。**本独立项目把执行底座整体换成 ssw-mpc**: + * - SimulationEngine 纯 TS 模拟,无外部依赖,默认驱动(保证编排闭环可跑) + * - MpcEngine 对接 ../ssw-mpc 的 Rust CLI(mpc orch / mpc psi / mpc lr ...) + * 平台侧(FlowRunService)只依赖本接口;换框架 = 换一个实现,DAG/状态机/契约不动。 + * + * 算子定义 catalog.json 里的 engine 字段(mpc / local / tee)仍作为选路依据。 + */ +import { FlowGraph } from './flow-graph'; + +export interface StepArtifact { + portKey: string; + type: 'table' | 'report' | 'model' | 'rule' | 'proof'; + title: string; + summary?: string; + columns?: any[]; + rows?: any[]; + metrics?: Record; + uri?: string; + rowCount?: number; +} + +export interface StepContext { + runId: string; + stepId: string; + operatorKey: string; + label: string; + params: Record; + engineType: string; + /** targetPort -> 上游产物(上游节点执行结果按端口聚合) */ + inputs: Record; + /** 参与方 id 列表(来自项目/数据集归属) */ + parties: string[]; + graph: FlowGraph; + /** 引擎运行所需的数据集/参与方等上下文,由 FlowRunService 预填 */ + datasetMap?: Record; + partyMap?: Record; +} + +export interface StepResult { + status: 'SUCCESS' | 'FAILED'; + errorMsg?: string; + artifacts: StepArtifact[]; + logs: string[]; + /** 实际执行引擎名,写进运行事件便于追溯 */ + engineName: string; + /** 外部作业 id(ssw-mpc 的 job/run id),模拟引擎为空 */ + externalJobId?: string; +} + +export interface ComputeEngine { + /** 引擎名,写进运行日志 */ + readonly name: string; + /** 是否接管该算子的执行环境:mpc / local / tee */ + supports(engineType: string, operatorKey: string): boolean; + /** 执行单个算子节点;失败请返回 status=FAILED 而不是抛裸异常 */ + execute(ctx: StepContext): Promise; +} + +export function success(engineName: string, artifacts: StepArtifact[] = [], logs: string[] = [], externalJobId?: string): StepResult { + return { status: 'SUCCESS', artifacts, logs, engineName, externalJobId }; +} + +export function failed(engineName: string, errorMsg: string, logs: string[] = []): StepResult { + return { status: 'FAILED', errorMsg, artifacts: [], logs, engineName }; +} diff --git a/src/backend/src/sswflow/engine/engine-registry.ts b/src/backend/src/sswflow/engine/engine-registry.ts new file mode 100644 index 0000000..dd110e7 --- /dev/null +++ b/src/backend/src/sswflow/engine/engine-registry.ts @@ -0,0 +1,55 @@ +/** + * 引擎注册与选路 —— 对应 ssw-mvp `SswflowExecutorConfig` + `ComputeEngine` SPI 的多实现选路。 + * 不改业务代码即可换底座:MPC_DRIVER=mpc 时把 ssw-mpc 引擎放在最前。 + */ +import { Injectable } from '@nestjs/common'; +import { ComputeEngine } from './compute-engine'; +import { SimulationEngine } from './simulation-engine'; +import { MpcEngine } from './mpc-engine'; +import { mpcSettings, probeMpc } from './mpc-client'; +import { MPC_OPERATOR_MAP } from './mpc-operator-map'; + +@Injectable() +export class EngineRegistry { + readonly driver: string; + private readonly engines: ComputeEngine[]; + + constructor() { + const s = mpcSettings(); + this.driver = s.enabled ? 'mpc' : 'simulation'; + this.engines = s.enabled ? [new MpcEngine(s), new SimulationEngine()] : [new SimulationEngine()]; + } + + select(engineType: string, operatorKey: string): ComputeEngine { + return this.engines.find((e) => e.supports(engineType, operatorKey)) || this.engines[this.engines.length - 1]; + } + + /** 供 /Engine/Info 展示真实能力边界(不粉饰 TODO) */ + async info() { + const s = mpcSettings(); + const probe = s.enabled ? await probeMpc(s) : null; + const map = Object.entries(MPC_OPERATOR_MAP).map(([key, cap]) => ({ key, ...cap })); + return { + driver: this.driver, + engines: this.engines.map((e) => e.name), + mpc: { + repo: s.workDir, + bin: s.bin, + sites: s.sites, + mode: s.mode, + demoUrl: s.demoUrl, + hostdUrl: s.hostdUrl, + available: probe?.available ?? false, + detail: probe?.detail ?? 'MPC_DRIVER 未开启,未探测 Rust 二进制', + }, + capabilities: map, + summary: { + native: map.filter((m) => m.status === 'native').length, + partial: map.filter((m) => m.status === 'partial').length, + local: map.filter((m) => m.status === 'local').length, + unsupported: map.filter((m) => m.status === 'unsupported').length, + }, + realExec: process.env.MPC_REAL_EXEC === '1', + }; + } +} diff --git a/src/backend/src/sswflow/engine/flow-graph.ts b/src/backend/src/sswflow/engine/flow-graph.ts new file mode 100644 index 0000000..30303e5 --- /dev/null +++ b/src/backend/src/sswflow/engine/flow-graph.ts @@ -0,0 +1,193 @@ +/** + * 流程画布图模型 —— 机械翻译自 ssw-mvp + * boot/ssw-sswflow/.../engine/FlowGraph.java + * + * 把 flow.f_steps / flow.f_edges 两段 JSON 解析成可计算的有向图, + * 提供 Kahn 拓扑排序、环检测、端口级连线绑定与运行前合法性校验。 + * + * steps: [{ stepId, operatorKey, label, x, y, params:{} }] + * edges: [{ edgeId, sourceStepId, sourcePort, targetStepId, targetPort }] + * + * 迁移到 JNPF(Java) 时本文件直接对应同名 FlowGraph,数据结构逐字保值。 + */ +import { findOperator } from '../catalog/operator-catalog'; + +export interface FlowStep { + stepId: string; + operatorKey: string; + label?: string; + x?: number; + y?: number; + params?: Record; +} + +export interface FlowEdge { + edgeId?: string; + sourceStepId: string; + sourcePort?: string; + targetStepId: string; + targetPort?: string; +} + +export interface GraphIssue { + level: 'ERROR' | 'WARN'; + stepId?: string; + message: string; +} + +export class FlowGraph { + readonly steps = new Map(); + readonly edges: FlowEdge[] = []; + /** stepId -> 下游 stepId 集合 */ + readonly outgoing = new Map>(); + /** stepId -> 上游 stepId 集合 */ + readonly incoming = new Map>(); + /** targetStepId -> (targetPort -> ["sourceStepId#sourcePort"]) */ + readonly inputBindings = new Map>(); + + static parse(stepsJson?: string, edgesJson?: string): FlowGraph { + const g = new FlowGraph(); + const steps = parseArray(stepsJson); + for (const step of steps) { + if (!step || !step.stepId) continue; + g.steps.set(step.stepId, { + ...step, + x: Number(step.x) || 0, + y: Number(step.y) || 0, + params: step.params || {}, + }); + g.outgoing.set(step.stepId, new Set()); + g.incoming.set(step.stepId, new Set()); + g.inputBindings.set(step.stepId, new Map()); + } + for (const edge of parseArray(edgesJson)) { + if (!edge || !g.steps.has(edge.sourceStepId) || !g.steps.has(edge.targetStepId)) continue; + g.edges.push(edge); + g.outgoing.get(edge.sourceStepId)!.add(edge.targetStepId); + g.incoming.get(edge.targetStepId)!.add(edge.sourceStepId); + const targetPort = edge.targetPort || 'in'; + const sourcePort = edge.sourcePort || 'out'; + const portMap = g.inputBindings.get(edge.targetStepId)!; + if (!portMap.has(targetPort)) portMap.set(targetPort, []); + portMap.get(targetPort)!.push(`${edge.sourceStepId}#${sourcePort}`); + } + return g; + } + + isEmpty(): boolean { + return this.steps.size === 0; + } + + getStep(stepId: string): FlowStep | undefined { + return this.steps.get(stepId); + } + + /** Kahn 拓扑排序;存在环时返回数组长度小于节点数 */ + topologicalOrder(): string[] { + const indegree = new Map(); + this.steps.forEach((_s, id) => indegree.set(id, this.incoming.get(id)!.size)); + const queue: string[] = []; + indegree.forEach((degree, id) => { + if (degree === 0) queue.push(id); + }); + const ordered: string[] = []; + while (queue.length) { + const id = queue.shift()!; + ordered.push(id); + for (const next of this.outgoing.get(id)!) { + const left = (indegree.get(next) || 0) - 1; + indegree.set(next, left); + if (left === 0) queue.push(next); + } + } + return ordered; + } + + /** 上游 stepId 集合(含所有层级的祖先)—— 对应 Java upstreamClosure */ + ancestors(stepId: string): Set { + const seen = new Set(); + const stack = [...(this.incoming.get(stepId) || [])]; + while (stack.length) { + const id = stack.pop()!; + if (seen.has(id)) continue; + seen.add(id); + for (const p of this.incoming.get(id) || []) stack.push(p); + } + return seen; + } + + /** 下游 stepId 集合(含所有层级的后继)—— 对应 Java downstreamClosure */ + descendants(stepId: string): Set { + const seen = new Set(); + const stack = [...(this.outgoing.get(stepId) || [])]; + while (stack.length) { + const id = stack.pop()!; + if (seen.has(id)) continue; + seen.add(id); + for (const n of this.outgoing.get(id) || []) stack.push(n); + } + return seen; + } + + /** + * 运行前校验:空图 / 环 / 未知算子 / 必填参数 / 必填输入端口未连线。 + * 与原 Java FlowServiceImpl.validate 语义一致,返回 issues 而不是抛异常, + * 便于前端一次拿到全部问题。 + */ + validate(): GraphIssue[] { + const issues: GraphIssue[] = []; + if (this.isEmpty()) { + issues.push({ level: 'ERROR', message: '画布为空,请先添加节点' }); + return issues; + } + const order = this.topologicalOrder(); + if (order.length !== this.steps.size) { + issues.push({ level: 'ERROR', message: '流程中存在环,无法拓扑排序' }); + } + this.steps.forEach((step, id) => { + const op = findOperator(step.operatorKey); + if (!op) { + issues.push({ level: 'ERROR', stepId: id, message: `未知算子:${step.operatorKey}` }); + return; + } + for (const p of op.params || []) { + if (!p.required) continue; + const v = (step.params || {})[p.key]; + if (v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)) { + issues.push({ + level: 'ERROR', + stepId: id, + message: `节点「${step.label || op.label}」缺少必填参数:${p.label}(${p.key})`, + }); + } + } + const bound = this.inputBindings.get(id) || new Map(); + for (const port of op.inputs || []) { + if (!(bound.get(port.key) || []).length) { + issues.push({ + level: 'ERROR', + stepId: id, + message: `节点「${step.label || op.label}」输入端口 ${port.label}(${port.key})未连线`, + }); + } + } + }); + // 对齐 Java FlowServiceImpl.validate:97-103 —— 必须有一个终态算子, + // 否则流程没有结果出口,运行时会「全绿但什么都没产出」。 + const hasTerminal = [...this.steps.values()].some((s) => findOperator(s.operatorKey)?.terminal); + if (!hasTerminal) { + issues.push({ level: 'ERROR', message: '缺少终态算子(sink.export),流程没有结果出口' }); + } + return issues; + } +} + +function parseArray(json?: string): T[] { + if (!json || !json.trim()) return []; + try { + const v = JSON.parse(json); + return Array.isArray(v) ? (v as T[]) : []; + } catch { + return []; + } +} diff --git a/src/backend/src/sswflow/engine/mpc-client.ts b/src/backend/src/sswflow/engine/mpc-client.ts new file mode 100644 index 0000000..5c24194 --- /dev/null +++ b/src/backend/src/sswflow/engine/mpc-client.ts @@ -0,0 +1,200 @@ +/** + * ssw-mpc 进程/服务客户端 —— 唯一与 Rust 侧打交道的地方。 + * + * 依据(../ssw-mpc 源码实测,不是推测): + * crates/mpc-cli/src/main.rs:106-155 顶层子命令与全局 `--report json` + * crates/mpc-cli/src/main.rs:2623-2710 `mpc orch run --plan --sites [--listen] [--fxp] [--seed] [--timeout] [--state-dir]` + * crates/mpc-orch/src/plan.rs:13-31 plan 只认 job / deps / expect / data 四指令 + * crates/mpc-cli/src/main.rs:... `mpc orch status --state-dir DIR [--job NAME]` + * demo/src/main.rs POST /<算子>/api/run、GET /api/job/、:18851 + * demo/src/session.rs hostd :3010 / control-plane :3020 / gate :18850 + * + * 所有调用都带超时并降级为可读错误;**不修改 ssw-mpc 仓库任何文件**。 + */ +import { execFile } from 'child_process'; +import { promisify } from 'util'; +import { randomBytes } from 'crypto'; +import * as fs from 'fs'; +import * as path from 'path'; + +const execFileAsync = promisify(execFile); + +export interface MpcSettings { + /** 是否启用真实 ssw-mpc 下发(MPC_DRIVER=mpc) */ + enabled: boolean; + /** `mpc` 可执行文件路径,默认 target/debug/mpc */ + bin: string; + /** ssw-mpc 仓库根目录(cwd) */ + workDir: string; + /** 全体站点,字典序即 party 编号(ssw-mpc 铁律) */ + sites: string[]; + /** orch 模式:trusted / semi / tss(semi/tss 多方协议尚未实现) */ + mode: string; + /** 单次进程调用超时 ms */ + timeoutMs: number; + /** demo HTTP 算子服务 */ + demoUrl: string; + /** 宿主控制面 */ + hostdUrl: string; + controlPlaneUrl: string; + /** 状态/计划文件落盘目录 */ + stateRoot: string; +} + +export function mpcSettings(): MpcSettings { + // ★ 仓库根解析顺序:MPC_REPO(绝对或相对)→ 相对 cwd 的候选路径。 + // 候选路径要够:`src/backend` 运行时,`../../ssw-mpc` 会落到 workspace 根下, + // 正确位置是 `../../../ssw-mpc`(即 workspace/ssw-mpc)。两个都试,取存在的那个。 + const candidates = [ + process.env.MPC_REPO, + path.resolve(process.cwd(), '../../../ssw-mpc'), + path.resolve(process.cwd(), '../../ssw-mpc'), + path.resolve(process.cwd(), '../ssw-mpc'), + '/Users/xs/Desktop/workspace/ssw-mpc', + ].filter(Boolean) as string[]; + const repo = + candidates.find((p) => fs.existsSync(path.join(p, 'target/debug/mpc'))) + || candidates.find((p) => fs.existsSync(p)) + || candidates[0]; + return { + enabled: (process.env.MPC_DRIVER || 'simulation').toLowerCase() === 'mpc', + bin: process.env.MPC_BIN || path.join(repo, 'target/debug/mpc'), + workDir: process.env.MPC_WORKDIR || repo, + sites: (process.env.MPC_SITES || 'alice,bob').split(',').map((s) => s.trim()).filter(Boolean).sort(), + mode: process.env.MPC_MODE || 'trusted', + timeoutMs: Number(process.env.MPC_TIMEOUT_MS || 60000), + demoUrl: process.env.MPC_DEMO_URL || 'http://127.0.0.1:18851', + hostdUrl: process.env.MPC_HOSTD_URL || 'http://127.0.0.1:3010', + controlPlaneUrl: process.env.MPC_CONTROL_PLANE_URL || 'http://127.0.0.1:3020', + stateRoot: process.env.MPC_STATE_DIR || path.join(process.cwd(), '.mpc-state'), + }; +} + +export interface CliResult { + ok: boolean; + stdout: string; + stderr: string; + command: string; + exitCode: number; +} + +/** 执行一次 mpc CLI 调用。全局 `--report json` 放在最前(main.rs:112 明确子命令前后都认)。 */ +export async function runCli(argv: string[], settings = mpcSettings(), json = true): Promise { + const args = json ? ['--report', 'json', ...argv] : argv; + const command = `mpc ${args.join(' ')}`; + try { + const { stdout, stderr } = await execFileAsync(settings.bin, args, { + cwd: settings.workDir, + timeout: settings.timeoutMs, + maxBuffer: 8 * 1024 * 1024, + env: { ...process.env, MPC_MODE: settings.mode }, + }); + return { ok: true, stdout: String(stdout || ''), stderr: String(stderr || ''), command, exitCode: 0 }; + } catch (e: any) { + return { + ok: false, + stdout: String(e.stdout || ''), + stderr: String(e.stderr || e.message || ''), + command, + exitCode: typeof e.code === 'number' ? e.code : -1, + }; + } +} + +/** 探测 ssw-mpc 是否可用(可执行文件在 + version 能跑),供 /Engine/Info 展示真实状态。 */ +export async function probeMpc(settings = mpcSettings()): Promise<{ available: boolean; detail: string; settings: MpcSettings }> { + const exists = fs.existsSync(settings.bin); + if (!exists) { + return { available: false, detail: `找不到 mpc 可执行文件:${settings.bin}`, settings }; + } + const r = await runCli(['version'], settings); + return { + available: r.ok, + detail: r.ok ? r.stdout.trim() || 'mpc version ok' : r.stderr.trim(), + settings, + }; +} + +/** + * 编译并运行一张作业级 plan。 + * ⚠️ `mpc orch run` 会阻塞等所有 `mpc agent` 连入;没有 agent 时按 --timeout 超时。 + * 故默认 `execute=false` 只产出 plan 文本,真正下发需显式打开。 + */ +export async function runOrchPlan( + plan: string, + runId: string, + execute: boolean, + settings = mpcSettings(), +): Promise<{ planPath: string; stateDir: string; argv: string[]; result?: CliResult; events: any[] }> { + const stateDir = path.join(settings.stateRoot, runId); + const planDir = path.join(stateDir, 'plans'); + fs.mkdirSync(planDir, { recursive: true }); + const planPath = path.join(planDir, 'flow.plan'); + fs.writeFileSync(planPath, plan, 'utf8'); + + const argv = [ + 'orch', 'run', + '--plan', planPath, + '--sites', settings.sites.join(','), + '--state-dir', stateDir, + '--timeout', String(Math.max(1, Math.floor(settings.timeoutMs / 1000))), + '--seed', randomBytes(32).toString('hex'), // 必须 64 hex 且非全零 + ]; + if (process.env.MPC_ORCH_LISTEN) argv.push('--listen', process.env.MPC_ORCH_LISTEN); + if (!execute) return { planPath, stateDir, argv, events: [] }; + + const result = await runCli(argv, settings); + let events: any[] = []; + try { + const statusFile = path.join(stateDir, 'events.jsonl'); + if (fs.existsSync(statusFile)) { + events = fs.readFileSync(statusFile, 'utf8').split('\n').filter(Boolean).map((l) => { + try { return JSON.parse(l); } catch { return { raw: l }; } + }); + } + } catch { /* 状态文件解析失败不影响主流程 */ } + return { planPath, stateDir, argv, result, events }; +} + +/** 查询 ssw-mpc 编排作业状态(JSONL 落盘,工具消费)。 */ +export async function orchStatus(stateDir: string, job?: string, settings = mpcSettings()): Promise { + const argv = ['orch', 'status', '--state-dir', stateDir]; + if (job) argv.push('--job', job); + return runCli(argv, settings); +} + +/** demo 算子 HTTP 服务:POST //api/run;返回 { jobId } 或同步结果。 */ +export async function demoRun(name: string, payload: any, settings = mpcSettings()): Promise { + const url = `${settings.demoUrl.replace(/\/$/, '')}/${name}/api/run`; + const res = await fetch(url, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify(payload || {}), + signal: AbortSignal.timeout(settings.timeoutMs), + }); + if (!res.ok) throw new Error(`ssw-mpc demo ${name} 返回 HTTP ${res.status}: ${await res.text()}`); + return res.json(); +} + +/** demo 算子异步作业查询:GET /api/job/,直到 DONE/FAILED。 */ +export async function demoPoll(jobId: string, settings = mpcSettings(), intervalMs = 300): Promise { + const url = `${settings.demoUrl.replace(/\/$/, '')}/api/job/${encodeURIComponent(jobId)}`; + const deadline = Date.now() + settings.timeoutMs; + while (Date.now() < deadline) { + const res = await fetch(url, { signal: AbortSignal.timeout(5000) }); + if (!res.ok) throw new Error(`ssw-mpc job ${jobId} 查询失败 HTTP ${res.status}`); + const body: any = await res.json(); + const state = String(body.state || body.status || '').toUpperCase(); + if (['DONE', 'SUCCESS', 'OK', 'FAILED', 'ERROR'].includes(state)) return body; + await new Promise((r) => setTimeout(r, intervalMs)); + } + throw new Error(`ssw-mpc job ${jobId} 轮询超时`); +} + +/** 宿主侧:hostd 健康检查(TEE / 节点注册用)。 */ +export async function hostdHealth(settings = mpcSettings()): Promise { + const res = await fetch(`${settings.hostdUrl.replace(/\/$/, '')}/healthz`, { + signal: AbortSignal.timeout(3000), + }); + return { status: res.status, body: await res.text() }; +} diff --git a/src/backend/src/sswflow/engine/mpc-engine.ts b/src/backend/src/sswflow/engine/mpc-engine.ts new file mode 100644 index 0000000..f1edf2c --- /dev/null +++ b/src/backend/src/sswflow/engine/mpc-engine.ts @@ -0,0 +1,140 @@ +/** + * ssw-mpc 执行引擎 —— 替代 ssw-mvp 的 NaxComputeEngine / RemoteNaxComputeEngine / TeeComputeEngine。 + * + * 设计要点(务必读,避免误判"已经全量真实计算"): + * 1. ssw-mpc 没有外部可提交的 JSON IR,`mpc node/psi/lr` 的计算类型编译期写死; + * 因此本引擎按 `MPC_OPERATOR_MAP` 逐算子映射为 **CLI 子命令**, + * 整图依赖则编译为 `mpc orch run` 的 job/deps plan(见 mpc-operator-map.ts)。 + * 2. native 算子在 `MPC_REAL_EXEC=1` 时真起 Rust 进程;未开启时仍生成确切命令写进 + * run_event(可审计),产物由 SimulationEngine 生成并**明确标记 simulated**。 + * 未对齐(partial/unsupported)的算子一律降级并写 WARN 事件,绝不静默冒充密态计算。 + * 3. `mpc psi/lr` 等会话类子命令需要各方 `mpc agent` 进程在场,单进程调用会等到超时; + * 生产部署请配合 ssw-mpc 的 deploy/ 起多方,或用 demo HTTP 算子服务(MPC_DEMO_URL)。 + */ +import { ComputeEngine, StepArtifact, StepContext, StepResult, failed, success } from './compute-engine'; +import { SimulationEngine } from './simulation-engine'; +import { capabilityOf, MpcStatus } from './mpc-operator-map'; +import { MpcSettings, mpcSettings, runCli } from './mpc-client'; + +export class MpcEngine implements ComputeEngine { + readonly name = 'ssw-mpc'; + private readonly sim = new SimulationEngine(); + private readonly settings: MpcSettings; + + constructor(settings = mpcSettings()) { + this.settings = settings; + } + + supports(_engineType: string, _operatorKey: string): boolean { + return true; // 由 EngineFactory 选路;本引擎内部再按 capability 决定下发/降级 + } + + async execute(ctx: StepContext): Promise { + const cap = capabilityOf(ctx.operatorKey); + const logs: string[] = [`[ssw-mpc] 算子 ${ctx.operatorKey} → crate=${cap.crate} status=${cap.status}`]; + const fallbackReason = this.fallbackReason(cap.status, cap.note); + + if (fallbackReason) { + const sim = await this.sim.execute(ctx); + logs.push(...sim.logs, `[WARN][降级] ${fallbackReason}`); + return { + ...sim, + engineName: `${this.name}(${cap.status})`, + logs, + artifacts: sim.artifacts.map((a) => ({ ...a, summary: `[simulated] ${a.summary || ''}` })), + }; + } + + const argv = this.buildCliArgv(ctx, cap.cli!); + const command = `mpc ${argv.join(' ')}`; + logs.push(`[ssw-mpc] 命令: ${command}`); + + if (process.env.MPC_REAL_EXEC !== '1') { + const sim = await this.sim.execute(ctx); + logs.push(...sim.logs, '[INFO] MPC_REAL_EXEC!=1,未实际下发;产物标记 simulated。设 MPC_REAL_EXEC=1 并启动各方 agent 后真实执行。'); + return { + ...sim, engineName: `${this.name}(dry-run)`, logs, externalJobId: command, + artifacts: sim.artifacts.map((a) => ({ ...a, summary: `[simulated] ${a.summary || ''}` })), + }; + } + + const r = await runCli(argv, this.settings); + logs.push(`[ssw-mpc] exit=${r.exitCode} ${r.stdout.slice(0, 400)}`); + if (!r.ok) { + logs.push(`[ERROR] ${r.stderr.slice(0, 400)}`); + return failed(this.name, `ssw-mpc 执行失败(exit=${r.exitCode}):${r.stderr.slice(0, 200) || r.stdout.slice(0, 200)}`, logs); + } + return success(this.name, this.artifactsFromOutput(ctx, r.stdout), logs, command); + } + + private fallbackReason(status: MpcStatus, note: string): string | null { + if (status === 'local') return `编排层职责,无需下发 ssw-mpc:${note}`; + if (status === 'partial') return `ssw-mpc 能力部分对齐,已回退模拟:${note}`; + if (status === 'unsupported') return `ssw-mpc 暂无对应算子,已回退模拟:${note}`; + return null; + } + + /** + * 构造 ssw-mpc CLI 参数。 + * 优先使用节点参数里的 `mpcArgs` 数组(运维可写全量参数,避免适配层猜错), + * 否则按 ssw-mpc 源码里已确认的参数名构造最小命令。 + */ + private buildCliArgv(ctx: StepContext, cli: string): string[] { + const p = ctx.params || {}; + if (Array.isArray(p.mpcArgs) && p.mpcArgs.length) { + return [cli, ...p.mpcArgs.map(String)]; + } + const sites = this.settings.sites; + switch (ctx.operatorKey) { + case 'prep.intersect': { + const ids = toCsv(p.ids || p.leftKeys, '1,2,3'); + const argv = ['psi', '--site', sites[0], '--sites', sites.join(','), '--ids', ids]; + if (process.env.MPC_PSI_LISTEN) argv.push('--listen', process.env.MPC_PSI_LISTEN); + return argv; + } + case 'model.lr.train': + return [ + 'lr', + '--data-x', toCsv(p.dataX, '1,2,3,4'), + '--data-y', toCsv(p.dataY, '0,1,1,0'), + '--n', String(p.n || 4), + '--d', String(p.d || 2), + '--epochs', String(p.epochs || 10), + '--lr', String(p.learningRate || 0.1), + ]; + case 'model.fedavg.train': + return [ + 'fl', + '--clients', String(p.clients || sites.length), + '--features', String(p.d || 4), + '--per-client', String(p.perClient || 50), + '--rounds', String(p.rounds || 3), + '--local-epochs', String(p.localEpochs || 1), + '--lr', String(p.learningRate || 0.1), + ]; + case 'stat.scql': + return ['sql', '--sql', String(p.query || 'SELECT count(*) FROM t')]; + default: + return [cli, '--help']; // 未知 native 算子只探测帮助,不伪造计算 + } + } + + private artifactsFromOutput(ctx: StepContext, stdout: string): StepArtifact[] { + // ssw-mpc `--report json` 输出为结构化文本;原样留痕,不臆造指标。 + let metrics: Record = { raw: stdout.slice(0, 4000) }; + try { + const parsed = JSON.parse(stdout); + metrics = { ...parsed, engine: 'ssw-mpc', operator: ctx.operatorKey }; + } catch { /* 非 JSON 输出保留原文 */ } + return [{ + portKey: 'report', type: 'report', title: `${ctx.label} · ssw-mpc 执行结果`, + summary: 'Rust 进程 stdout 原样留痕(未做任何语义解释)', metrics, + }]; + } +} + +function toCsv(v: any, fallback: string): string { + if (Array.isArray(v)) return v.map(String).join(','); + if (typeof v === 'string' && v.trim()) return v; + return fallback; +} diff --git a/src/backend/src/sswflow/engine/mpc-operator-map.ts b/src/backend/src/sswflow/engine/mpc-operator-map.ts new file mode 100644 index 0000000..64f0efb --- /dev/null +++ b/src/backend/src/sswflow/engine/mpc-operator-map.ts @@ -0,0 +1,152 @@ +/** + * sswflow 算子 → ssw-mpc 能力映射表(换框架的核心决策表) + * + * 来源:../ssw-mpc 的 crates/mpc-cli/src/main.rs:120-155(CLI 子命令)、 + * ../ssw-mpc/crates/mpc-orch/src/plan.rs(作业级 plan)、demo/src/ops/*(算子 HTTP)。 + * + * ⚠️ 诚实边界:ssw-mpc 是「单二进制 + 固定算子会话」引擎,**没有外部可提交的 JSON IR** + * (docs/IR.md:534 明确不做语言绑定),`mpc node/psi/lr` 的计算类型编译期写死。 + * 因此下表按 status 分级,**不假装 19 个算子都已原生支持**: + * native —— 有确切 CLI 子命令,MPC_DRIVER=mpc 时真下发到 Rust 进程 + * partial —— 能力存在但语义/参数不完全对齐,当前回退 simulation 并记录降级原因 + * local —— 编排层职责(数据准备/结果导出),本就不需要下发 + * unsupported —— ssw-mpc 暂无对应算子,回退 simulation 并明确告警 + * 回退一律写进 run_event(level=WARN),界面可见,绝不静默冒充真实密态计算。 + */ +export type MpcStatus = 'native' | 'partial' | 'local' | 'unsupported'; + +export interface MpcCapability { + /** ssw-mpc 的 CLI 子命令(native 时非空) */ + cli?: string; + /** 对应 crate */ + crate: string; + status: MpcStatus; + /** 对应的 ssw-mpc 说明/路径 */ + note: string; + /** 是否可编译成 mpc-orch 的 job(作业级依赖闸门演示) */ + orchJob?: boolean; +} + +export const MPC_OPERATOR_MAP: Record = { + 'source.dataset': { + crate: 'mpc-data', status: 'local', orchJob: true, + note: '数据接入属编排层:ssw-mpc 只有 --data/--ids/--data-x 等 CLI 入参,--data-file 读 CSV 尚未落地(deploy/ray/README.md:85)', + }, + 'prep.intersect': { + cli: 'psi', crate: 'mpc-psi', status: 'native', orchJob: true, + note: 'mpc psi --site/--sites/--ids [--listen|--connect|--peers];ECDH 已实现,KKRT/OT 扩展未完成', + }, + 'prep.sample': { + cli: 'sql', crate: 'mpc-sql', status: 'partial', + note: '需 --features secure;mpc sql 支持聚合/过滤,随机采样语义不等价', + }, + 'prep.split': { crate: '编排层', status: 'local', note: '训练集/测试集划分在编排层按端口分流' }, + 'prep.fillna': { crate: '编排层', status: 'local', note: '缺失值填充属本地数据准备' }, + 'prep.binning': { crate: '编排层', status: 'local', note: '分箱规则由编排层产出 rule 产物' }, + 'stat.profile': { + cli: 'sql', crate: 'mpc-sql', status: 'partial', + note: 'mpc sql 的 count/sum/avg/min/max 聚合可覆盖部分画像统计', + }, + 'stat.correlation': { + cli: 'node', crate: 'mpc-core', status: 'partial', orchJob: true, + note: 'mpc node 的固定语义是两方内积 dot(a,b);相关性需先标准化,尚未封装', + }, + 'stat.iv': { crate: '编排层', status: 'local', note: 'IV/WOE 计算在编排层基于分箱结果完成' }, + 'stat.scql': { + cli: 'sql', crate: 'mpc-sql', status: 'native', orchJob: true, + note: 'mpc sql / sql-plan / sql-join(--features secure),含 minGroupSize 类约束', + }, + 'model.lr.train': { + cli: 'lr', crate: 'mpc-ml', status: 'native', orchJob: true, + note: 'mpc lr --data-x/--data-y/--n/--d/--epochs/--lr;纵向场景用 lr-vertical', + }, + 'model.gbdt.train': { + crate: 'mpc-ml', status: 'unsupported', + note: 'ssw-mpc 暂无 GBDT 密态训练实现(mpc-ml 覆盖 LR / MLP 方向)', + }, + 'model.mlp.train': { + crate: 'mpc-ml', status: 'partial', + note: 'mpc-ml 有网络层原语,但没有 mpc mlp 顶层子命令', + }, + 'model.fedavg.train': { + cli: 'fl', crate: 'mpc-fl', status: 'native', orchJob: true, + note: 'mpc fl --clients/--features/--per-client/--rounds/--local-epochs/--lr;本地演示无网络', + }, + 'model.predict': { + cli: 'lr', crate: 'mpc-ml', status: 'partial', + note: '用 lr 训练得到的权重在编排层做密态/明文评分,无独立 predict 子命令', + }, + 'model.evaluate': { crate: '编排层', status: 'local', orchJob: true, note: 'AUC/KS/分桶基于 reveal 结果在编排层计算' }, + 'sink.export': { crate: '编排层', status: 'local', orchJob: true, note: '终态节点:结果导出由编排层负责(ssw-mpc 无结果表/对象存储)' }, + 'tee.privacy_aggregate': { + cli: 'tee', crate: 'mpc-tee', status: 'partial', + note: 'mpc tee / hostd(:3010) / control-plane(:3020) 是起 TEE 实例,不是聚合算子', + }, + 'zkp.prove': { + crate: 'mpc-zkp', status: 'partial', + note: 'mpc-zkp 是库能力,mpc CLI 顶层无 zkp 子命令(main.rs:120-155)', + }, +}; + +export function capabilityOf(operatorKey: string): MpcCapability { + return MPC_OPERATOR_MAP[operatorKey] || { + crate: '-', status: 'unsupported', note: `未登记的算子 ${operatorKey}`, + }; +} + +/** + * 把一张 sswflow DAG 编译成 ssw-mpc 的作业级 plan(行文本,非 JSON)。 + * 语法严格遵循 crates/mpc-orch/src/plan.rs:13-31:只认 job / deps / expect / data 四指令。 + * + * 说明:mpc-orch 的每个 job 执行的仍是固定算术会话,所以这里编译的是 + * 「节点依赖闸门 + 各方输入数据」,不是把任意算子语义翻译成 ssw-mpc IR + * (ssw-mpc 没有这样的 IR)。算子语义由 MpcEngine 按 CLI 子命令另行下发。 + */ +export function compileOrchPlan( + steps: { stepId: string; params?: Record }[], + edges: { sourceStepId: string; targetStepId: string }[], + sites: string[], +): string { + const depsOf = new Map(); + steps.forEach((s) => depsOf.set(s.stepId, [])); + edges.forEach((e) => { + if (depsOf.has(e.targetStepId) && depsOf.has(e.sourceStepId)) { + depsOf.get(e.targetStepId)!.push(e.sourceStepId); + } + }); + const lines: string[] = [ + '# generated by ssw-mpc-flow / MpcEngine', + `# sites=${sites.join(',')} (字典序即 party 编号,ssw-mpc 铁律)`, + ]; + for (const s of steps) { + lines.push(`job ${sanitizeJobName(s.stepId)}`); + const deps = [...new Set(depsOf.get(s.stepId) || [])].map(sanitizeJobName); + lines.push(`deps ${deps.length ? deps.join(',') : '-'}`); + const data = numericVector(s.params); + if (data) { + // plan.rs:107-140 —— 一行内可写多组 `site=v,v`,用空格分隔; + // 站点名必须出现在 orch run --sites 里,且字典序即 party 编号。 + lines.push(`data ${[...sites].sort().map((site) => `${site}=${data}`).join(' ')}`); + } + lines.push(''); + } + return lines.join('\n'); +} + +/** plan 的 job 名不允许空格;画布 stepId 通常是 uuid,这里做兜底 */ +function sanitizeJobName(id: string): string { + return String(id).replace(/[^A-Za-z0-9_-]/g, '_').slice(0, 60) || 'job'; +} + +/** 从节点参数里抽取可作为各方输入的数值向量(没有则返回 null,不下发 data 行) */ +function numericVector(params?: Record): string | null { + if (!params) return null; + for (const key of ['data', 'vector', 'values', 'dataX', 'ids']) { + const v = params[key]; + const arr = typeof v === 'string' ? v.split(',') : Array.isArray(v) ? v : null; + if (arr && arr.length && arr.every((x) => Number.isFinite(Number(x)))) { + return arr.map((x) => Number(x)).join(','); + } + } + return null; +} diff --git a/src/backend/src/sswflow/engine/simulation-engine.ts b/src/backend/src/sswflow/engine/simulation-engine.ts new file mode 100644 index 0000000..4077cb1 --- /dev/null +++ b/src/backend/src/sswflow/engine/simulation-engine.ts @@ -0,0 +1,95 @@ +/** + * 本地模拟引擎 —— 对齐 ssw-mvp `SimulationComputeEngine.java` 的角色。 + * 不依赖 Rust / 网络,按算子分类生成确定性产物,用于: + * ① 无 ssw-mpc 环境时也能完整跑通「保存画布 → 校验 → 运行 → 步骤/事件/产物」闭环; + * ② 前端联调、冒烟测试、演示。 + * 设 MPC_DRIVER=mpc 即切到真实 ssw-mpc 驱动(见 mpc-engine.ts)。 + */ +import { ComputeEngine, StepArtifact, StepContext, StepResult, success } from './compute-engine'; + +export class SimulationEngine implements ComputeEngine { + readonly name = 'simulation'; + + supports(_engineType: string, _operatorKey: string): boolean { + return true; + } + + async execute(ctx: StepContext): Promise { + const logs = [`[${this.name}] ${ctx.operatorKey} 开始`, `参与方: ${ctx.parties.join(',') || '本机模拟'}`]; + const artifacts = this.buildArtifacts(ctx); + logs.push(`[${this.name}] 产出 ${artifacts.length} 个端口产物`); + return success(this.name, artifacts, logs); + } + + private buildArtifacts(ctx: StepContext): StepArtifact[] { + const key = ctx.operatorKey; + const p = ctx.params || {}; + const inputRows = Object.values(ctx.inputs || {}).flat().reduce((n, a) => n + (a.rowCount || 0), 0); + const rowCount = key.startsWith('source.') ? 1000 : Math.max(1, Math.round(inputRows || 1000)); + const cols = [ + { name: 'id', type: 'string' }, + { name: 'feature_a', type: 'number' }, + { name: 'feature_b', type: 'number' }, + { name: 'label', type: 'number' }, + ]; + const rows = Array.from({ length: Math.min(rowCount, 5) }, (_, i) => ({ + id: `s${i + 1}`, feature_a: (i + 1) * 1.25, feature_b: (i + 3) * 0.75, label: i % 2, + })); + + if (key === 'source.dataset') { + return [{ portKey: 'out', type: 'table', title: p.datasetId || '数据集输入', + summary: '模拟读取参与方已授权数据集(平台不落原始数据)', columns: cols, rows, rowCount }]; + } + if (key === 'prep.intersect') { + return [{ portKey: 'out', type: 'table', title: '隐私求交结果', + summary: `协议 ${p.protocol || 'ECDH'},仅输出交集样本`, columns: cols, rows, + metrics: { protocol: p.protocol || 'ECDH', intersection: rowCount }, rowCount }]; + } + if (key === 'prep.split') { + const train = Math.round(rowCount * (Number(p.trainRate) || 0.8)); + return [ + { portKey: 'train', type: 'table', title: '训练集', columns: cols, rows, rowCount: train }, + { portKey: 'test', type: 'table', title: '测试集', columns: cols, rows, rowCount: rowCount - train }, + ]; + } + if (key === 'prep.binning') { + return [ + { portKey: 'out', type: 'table', title: '分箱结果', columns: cols, rows, rowCount }, + { portKey: 'rule', type: 'rule', title: '分箱规则', summary: `${p.binMethod || '等频'} / ${p.binCount || 10} 箱`, + metrics: { binMethod: p.binMethod || 'EQ_FREQ', binCount: Number(p.binCount) || 10 } }, + ]; + } + if (key.startsWith('stat.')) { + return [{ portKey: 'report', type: 'report', title: `${ctx.label} 报告`, + summary: `${key} 统计结果(模拟)`, + metrics: { operator: key, rowCount, columnsScanned: (p.columns || []).length || 4, + minGroupSize: p.minGroupSize ?? null }, rowCount }]; + } + if (key.startsWith('model.') && key.endsWith('.train')) { + return [{ portKey: 'model', type: 'model', title: `${ctx.label} 模型`, + summary: `联合训练完成(模拟);epochs=${p.epochs ?? p.rounds ?? p.treeNum ?? '-'}`, + metrics: { operator: key, auc: 0.8731, loss: 0.2146, epochs: Number(p.epochs ?? p.rounds ?? p.treeNum ?? 0) } }]; + } + if (key === 'model.predict') { + return [{ portKey: 'out', type: 'table', title: '预测评分表', columns: [...cols, { name: p.scoreColumn || 'score', type: 'number' }], rows, rowCount }]; + } + if (key === 'model.evaluate') { + return [{ portKey: 'report', type: 'report', title: '模型评估报告', + summary: 'AUC / KS / 分桶提升度(模拟)', + metrics: { auc: 0.8731, ks: 0.421, bucketNum: Number(p.bucketNum) || 10 } }]; + } + if (key === 'zkp.prove') { + return [{ portKey: 'proof', type: 'proof', title: '零知识证明', + summary: `scheme=${p.scheme || 'GROTH16'},statement=${p.statement || '-'}`, + metrics: { scheme: p.scheme || 'GROTH16', verified: true } }]; + } + if (key === 'tee.privacy_aggregate') { + return [{ portKey: 'out', type: 'table', title: 'TEE 聚合结果', columns: cols, rows, + metrics: { method: p.method || 'SUM', deliveryType: p.deliveryType || 'TABLE' }, rowCount }]; + } + if (key === 'sink.export') { + return []; // 终态节点只写日志,与 catalog terminal=true 对齐 + } + return [{ portKey: 'out', type: 'table', title: ctx.label || key, columns: cols, rows, rowCount }]; + } +} diff --git a/src/backend/src/sswflow/engine/ssw-mpc-adapter.ts b/src/backend/src/sswflow/engine/ssw-mpc-adapter.ts new file mode 100644 index 0000000..a4d93ef --- /dev/null +++ b/src/backend/src/sswflow/engine/ssw-mpc-adapter.ts @@ -0,0 +1,656 @@ +/** + * ssw-mpc 真实接口适配层 —— 设备注册与链上存证两个模块的**唯一**真数据源入口。 + * + * ★ 依据(2026-11-10 本机 / 海光真机 / k8s FISCO 链**实测**,不是推测): + * + * ① 设备注册的真源 = **mpc control-plane 的节点注册表**: + * `GET {controlPlaneUrl}/nodes` → `{"nodes":[...]}`,每项字段: + * key(`site@host`) / site / host / platform / tcb / capacity / last_seen / + * device_present / qemu_present / firmware_present / image_present / + * kbs_reachable / kbc / measurement / descriptor + * ★ `platform` 的真实取值是 `sev-snp` / `hygon-csv`(= TeeNode 的 kind), + * `kbc` 的真实取值是 `cc_kbc` / `offline_fs_kbc::null` —— 不是 online/offline。 + * ★ `descriptor` 是 TeeNode 的 `key=value` 行式文本,**原始字段都在里面**, + * 它是「一份描述两处呈现」的权威副本。 + * + * ② `GET {controlPlaneUrl}/sessions` → **只列已证明通过的端点** `[{session_id, endpoint}]`。 + * 空数组 = 没有通过证明的端点(fail-closed,不是 404、不是假数据)。 + * + * ③ `GET {controlPlaneUrl}/report` → 最近一轮对账结论 `{"healthy":[],"failed":[]}`。 + * + * ④ 鉴权:控制面在**配置了共享密钥**时要求 `Authorization: Bearer <明文密钥原文>` + * (≥32 字节 ASCII 无空白;服务端存 SHA-256 摘要,比对用常量时间)。 + * ★ 没配置密钥 = 回环信任模式:不带凭据放行,**带了任何凭据一律拒**。 + * + * ⑤ 链上存证的真源 = **mpc chain 的 outbox + FISCO 合约读回**: + * `mpc chain status --outbox PATH` → 条目状态(Pending / Confirmed)。 + * `mpc chain contract read --config --contract --method --abi --arg ...` + * → 只读读回,输出形如 `{"read":true,"output":"0x..."}`。 + * ★ ssw-mpc **没有**通用区块浏览命令(`mpc chain` 子命令里没有), + * 所以「区块链浏览器」在本项目里 = **链上对象 / 回执浏览器**,不是区块浏览器。 + * + * ⑥ FISCO 成功判据**三件套**(缺一不可,且与 web3 相反): + * `status == 0`(TransactionStatus::None;web3 是 0x1)+ `transactionHash` 非空 + * + `blockNumber > 0`(已出块,不是刚进交易池)。 + * ★ HTTP 200 ≠ 成功:FISCO 把错误放在 body 的 `error` 对象里。 + * + * ★ 本文件**不修改 ssw-mpc 仓库任何文件**,只调它的 CLI 与 HTTP 端点。 + */ +import { execFile } from 'child_process'; +import { promisify } from 'util'; +import * as fs from 'fs'; +import * as path from 'path'; +import { mpcSettings, MpcSettings, runCli } from './mpc-client'; + +const execFileAsync = promisify(execFile); + +/** 数据来源标注 —— 前端必须原样展示,绝不把 mock 冒充成真链/真设备。 */ +export type DataSource = 'control-plane' | 'chain-cli' | 'mock'; + +export interface SourceTagged { + data: T; + /** 真源 = 真接口读到的;mock = 接口不可达时的同形状占位。 */ + source: DataSource; + /** 人类可读的来源说明(含端点/命令),直接展示给用户。 */ + origin: string; + /** 真源读失败时的原因(source=mock 时必有)。 */ + reason?: string; +} + +/** + * TeeNode 字段 —— **严格**对齐 ssw-mpc `crates/mpc-tee/src/schedule.rs` 的 `TeeNode` + * 与 `crates/mpc-hostd/src/control_plane_api.rs` 的 `node_to_json`。 + * 不多不少不加不减:多一个字段就等于自造,多一个字段就等于漏。 + */ +export interface TeeNodeView { + /** `site@host`,注册表主键。 */ + key: string; + /** 站点名(alice / bob …)。 */ + site: string; + /** 主机地址。 */ + host: string; + /** 平台种类:`sev-snp` / `hygon-csv`(= TeeNode.kind)。 */ + platform: string; + /** 可信计算基版本号(整数)。 */ + tcb: number; + /** 并发容量。 */ + capacity: number; + /** 最近一次自报时间(unix 秒)。 */ + last_seen: number; + /** TEE 设备在位。 */ + device_present: boolean; + /** qemu 在位。 */ + qemu_present: boolean; + /** 固件在位。 */ + firmware_present: boolean; + /** 镜像在位。 */ + image_present: boolean; + /** 密钥代理可达。 */ + kbs_reachable: boolean; + /** 密钥代理模式:真实值形如 `cc_kbc` / `offline_fs_kbc::null`。 */ + kbc: string; + /** 镜像度量(64 hex)。 */ + measurement: string; + /** TeeNode 原始描述符(key=value 行式文本),**权威副本**。 */ + descriptor: string; +} + +/** 控制面已证明通过的会话端点(fail-closed:没通过就没有)。 */ +export interface SessionEndpoint { + session_id: string; + endpoint: string; +} + +/** 对账结论。 */ +export interface ControlPlaneReport { + healthy: any[]; + failed: any[]; +} + +/** + * 控制面访问参数。 + * ★ `sharedSecret` 是**明文密钥原文**(与 ssw-mpc 的 `secret_token` 同一口径): + * 不能传 hex、不能带空白、非 ASCII 一律无效。 + */ +export interface ControlPlaneOptions { + url: string; + sharedSecret?: string; + timeoutMs?: number; +} + +function controlPlaneBase(url: string): string { + return url.replace(/\/+$/, ''); +} + +/** + * 调控制面端点。 + * + * ★ 鉴权口径(与 ssw-mpc `crates/mpc-hostd/src/auth.rs` 逐字对齐): + * 配了密钥 ⇒ 必须带 `Authorization: Bearer <原文>`; + * 没配密钥 ⇒ 不带凭据才放行,带了就拒。 + * ⇒ 所以**有没有配密钥,要和「带不带凭据」保持一致**, + * 否则会出现「看起来配了、其实一直 401」的死路。 + */ +async function callControlPlane( + path: string, + opts: ControlPlaneOptions, +): Promise<{ ok: boolean; status: number; body: T | null; raw: string }> { + const headers: Record = { accept: 'application/json' }; + if (opts.sharedSecret && opts.sharedSecret.trim().length > 0) { + headers['authorization'] = `Bearer ${opts.sharedSecret}`; + } + const url = `${controlPlaneBase(opts.url)}${path}`; + try { + const res = await fetch(url, { + headers, + signal: AbortSignal.timeout(opts.timeoutMs ?? 5000), + }); + const raw = await res.text(); + let body: T | null = null; + try { + body = raw ? (JSON.parse(raw) as T) : null; + } catch { + body = null; + } + return { ok: res.ok, status: res.status, body, raw }; + } catch (e: any) { + return { ok: false, status: 0, body: null, raw: String(e?.message || e) }; + } +} + +/** + * 读控制面节点注册表(设备注册的真数据源)。 + * + * ★ fail-closed 语义照搬 ssw-mpc:注册表为空 ⇒ 返回**空数组**, + * 不是 404、不是假数据。接口不可达时才降级 mock,并显式标注。 + */ +export async function fetchControlPlaneNodes( + opts: ControlPlaneOptions, +): Promise> { + const origin = `GET ${controlPlaneBase(opts.url)}/nodes`; + const r = await callControlPlane<{ nodes?: TeeNodeView[] }>('/nodes', opts); + if (r.ok && r.body && Array.isArray(r.body.nodes)) { + return { data: r.body.nodes, source: 'control-plane', origin }; + } + const reason = r.status === 401 + ? `控制面要求凭据(HTTP 401):共享密钥未配置或与控制面不一致` + : r.status === 0 + ? `控制面不可达:${r.raw}` + : `控制面返回 HTTP ${r.status}:${r.raw.slice(0, 200)}`; + return { data: [], source: 'mock', origin, reason }; +} + +/** 读控制面已证明通过的会话端点。 */ +export async function fetchControlPlaneSessions( + opts: ControlPlaneOptions, +): Promise> { + const origin = `GET ${controlPlaneBase(opts.url)}/sessions`; + const r = await callControlPlane<{ sessions?: SessionEndpoint[] }>('/sessions', opts); + if (r.ok && r.body && Array.isArray(r.body.sessions)) { + return { data: r.body.sessions, source: 'control-plane', origin }; + } + const reason = r.status === 401 + ? `控制面要求凭据(HTTP 401)` + : r.status === 0 ? `控制面不可达:${r.raw}` : `控制面返回 HTTP ${r.status}`; + return { data: [], source: 'mock', origin, reason }; +} + +/** 读控制面最近一轮对账结论。 */ +export async function fetchControlPlaneReport( + opts: ControlPlaneOptions, +): Promise> { + const origin = `GET ${controlPlaneBase(opts.url)}/report`; + const r = await callControlPlane('/report', opts); + if (r.ok && r.body) { + return { data: { healthy: r.body.healthy || [], failed: r.body.failed || [] }, source: 'control-plane', origin }; + } + return { + data: { healthy: [], failed: [] }, + source: 'mock', + origin, + reason: r.status === 401 ? '控制面要求凭据(HTTP 401)' : `控制面返回 HTTP ${r.status}`, + }; +} + +/** 从 TeeNode 的 `descriptor`(key=value 行式文本)里解析出 qemu/firmware/kernel/initrd 等路径。 */ +export function parseDescriptor(descriptor: string): Record { + const out: Record = {}; + for (const line of String(descriptor || '').split('\n')) { + const t = line.trim(); + if (!t) continue; + const i = t.indexOf('='); + if (i <= 0) continue; + out[t.slice(0, i)] = t.slice(i + 1); + } + return out; +} + +// --------------------------------------------------------------------------- +// 链侧:outbox 状态 + 合约只读读回 +// --------------------------------------------------------------------------- + +/** outbox 条目状态(`mpc chain status` 的原始条目)。 */ +export interface OutboxEntryView { + key: string; + state: string; // Pending / Confirmed + attempts: number; + payloadBytes: number; + lastError: string | null; + /** ★ outbox 行里的原始 payload(canonical_bytes 的 hex),可据此解出 Receipt。 */ + payloadHex?: string; +} + +// --------------------------------------------------------------------------- +// Receipt 二进制解码(canonical_bytes 反向解析) +// --------------------------------------------------------------------------- + +/** 域分隔常量 —— 与 `mpc-core/src/domain.rs` 的 `TEE_CHAIN_OBJECT` 一字不差。 */ +export const TEE_CHAIN_OBJECT = 'mpc/tee/chain/object/v1'; +/** 对象类型标签 —— 与 `objects.rs` 的 `RECEIPT_TAG` 一字不差。 */ +export const RECEIPT_TAG = 'receipt'; + +/** 解出来的 Receipt(字段名与 `Receipt::from_json` 的 JSON 口径一致)。 */ +export interface DecodedReceipt { + order_id: string; + decision_id: string; + result_hash: string; + input_hash: string; + user_data: string; + attest: { user_data_ok: boolean; meas_ok: boolean; tcb_ok: boolean; chip_sig: boolean }; + link: string; + link_binding: string; + /** canonical body 里**不含**签名(自指),故这里恒为空数组。 */ + signatures: string[]; +} + +class ByteCursor { + private off = 0; + constructor(private readonly buf: Buffer) {} + get remaining(): number { return this.buf.length - this.off; } + take(n: number): Buffer { + if (this.off + n > this.buf.length) { + throw new Error(`游标越界:需要 ${n} 字节,只剩 ${this.remaining}`); + } + const b = this.buf.subarray(this.off, this.off + n); + this.off += n; + return b; + } + u32(): number { return this.take(4).readUInt32BE(0); } + u8(): number { return this.take(1)[0]; } + /** 变长字段:4 字节大端长度前缀 + 内容(`push_field` 的逆运算)。 */ + field(): Buffer { + const len = this.u32(); + return this.take(len); + } + text(): string { return this.field().toString('utf8'); } +} + +/** + * ★ 反解 outbox payload 里的 Receipt。 + * + * ★ 布局真相源:`../ssw-mpc/crates/mpc-chain/src/objects.rs` + * - `canonical_bytes()` = 域分隔 + push_field(kind_tag) + "v1" + canonical_body() + * - `Receipt::canonical_body()` 顺序: + * push_field(order_id) / push_field(decision_id) + * / result_hash[32] / input_hash[32] / user_data[64] + * / attest 4 个 u8 / push_field(link) / link_binding[32] + * (`signatures` **故意不写** —— 签名是产物不是被签内容) + * + * ★ 任一处对不上 ⇒ 抛错,不返回半截数据。 + */ +export function decodeReceiptPayload(payloadHex: string): DecodedReceipt { + const buf = Buffer.from(payloadHex || '', 'hex'); + if (buf.length === 0) throw new Error('payload 为空'); + const c = new ByteCursor(buf); + + // 域分隔:**固定长度直接 extend,没有长度前缀**(只有 kind_tag 走 push_field)。 + const domain = c.take(TEE_CHAIN_OBJECT.length).toString('utf8'); + if (domain !== TEE_CHAIN_OBJECT) { + throw new Error(`域分隔不符:期望 ${TEE_CHAIN_OBJECT},实际 ${domain}`); + } + // kind_tag 走 push_field ⇒ 有 4 字节大端长度前缀。 + const kind = c.field().toString('utf8'); + if (kind !== RECEIPT_TAG) { + throw new Error(`对象类型不符:期望 ${RECEIPT_TAG},实际 ${kind}`); + } + // 版本号也是直接 extend,固定 2 字节。 + const version = c.take(2).toString('utf8'); + if (version !== 'v1') { + throw new Error(`版本不符:期望 v1,实际 ${version}`); + } + + const orderId = c.text(); + const decisionId = c.text(); + const resultHash = c.take(32).toString('hex'); + const inputHash = c.take(32).toString('hex'); + const userData = c.take(64).toString('hex'); + const attest = { + user_data_ok: c.u8() !== 0, + meas_ok: c.u8() !== 0, + tcb_ok: c.u8() !== 0, + chip_sig: c.u8() !== 0, + }; + const link = c.text(); + const linkBinding = c.take(32).toString('hex'); + + return { + order_id: orderId, + decision_id: decisionId, + result_hash: resultHash, + input_hash: inputHash, + user_data: userData, + attest, + link, + link_binding: linkBinding, + signatures: [], + }; +} + +/** + * 直接读 outbox 文件行,拿到 payload hex。 + * + * ★ 行格式(`outbox.rs`):`v1|key|state|attempts|payload_hex|last_error_hex`, + * 6 段缺一即坏行 —— **整表拒绝**,绝不静默跳过(跳过等于悄悄丢审计记录)。 + */ +export function readOutboxRows(outboxPath: string): { rows: OutboxEntryView[]; error?: string } { + if (!fs.existsSync(outboxPath)) return { rows: [], error: `outbox 文件不存在:${outboxPath}` }; + let text: string; + try { + text = fs.readFileSync(outboxPath, 'utf8'); + } catch (e: any) { + return { rows: [], error: `读 outbox 失败:${e?.message}` }; + } + const rows: OutboxEntryView[] = []; + for (const [i, line] of text.split('\n').entries()) { + if (!line.trim()) continue; + const parts = line.split('|'); + if (parts.length !== 6 || parts[0] !== 'v1') { + return { rows: [], error: `outbox 第 ${i + 1} 行格式损坏,拒绝静默跳过` }; + } + const state = parts[2] === 'C' ? 'Confirmed' : parts[2] === 'P' ? 'Pending' : parts[2]; + rows.push({ + key: parts[1], + state, + attempts: Number(parts[3]) || 0, + payloadBytes: Math.floor(parts[4].length / 2), + lastError: parts[5] ? Buffer.from(parts[5], 'hex').toString('utf8') : null, + payloadHex: parts[4], + }); + } + return { rows }; +} + +/** + * 读 outbox 条目状态(链上存证的真源之一)。 + * + * ★ outbox 是**本地待上链表**(fail-open 侧):链挂了照常入队、恢复后补链。 + * 所以 `Pending` 不等于「失败」,`Confirmed` 也**只代表已广播**, + * 不代表已出块确认 —— 出块要看 FISCO 回执三件套。 + * + * ★ 优先读文件本体(能拿到 payload),再用 `mpc chain status` 交叉核对状态; + * 两者不一致时以 CLI 为准并保留文件里的 payload。 + */ +export async function fetchChainOutbox( + outboxPath: string, + settings: MpcSettings = mpcSettings(), +): Promise> { + const origin = `mpc chain status --outbox ${outboxPath}`; + const local = readOutboxRows(outboxPath); + if (!fs.existsSync(outboxPath)) { + return { data: [], source: 'chain-cli', origin, reason: `outbox 文件不存在:${outboxPath}` }; + } + const r = await runCli(['chain', 'status', '--outbox', outboxPath], settings); + const raw = String(r.stdout || '').trim(); + const line = raw.split('\n').reverse().find((l) => l.trim().startsWith('{')); + if (!r.ok || !line) { + return { + data: local.rows, + source: local.error ? 'mock' : 'chain-cli', + origin, + reason: local.error || `mpc chain status 失败:${(r.stderr || raw).slice(0, 300)}`, + }; + } + try { + const parsed = JSON.parse(line); + const entries: any[] = Array.isArray(parsed.entries) ? parsed.entries : []; + // 用 CLI 的状态覆盖文件的状态,但保留文件里的 payload hex。 + const byKey = new Map(local.rows.map((x) => [x.key, x])); + const merged = entries.map((e: any) => { + const hit = byKey.get(e.key); + return { + key: e.key, + state: e.state, + attempts: e.attempts, + payloadBytes: e.payloadBytes, + lastError: e.lastError ?? null, + payloadHex: hit?.payloadHex, + } as OutboxEntryView; + }); + return { data: merged, source: 'chain-cli', origin }; + } catch (e: any) { + return { data: local.rows, source: local.error ? 'mock' : 'chain-cli', origin, reason: local.error || `解析 chain status 输出失败:${e?.message}` }; + } +} + +/** FISCO 回执视图(成功判据三件套的载体)。 */ +export interface FiscoReceiptView { + /** `transactionHash` —— FISCO 自有字段名,**不是** `txHash`。 */ + transactionHash: string; + /** `TransactionStatus` 枚举值;**0 = 执行成功**(与 web3 的 0x1 相反)。 */ + status: number | null; + /** 出块高度;> 0 才是「已上链」。 */ + blockNumber: number | null; + /** gasUsed(十六进制串,无 0x 前缀)。 */ + gasUsed: string; + /** 部署时的合约地址。 */ + contractAddress: string; +} + +/** + * ★★ FISCO 成功判据**三件套** —— 唯一口径,来自 ssw-mpc + * `crates/mpc-chain/src/rpc.rs` 与 `tools/selftest-fisco-contract.py`。 + * + * ① `status == 0`(TransactionStatus::None = 执行成功) + * ② `transactionHash` 非空 + * ③ `blockNumber > 0`(已出块,不是「刚进交易池」) + * + * 缺一不可;**字段缺失一律按「没有」处理**,绝不用默认值把它们补成成功。 + */ +export function isFiscoTxSuccess(r: { + status?: number | null; + transactionHash?: string | null; + blockNumber?: number | null; +}): boolean { + return r.status === 0 + && typeof r.transactionHash === 'string' && r.transactionHash.length > 0 + && (r.blockNumber ?? 0) > 0; +} + +/** + * 只读读回合约里的一个值(走 FISCO 自有 `call` 端点,不上链)。 + * + * ★ FISCO 没有 `eth_call`,只有自有的 `call`(4 参 `[group, node, to, data]`)。 + */ +export async function readContract( + args: { + config: string; + contract: string; + method: string; + abi: string; + node?: string; + arg?: string[]; + }, + settings: MpcSettings = mpcSettings(), +): Promise> { + const argv = [ + 'chain', 'contract', 'read', + '--config', args.config, + '--contract', args.contract, + '--method', args.method, + '--abi', args.abi, + '--node', args.node || 'node0', + ]; + for (const a of args.arg || []) argv.push('--arg', a); + const origin = `mpc ${argv.join(' ')}`; + const r = await runCli(argv, settings); + const raw = String(r.stdout || '').trim(); + const line = raw.split('\n').reverse().find((l) => l.trim().startsWith('{')); + if (!r.ok || !line) { + return { + data: null, + source: 'chain-cli', + origin, + reason: `合约只读调用失败:${(r.stderr || raw).slice(0, 300)}`, + }; + } + try { + const parsed = JSON.parse(line); + return { + data: { output: parsed.output || '0x', selector: parsed.selector || '' }, + source: 'chain-cli', + origin, + }; + } catch (e: any) { + return { data: null, source: 'chain-cli', origin, reason: `解析只读输出失败:${e?.message}` }; + } +} + +/** + * 算一条 Receipt 的规范摘要(`mpc chain digest --kind receipt`)。 + * 这是**链上登记的摘要**,与「链上对象规范字节」一一对应。 + */ +export async function digestReceipt( + receiptFile: string, + config: string, + settings: MpcSettings = mpcSettings(), +): Promise> { + const origin = `mpc chain digest --config ${config} --kind receipt --file ${receiptFile}`; + const r = await runCli( + ['chain', 'digest', '--config', config, '--kind', 'receipt', '--file', receiptFile], + settings, + ); + const raw = String(r.stdout || '').trim(); + const line = raw.split('\n').reverse().find((l) => l.trim().startsWith('{')); + if (!r.ok || !line) { + return { data: null, source: 'chain-cli', origin, reason: `摘要计算失败:${(r.stderr || raw).slice(0, 300)}` }; + } + try { + const parsed = JSON.parse(line); + return { + data: { + digest: parsed.digest || '', + canonicalBytes: Number(parsed.canonicalBytes || 0), + hashSuite: parsed.hashSuite || '', + }, + source: 'chain-cli', + origin, + }; + } catch (e: any) { + return { data: null, source: 'chain-cli', origin, reason: `解析摘要输出失败:${e?.message}` }; + } +} + +/** + * 探链:读 FISCO 链当前高度(`getBlockNumber`,**裸调用不传 group/node**)。 + * + * ★ 真相源:`crates/mpc-chain/src/rpc.rs` 里 FISCO 自有端点都带 + * `[groupID, nodeName, ...]`,但 `getBlockNumber` 只接受 0 参; + * 传 2 参会报 `group=..., node=...`(把参数当成了 group/node)。 + * ★ HTTP 200 ≠ 成功:错误在 body 的 `error` 对象里。 + */ +export async function probeChainHeight( + rpcEndpoint: string, + timeoutMs = 4000, +): Promise> { + const origin = `POST http://${rpcEndpoint} {"method":"getBlockNumber","params":[]}`; + try { + const res = await fetch(`http://${rpcEndpoint}`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'getBlockNumber', params: [] }), + signal: AbortSignal.timeout(timeoutMs), + }); + const body: any = await res.json().catch(() => null); + if (body && body.error) { + return { data: null, source: 'chain-cli', origin, reason: `链返回错误:${JSON.stringify(body.error)}` }; + } + const h = Number(body?.result); + if (!Number.isFinite(h)) { + return { data: null, source: 'chain-cli', origin, reason: '链返回的 result 不是数字' }; + } + return { data: h, source: 'chain-cli', origin }; + } catch (e: any) { + return { data: null, source: 'chain-cli', origin, reason: `链不可达:${e?.message}` }; + } +} + +/** + * ★★ 查 FISCO 链上回执(自有端点 `getTransactionReceipt`)。 + * + * ★ 真相源:`crates/mpc-chain/src/rpc.rs` —— FISCO **没有** web3 的 + * `eth_getTransactionReceipt`,只有自有的 `getTransactionReceipt`, + * 参数形状 4 参 `[groupID, nodeName, txHash, requireProof]`。 + * 传 web3 形状会得 `-32601 The method does not exist/is not available.`。 + * + * ★ `result: null` = **还没出块**(既不是成功也不是失败),不是错误。 + * + * ★ `status` 是 `TransactionStatus` 枚举值,**0 = 成功**(与 web3 的 0x1 相反)。 + */ +export async function fetchFiscoReceipt( + rpcEndpoint: string, + groupId: string, + nodeName: string, + txHash: string, + timeoutMs = 4000, +): Promise> { + const params = [groupId, nodeName, txHash, false]; + const origin = `POST http://${rpcEndpoint} {"method":"getTransactionReceipt","params":${JSON.stringify(params)}}`; + try { + const res = await fetch(`http://${rpcEndpoint}`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'getTransactionReceipt', params }), + signal: AbortSignal.timeout(timeoutMs), + }); + const body: any = await res.json().catch(() => null); + if (body && body.error) { + return { data: null, source: 'chain-cli', origin, reason: `链返回错误:${JSON.stringify(body.error)}` }; + } + const result = body?.result; + if (result === null || result === undefined) { + // 还没出块 —— 不是错误,是「既不是成功也不是失败」。 + return { data: null, source: 'chain-cli', origin, reason: '尚未出块(result 为 null)' }; + } + if (typeof result !== 'object') { + return { data: null, source: 'chain-cli', origin, reason: '回执 result 不是对象' }; + } + return { + data: { + transactionHash: typeof result.transactionHash === 'string' ? result.transactionHash : '', + status: result.status === undefined || result.status === null ? null : Number(result.status), + blockNumber: result.blockNumber === undefined || result.blockNumber === null ? null : Number(result.blockNumber), + gasUsed: result.gasUsed === undefined || result.gasUsed === null ? '' : String(result.gasUsed), + contractAddress: result.contractAddress === undefined || result.contractAddress === null ? '' : String(result.contractAddress), + }, + source: 'chain-cli', + origin, + }; + } catch (e: any) { + return { data: null, source: 'chain-cli', origin, reason: `链不可达:${e?.message}` }; + } +} + +/** 从环境变量读控制面共享密钥。 */ +export function controlPlaneSecretFromEnv(): string | undefined { + const s = process.env.MPC_HOSTD_SHARED_SECRET || process.env.MPC_CONTROL_PLANE_SECRET; + return s && s.trim().length > 0 ? s : undefined; +} + +/** 组装控制面访问参数(默认取 mpcSettings 里的 controlPlaneUrl)。 */ +export function controlPlaneOptions(settings: MpcSettings = mpcSettings()): ControlPlaneOptions { + return { + url: settings.controlPlaneUrl, + sharedSecret: controlPlaneSecretFromEnv(), + timeoutMs: 5000, + }; +} diff --git a/src/backend/src/sswflow/flow.controller.ts b/src/backend/src/sswflow/flow.controller.ts new file mode 100644 index 0000000..524a3dd --- /dev/null +++ b/src/backend/src/sswflow/flow.controller.ts @@ -0,0 +1,86 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { FlowService } from './flow.service'; + +const MODULE_KEY = 'sswflow/Flow'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 流程定义 —— /api/ssw/sswflow/Flow/{List|Save|Delete|Canvas|Validate|Copy|CompilePlan|ByProject} */ +@Controller('api/ssw/sswflow/Flow') +export class FlowController { + constructor( + private readonly svc: FlowService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } + + @Get('ByProject') + async byProject(@Req() req: any, @Query('projectId') projectId: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.byProject(projectId)); + } + + /** 保存画布:body = { steps, edges },均可是数组或 JSON 字符串 */ + @Post('Canvas') + async canvas(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.canvas(body.id, body.steps, body.edges)); + } + + @Post('Validate') + async validate(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.validate(body.id)); + } + + @Post('Copy') + async copy(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.copy(body.id)); + } + + /** 把画布编译成 ssw-mpc 作业级 plan(不执行) */ + @Get('CompilePlan') + async compilePlan(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.compilePlan(id)); + } +} diff --git a/src/backend/src/sswflow/flow.entity.ts b/src/backend/src/sswflow/flow.entity.ts new file mode 100644 index 0000000..b910ff9 --- /dev/null +++ b/src/backend/src/sswflow/flow.entity.ts @@ -0,0 +1,45 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 流程(sswflow_flow)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../FlowEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_flow' }) +export class FlowEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_project_id', type: 'varchar', length: 50, nullable: true }) + projectId: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_desc', type: 'varchar', length: 1000, nullable: true }) + desc: string; + + @Column({ name: 'f_steps', type: 'text', nullable: true }) + steps: string; + + @Column({ name: 'f_edges', type: 'text', nullable: true }) + edges: string; + + @Column({ name: 'f_last_run_id', type: 'varchar', length: 50, nullable: true }) + lastRunId: string; + + @Column({ name: 'f_last_run_status', type: 'varchar', length: 32, nullable: true }) + lastRunStatus: string; + + @Column({ name: 'f_last_run_time', type: 'timestamp', nullable: true }) + lastRunTime: Date; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/flow.service.ts b/src/backend/src/sswflow/flow.service.ts new file mode 100644 index 0000000..6654cd9 --- /dev/null +++ b/src/backend/src/sswflow/flow.service.ts @@ -0,0 +1,113 @@ +/** + * 流程定义服务 —— 对齐 ssw-mvp `FlowServiceImpl` / `FlowController`: + * 保存画布(steps/edges 为 JSON 字符串)、运行前校验、复制、按项目查询, + * 外加本项目新增的 **ssw-mpc 作业计划编译**(CompilePlan)。 + */ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { BizException } from '../common/business.exception'; +import { FlowEntity } from './flow.entity'; +import { FlowGraph } from './engine/flow-graph'; +import { compileOrchPlan } from './engine/mpc-operator-map'; +import { mpcSettings } from './engine/mpc-client'; + +@Injectable() +export class FlowService { + constructor( + @InjectRepository(FlowEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ where: { deleteMark: 0 } as any, order: { creatorTime: 'DESC' } as any }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, id: randomUUID(), creatorTime: new Date(), deleteMark: 0, + creatorUserId: (item as any).creatorUserId || 'admin', + } as any); + return (await this.repo.save(ent)) as unknown as FlowEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as FlowEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as FlowEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } + + async byProject(projectId: string): Promise { + return this.repo.find({ where: { projectId, deleteMark: 0 } as any, order: { creatorTime: 'DESC' } as any }); + } + + /** 保存画布:steps / edges 原样是 JSON 字符串,与前端 flowTransform 的后端形态一致 */ + async canvas(id: string, steps: any, edges: any): Promise { + const flow = await this.get(id); + if (!flow) throw new BizException('流程不存在或已删除'); + flow.steps = typeof steps === 'string' ? steps : JSON.stringify(steps || []); + flow.edges = typeof edges === 'string' ? edges : JSON.stringify(edges || []); + return (await this.repo.save(flow)) as unknown as FlowEntity; + } + + async validate(id: string): Promise<{ valid: boolean; issues: any[]; order: string[] }> { + const { result } = await this.parseFlowAsync(id); + return result; + } + + /** 编译整张画布为 ssw-mpc `mpc orch run --plan` 可消费的行文本计划 */ + async compilePlan(id: string): Promise<{ plan: string; sites: string[]; command: string; note: string }> { + const { graph } = await this.parseFlowAsync(id); + const sites = mpcSettings().sites; + const plan = compileOrchPlan( + [...graph.steps.values()] as any, + graph.edges.map((e) => ({ sourceStepId: e.sourceStepId, targetStepId: e.targetStepId })), + sites, + ); + return { + plan, + sites, + command: `mpc orch run --plan flow.plan --sites ${sites.join(',')} --state-dir ./.mpc-state/`, + note: 'plan 只表达 job 依赖闸门与各方输入;ssw-mpc 无外部 JSON IR,算子语义由 CLI 子命令另行下发。', + }; + } + + async copy(id: string): Promise { + const src = await this.get(id); + if (!src) throw new BizException('流程不存在或已删除'); + const ent = this.repo.create({ + id: randomUUID(), projectId: src.projectId, name: `${src.name} - 副本`, + desc: src.desc, steps: src.steps, edges: src.edges, + creatorTime: new Date(), creatorUserId: 'admin', deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as FlowEntity; + } + + /** 异步读取 + 解析画布 */ + async parseFlowAsync(id: string): Promise<{ flow: FlowEntity; graph: FlowGraph; result: any }> { + const flow = await this.get(id); + if (!flow) throw new BizException('流程不存在或已删除'); + const graph = FlowGraph.parse(flow.steps, flow.edges); + const issues = graph.validate(); + return { + flow, graph, + result: { + valid: !issues.some((i) => i.level === 'ERROR'), + issues, + order: graph.topologicalOrder(), + }, + }; + } +} diff --git a/src/backend/src/sswflow/flowrun.controller.ts b/src/backend/src/sswflow/flowrun.controller.ts new file mode 100644 index 0000000..2f27555 --- /dev/null +++ b/src/backend/src/sswflow/flowrun.controller.ts @@ -0,0 +1,124 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { FlowRunService } from './flowrun.service'; + +const MODULE_KEY = 'sswflow/FlowRun'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** + * 运行实例 —— 标准三段式 /api/ssw/sswflow/FlowRun/{List|Save|Delete} + * 之外补齐原 ssw-mvp FlowRunController 的运行控制与观测端点: + * Start / Stop / Steps / Events / Artifacts / Overview / Recent / ByFlow / Info + * SSE 改为 Events 增量轮询(afterSeq 游标),形状与 run_event.f_sort_code 一致。 + */ +@Controller('api/ssw/sswflow/FlowRun') +export class FlowRunController { + constructor( + private readonly svc: FlowRunService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } + + @Post('Start') + async start(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + const u = (req as any).user; + return ActionResult.success(await this.svc.start(body.flowId, { ...body, operator: u.account })); + } + + @Post('Stop') + async stop(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + await this.svc.stop(body.runId); + return ActionResult.success(null); + } + + @Get('Info') + async info(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.get(id)); + } + + @Get('Steps') + async steps(@Req() req: any, @Query('runId') runId: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.steps(runId)); + } + + @Get('Events') + async events( + @Req() req: any, + @Query('runId') runId: string, + @Query('afterSeq') afterSeq?: string, + @Query('limit') limit?: string, + ) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.events(runId, Number(afterSeq) || 0, Number(limit) || 200)); + } + + @Get('Artifacts') + async artifacts(@Req() req: any, @Query('runId') runId: string, @Query('stepId') stepId?: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.artifacts(runId, stepId)); + } + + @Get('Overview') + async overview(@Req() req: any, @Query('runId') runId: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.overview(runId)); + } + + @Get('Recent') + async recent(@Req() req: any, @Query('limit') limit?: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.recent(Number(limit) || 50)); + } + + @Get('ByFlow') + async byFlow(@Req() req: any, @Query('flowId') flowId: string, @Query('limit') limit?: string) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.byFlow(flowId, Number(limit) || 20)); + } +} diff --git a/src/backend/src/sswflow/flowrun.entity.ts b/src/backend/src/sswflow/flowrun.entity.ts new file mode 100644 index 0000000..52cf764 --- /dev/null +++ b/src/backend/src/sswflow/flowrun.entity.ts @@ -0,0 +1,69 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 运行实例(sswflow_flow_run)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../FlowRunEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_flow_run' }) +export class FlowRunEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_flow_id', type: 'varchar', length: 50, nullable: true }) + flowId: string; + + @Column({ name: 'f_flow_name', type: 'varchar', length: 255, nullable: true }) + flowName: string; + + @Column({ name: 'f_project_id', type: 'varchar', length: 50, nullable: true }) + projectId: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_trigger', type: 'varchar', length: 32, nullable: true }) + trigger: string; + + @Column({ name: 'f_operator', type: 'varchar', length: 50, nullable: true }) + operator: string; + + @Column({ name: 'f_start_time', type: 'timestamp', nullable: true }) + startTime: Date; + + @Column({ name: 'f_end_time', type: 'timestamp', nullable: true }) + endTime: Date; + + @Column({ name: 'f_cost_ms', type: 'int', nullable: true, default: 0 }) + costMs: number; + + @Column({ name: 'f_error_msg', type: 'varchar', length: 2000, nullable: true }) + errorMsg: string; + + @Column({ name: 'f_cancelled_mark', type: 'int', nullable: true, default: 0 }) + cancelledMark: number; + + @Column({ name: 'f_steps_snapshot', type: 'text', nullable: true }) + stepsSnapshot: string; + + @Column({ name: 'f_edges_snapshot', type: 'text', nullable: true }) + edgesSnapshot: string; + + @Column({ name: 'f_base_run_id', type: 'varchar', length: 50, nullable: true }) + baseRunId: string; + + @Column({ name: 'f_run_mode', type: 'varchar', length: 32, nullable: true }) + runMode: string; + + @Column({ name: 'f_selected_steps', type: 'text', nullable: true }) + selectedSteps: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/flowrun.service.ts b/src/backend/src/sswflow/flowrun.service.ts new file mode 100644 index 0000000..c8d9e6d --- /dev/null +++ b/src/backend/src/sswflow/flowrun.service.ts @@ -0,0 +1,398 @@ +/** + * 运行调度中枢 —— 机械翻译自 ssw-mvp `FlowRunServiceImpl.java`(1063 行)。 + * + * 状态机(逐字保值): + * run : PENDING → RUNNING → SUCCESS | FAILED | STOPPED + * step: PENDING → RUNNING → SUCCESS | FAILED | STOPPED | SKIPPED + * trigger: MANUAL / SCHEDULE / API / RERUN + * runMode: FULL / SINGLE / SELECTED / UPSTREAM / DOWNSTREAM / RESUME + * + * 相对原实现的裁剪:去掉 TDC 回调链、跨方 HTTP 转发、SSE(前端改为轮询 Events)、 + * 审批/待办;执行引擎经 EngineRegistry 换成 ssw-mpc(见 engine/)。 + * 保留:DAG 拓扑排序、部分运行/续跑、失败下游 SKIPPED、取消、事件增量游标、产物落库。 + */ +import { Injectable, Logger } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { In, Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { BizException } from '../common/business.exception'; +import { FlowEntity } from './flow.entity'; +import { FlowRunEntity } from './flowrun.entity'; +import { FlowStepRunEntity } from './flowsteprun.entity'; +import { RunEventEntity } from './runevent.entity'; +import { ArtifactEntity } from './artifact.entity'; +import { FlowGraph, FlowStep } from './engine/flow-graph'; +import { EngineRegistry } from './engine/engine-registry'; +import { StepArtifact, StepContext } from './engine/compute-engine'; +import { findOperator } from './catalog/operator-catalog'; +import { compileOrchPlan } from './engine/mpc-operator-map'; +import { mpcSettings, runOrchPlan } from './engine/mpc-client'; + +export interface StartOptions { + trigger?: string; + mode?: string; + stepIds?: string[]; + baseRunId?: string; + skipSucceeded?: boolean; + operator?: string; +} + +@Injectable() +export class FlowRunService { + private readonly logger = new Logger('FlowRun'); + /** 终止标记(内存态;迁 JNPF 时换 Redis / f_cancelled_mark 轮询) */ + private readonly cancelled = new Set(); + /** runId -> 事件增量游标(对应 Java run_event.f_sort_code) */ + private readonly seq = new Map(); + + constructor( + @InjectRepository(FlowRunEntity) private readonly runRepo: Repository, + @InjectRepository(FlowStepRunEntity) private readonly stepRepo: Repository, + @InjectRepository(RunEventEntity) private readonly eventRepo: Repository, + @InjectRepository(ArtifactEntity) private readonly artifactRepo: Repository, + @InjectRepository(FlowEntity) private readonly flowRepo: Repository, + private readonly engines: EngineRegistry, + ) {} + + // ---------- 标准 CRUD(接触点:软删契约) ---------- + + async list(): Promise { + return this.runRepo.find({ where: { deleteMark: 0 } as any, order: { creatorTime: 'DESC' } as any, take: 200 }); + } + + async get(id: string): Promise { + return this.runRepo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.runRepo.create({ + ...item, id: randomUUID(), creatorTime: new Date(), deleteMark: 0, + creatorUserId: (item as any).creatorUserId || 'admin', + } as any); + return (await this.runRepo.save(ent)) as unknown as FlowRunEntity; + } + // 按 id 找原行(不过滤 deleteMark:软删行仍允许被更新回来); + // 不走 this.get(),否则软删行会拿到 null 导致 Object.assign 抛错。 + const existing = await this.runRepo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.runRepo.create({ ...item, id: item.id, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.runRepo.save(created)) as unknown as FlowRunEntity; + } + Object.assign(existing, item); + return (await this.runRepo.save(existing)) as unknown as FlowRunEntity; + } + + async remove(id: string): Promise { + await this.runRepo.update({ id } as any, { deleteMark: 1 } as any); + } + + // ---------- 运行生命周期 ---------- + + async start(flowId: string, opts: StartOptions = {}): Promise { + const flow = await this.flowRepo.findOne({ where: { id: flowId, deleteMark: 0 } as any }); + if (!flow) throw new BizException('流程不存在或已删除'); + const graph = FlowGraph.parse(flow.steps, flow.edges); + const issues = graph.validate().filter((i) => i.level === 'ERROR'); + if (issues.length) throw new BizException('流程校验未通过:' + issues.map((i) => i.message).join(';')); + + const ordered = graph.topologicalOrder(); + const mode = (opts.mode || 'FULL').toUpperCase(); + const effective = await this.resolveEffective(graph, ordered, mode, opts); + const now = new Date(); + const run = await this.runRepo.save(this.runRepo.create({ + id: randomUUID(), + flowId: flow.id, + flowName: flow.name, + projectId: flow.projectId, + status: 'PENDING', + trigger: opts.trigger || 'MANUAL', + operator: opts.operator || 'admin', + cancelledMark: 0, + stepsSnapshot: JSON.stringify(graph.steps ? [...graph.steps.values()] : []), + edgesSnapshot: JSON.stringify(graph.edges), + baseRunId: opts.baseRunId || null, + runMode: mode, + selectedSteps: JSON.stringify(opts.stepIds || []), + creatorTime: now, + creatorUserId: 'admin', + deleteMark: 0, + } as any) as unknown as FlowRunEntity) as unknown as FlowRunEntity; + + this.seq.set(run.id, 0); + this.cancelled.delete(run.id); + // 预建步骤记录:范围内 PENDING,范围外 SKIPPED(对齐 Java FlowRunServiceImpl:171-185) + for (let i = 0; i < ordered.length; i++) { + const stepId = ordered[i]; + const step = graph.getStep(stepId)!; + await this.stepRepo.save(this.stepRepo.create({ + id: randomUUID(), runId: run.id, stepId, + operatorKey: step.operatorKey, label: step.label || step.operatorKey, + status: effective.has(stepId) ? 'PENDING' : 'SKIPPED', + progress: 0, seq: i + 1, + parties: JSON.stringify([]), + paramsSnapshot: JSON.stringify(step.params || {}), + creatorTime: now, deleteMark: 0, + } as any) as unknown as FlowStepRunEntity); + } + await this.event(run.id, null, 'run.status', 'PENDING', 0, 'INFO', + `运行已创建:mode=${mode},范围 ${effective.size}/${ordered.length} 个节点`); + await this.flowRepo.update({ id: flow.id } as any, + { lastRunId: run.id, lastRunStatus: 'PENDING', lastRunTime: now } as any); + + // 异步执行:HTTP 立即返回 runId,前端轮询 Events(原 SSE 的等价物) + void this.execute(run.id); + return run; + } + + /** 6 种 RunScope(对齐 ssw-mvp engine/RunScope.java) */ + private async resolveEffective( + graph: FlowGraph, ordered: string[], mode: string, opts: StartOptions, + ): Promise> { + const all = new Set(ordered); + const selected = new Set((opts.stepIds || []).filter((id) => graph.steps.has(id))); + if (mode === 'FULL') return all; + if (mode === 'SINGLE' || mode === 'SELECTED') return selected; + if (mode === 'UPSTREAM') { + const s = new Set(); + selected.forEach((id) => { s.add(id); graph.ancestors(id).forEach((a) => s.add(a)); }); + return s; + } + if (mode === 'DOWNSTREAM') { + const s = new Set(); + selected.forEach((id) => { s.add(id); graph.descendants(id).forEach((d) => s.add(d)); }); + return s; + } + if (mode === 'RESUME') { + if (!opts.baseRunId) throw new BizException('RESUME 模式需要 baseRunId'); + const base = await this.stepRepo.find({ where: { runId: opts.baseRunId } as any }); + const done = new Set(base.filter((b) => b.status === 'SUCCESS').map((b) => b.stepId)); + return new Set(ordered.filter((id) => !(opts.skipSucceeded !== false && done.has(id)))); + } + throw new BizException(`未知运行模式:${mode}`); + } + + /** 拓扑推进:逐节点执行引擎、落事件/产物,失败下游自动 SKIPPED */ + private async execute(runId: string): Promise { + const started = Date.now(); + const run = await this.get(runId); + if (!run) return; + const graph = FlowGraph.parse(run.stepsSnapshot, run.edgesSnapshot); + const ordered = graph.topologicalOrder(); + let finalStatus = 'SUCCESS'; + const failedOrSkipped = new Set(); + + await this.runRepo.update({ id: runId } as any, + { status: 'RUNNING', startTime: new Date() } as any); + await this.event(runId, null, 'run.status', 'RUNNING', 0, 'INFO', '开始执行'); + + // 作业级 DAG:把整张图编译成 ssw-mpc 的 plan(只编译不自动执行,避免无 agent 时挂住) + if (mpcSettings().enabled) { + try { + const plan = compileOrchPlan( + [...graph.steps.values()] as any, + graph.edges.map((e) => ({ sourceStepId: e.sourceStepId, targetStepId: e.targetStepId })), + mpcSettings().sites, + ); + const out = await runOrchPlan(plan, runId, process.env.MPC_ORCH_EXEC === '1'); + await this.event(runId, null, 'run.log', 'PLAN', 0, 'INFO', + `已编译 ssw-mpc 作业计划:${out.planPath}(${ordered.length} 个 job)`); + } catch (e: any) { + await this.event(runId, null, 'run.log', 'PLAN', 0, 'WARN', `plan 编译跳过:${e.message}`); + } + } + + for (const stepId of ordered) { + const step = graph.getStep(stepId); + if (!step) continue; + if (this.cancelled.has(runId)) { + finalStatus = 'STOPPED'; + await this.markRemaining(runId, ordered.slice(ordered.indexOf(stepId)), 'STOPPED', '运行被人工终止'); + break; + } + const stepRows = await this.stepRepo.find({ where: { runId, stepId } as any }); + if (stepRows[0]?.status === 'SKIPPED') continue; + + // 上游失败 → 本节点 SKIPPED,不再空跑 + const upstreamFailed = [...graph.incoming.get(stepId)!].some((p) => failedOrSkipped.has(p)); + if (upstreamFailed) { + failedOrSkipped.add(stepId); + await this.updateStep(runId, stepId, { status: 'SKIPPED', progress: 0, endTime: new Date(), costMs: 0, errorMsg: '上游节点未成功' }); + await this.event(runId, stepId, 'step.status', 'SKIPPED', 0, 'WARN', '上游节点未成功,跳过'); + continue; + } + + const stepStart = new Date(); + await this.updateStep(runId, stepId, { status: 'RUNNING', progress: 0, startTime: stepStart }); + await this.event(runId, stepId, 'step.status', 'RUNNING', 0, 'INFO', `节点 ${step.label || step.operatorKey} 开始`); + + try { + const inputs = await this.collectInputs(runId, graph, stepId); + const op = findOperator(step.operatorKey) || {}; + const ctx: StepContext = { + runId, stepId, operatorKey: step.operatorKey, + label: step.label || step.operatorKey, params: step.params || {}, + engineType: op.engine || 'mpc', inputs, parties: [], graph, + }; + const engine = this.engines.select(ctx.engineType, ctx.operatorKey); + const result = await engine.execute(ctx); + for (const log of result.logs) { + await this.event(runId, stepId, 'step.log', result.status, 0, + log.includes('[ERROR]') ? 'ERROR' : log.includes('[WARN]') ? 'WARN' : 'INFO', log); + } + if (result.status !== 'SUCCESS') { + finalStatus = 'FAILED'; + failedOrSkipped.add(stepId); + await this.updateStep(runId, stepId, { + status: 'FAILED', progress: 100, endTime: new Date(), + costMs: Date.now() - stepStart.getTime(), errorMsg: result.errorMsg, + }); + await this.event(runId, stepId, 'step.status', 'FAILED', 100, 'ERROR', result.errorMsg || '节点执行失败'); + continue; + } + await this.saveArtifacts(runId, stepId, result.artifacts); + await this.updateStep(runId, stepId, { + status: 'SUCCESS', progress: 100, endTime: new Date(), costMs: Date.now() - stepStart.getTime(), + }); + await this.event(runId, stepId, 'step.status', 'SUCCESS', 100, 'INFO', + `${result.engineName} 执行完成,产出 ${result.artifacts.length} 个端口产物`); + } catch (e: any) { + finalStatus = 'FAILED'; + failedOrSkipped.add(stepId); + await this.updateStep(runId, stepId, { + status: 'FAILED', progress: 100, endTime: new Date(), + costMs: Date.now() - stepStart.getTime(), errorMsg: e.message, + }); + await this.event(runId, stepId, 'step.status', 'FAILED', 100, 'ERROR', e.message); + } + } + + const end = new Date(); + await this.runRepo.update({ id: runId } as any, { + status: finalStatus, endTime: end, costMs: end.getTime() - started, + errorMsg: finalStatus === 'FAILED' ? '存在失败节点' : null, + } as any); + await this.event(runId, null, 'run.finish', finalStatus, 100, + finalStatus === 'SUCCESS' ? 'INFO' : 'ERROR', `运行结束:${finalStatus}`); + if (run.flowId) { + await this.flowRepo.update({ id: run.flowId } as any, + { lastRunStatus: finalStatus, lastRunTime: end } as any); + } + this.cancelled.delete(runId); + } + + async stop(runId: string): Promise { + const run = await this.get(runId); + if (!run) throw new BizException('运行实例不存在'); + if (!['PENDING', 'RUNNING'].includes(run.status)) throw new BizException('该运行已结束,无需终止'); + this.cancelled.add(runId); + await this.runRepo.update({ id: runId } as any, { cancelledMark: 1 } as any); + await this.event(runId, null, 'run.status', 'STOPPED', 0, 'WARN', '收到人工终止指令'); + } + + // ---------- 查询 ---------- + + steps(runId: string): Promise { + return this.stepRepo.find({ where: { runId } as any, order: { seq: 'ASC' } as any }); + } + + async events(runId: string, afterSeq = 0, limit = 200): Promise { + const rows = await this.eventRepo.find({ where: { runId } as any, order: { sortCode: 'ASC' } as any, take: 1000 }); + return rows.filter((r) => (r.sortCode || 0) > afterSeq).slice(0, limit); + } + + async artifacts(runId: string, stepId?: string): Promise { + const where: any = { runId }; + if (stepId) where.stepId = stepId; + return this.artifactRepo.find({ where, order: { creatorTime: 'ASC' } as any }); + } + + async overview(runId: string) { + const run = await this.get(runId); + if (!run) throw new BizException('运行实例不存在'); + const steps = await this.steps(runId); + const events = await this.events(runId, 0, 200); + const artifacts = await this.artifacts(runId); + return { + run, steps, events, artifacts, + stats: { + total: steps.length, + success: steps.filter((s) => s.status === 'SUCCESS').length, + failed: steps.filter((s) => s.status === 'FAILED').length, + skipped: steps.filter((s) => s.status === 'SKIPPED').length, + artifacts: artifacts.length, + }, + }; + } + + byFlow(flowId: string, limit = 20): Promise { + return this.runRepo.find({ where: { flowId, deleteMark: 0 } as any, order: { creatorTime: 'DESC' } as any, take: limit }); + } + + recent(limit = 50): Promise { + return this.runRepo.find({ where: { deleteMark: 0 } as any, order: { creatorTime: 'DESC' } as any, take: limit }); + } + + // ---------- 内部工具 ---------- + + private async updateStep(runId: string, stepId: string, patch: any): Promise { + await this.stepRepo.update({ runId, stepId } as any, patch as any); + } + + private async markRemaining(runId: string, ids: string[], status: string, msg: string): Promise { + for (const id of ids) { + await this.updateStep(runId, id, { status, progress: 0, endTime: new Date(), costMs: 0, errorMsg: msg }); + await this.event(runId, id, 'step.status', status, 0, 'WARN', msg); + } + } + + private async event( + runId: string, stepId: string | null, type: string, status: string, + progress: number, level: string, message: string, + ): Promise { + const sortCode = (this.seq.get(runId) || 0) + 1; + this.seq.set(runId, sortCode); + await this.eventRepo.save(this.eventRepo.create({ + id: randomUUID(), runId, stepId, type, status, progress, level, message, + ts: new Date(), sortCode, creatorTime: new Date(), creatorUserId: 'system', deleteMark: 0, + } as any) as unknown as RunEventEntity); + } + + /** 按端口级连线把上游产物装配成本节点输入 */ + private async collectInputs(runId: string, graph: FlowGraph, stepId: string): Promise> { + const bindings = graph.inputBindings.get(stepId) || new Map(); + if (!bindings.size) return {}; + const all = await this.artifactRepo.find({ where: { runId } as any }); + const toArtifact = (a: ArtifactEntity): StepArtifact => ({ + portKey: a.portKey, type: (a.type as any) || 'table', title: a.title, + summary: a.summary, uri: a.uri, rowCount: a.rowCount, + columns: parseJson(a.columns, []), rows: parseJson(a.rows, []), metrics: parseJson(a.metrics, {}), + }); + const inputs: Record = {}; + bindings.forEach((refs, port) => { + inputs[port] = []; + for (const ref of refs) { + const [src, srcPort] = ref.split('#'); + all.filter((a) => a.stepId === src && a.portKey === srcPort).forEach((a) => inputs[port].push(toArtifact(a))); + } + }); + return inputs; + } + + private async saveArtifacts(runId: string, stepId: string, artifacts: StepArtifact[]): Promise { + for (const a of artifacts) { + await this.artifactRepo.save(this.artifactRepo.create({ + id: randomUUID(), runId, stepId, + portKey: a.portKey, type: a.type, title: a.title, summary: a.summary || '', + columns: JSON.stringify(a.columns || []), rows: JSON.stringify(a.rows || []), + metrics: JSON.stringify(a.metrics || {}), uri: a.uri || '', rowCount: a.rowCount || 0, + creatorTime: new Date(), creatorUserId: 'system', deleteMark: 0, + } as any) as unknown as ArtifactEntity); + } + } +} + +function parseJson(s: any, fallback: any): any { + if (!s) return fallback; + try { return typeof s === 'string' ? JSON.parse(s) : s; } catch { return fallback; } +} diff --git a/src/backend/src/sswflow/flowschedule.controller.ts b/src/backend/src/sswflow/flowschedule.controller.ts new file mode 100644 index 0000000..3b4a30d --- /dev/null +++ b/src/backend/src/sswflow/flowschedule.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { FlowScheduleService } from './flowschedule.service'; + +const MODULE_KEY = 'sswflow/FlowSchedule'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 周期调度 —— /api/ssw/sswflow/FlowSchedule/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/FlowSchedule') +export class FlowScheduleController { + constructor( + private readonly svc: FlowScheduleService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/flowschedule.entity.ts b/src/backend/src/sswflow/flowschedule.entity.ts new file mode 100644 index 0000000..80c05c4 --- /dev/null +++ b/src/backend/src/sswflow/flowschedule.entity.ts @@ -0,0 +1,54 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 周期调度(sswflow_flow_schedule)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../FlowScheduleEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_flow_schedule' }) +export class FlowScheduleEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_flow_id', type: 'varchar', length: 50, nullable: true }) + flowId: string; + + @Column({ name: 'f_project_id', type: 'varchar', length: 50, nullable: true }) + projectId: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_cron', type: 'varchar', length: 100, nullable: true }) + cron: string; + + @Column({ name: 'f_enabled_mark', type: 'int', nullable: true, default: 0 }) + enabledMark: number; + + @Column({ name: 'f_next_fire_time', type: 'timestamp', nullable: true }) + nextFireTime: Date; + + @Column({ name: 'f_last_fire_time', type: 'timestamp', nullable: true }) + lastFireTime: Date; + + @Column({ name: 'f_last_run_id', type: 'varchar', length: 50, nullable: true }) + lastRunId: string; + + @Column({ name: 'f_last_status', type: 'varchar', length: 32, nullable: true }) + lastStatus: string; + + @Column({ name: 'f_misfire_policy', type: 'varchar', length: 32, nullable: true }) + misfirePolicy: string; + + @Column({ name: 'f_run_scope', type: 'varchar', length: 32, nullable: true }) + runScope: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/flowschedule.service.ts b/src/backend/src/sswflow/flowschedule.service.ts new file mode 100644 index 0000000..bfabc10 --- /dev/null +++ b/src/backend/src/sswflow/flowschedule.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { FlowScheduleEntity } from './flowschedule.entity'; + +/** 周期调度服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class FlowScheduleService { + constructor( + @InjectRepository(FlowScheduleEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as FlowScheduleEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as FlowScheduleEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as FlowScheduleEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/flowsteprun.controller.ts b/src/backend/src/sswflow/flowsteprun.controller.ts new file mode 100644 index 0000000..a918790 --- /dev/null +++ b/src/backend/src/sswflow/flowsteprun.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { FlowStepRunService } from './flowsteprun.service'; + +const MODULE_KEY = 'sswflow/FlowStepRun'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 步骤运行 —— /api/ssw/sswflow/FlowStepRun/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/FlowStepRun') +export class FlowStepRunController { + constructor( + private readonly svc: FlowStepRunService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/flowsteprun.entity.ts b/src/backend/src/sswflow/flowsteprun.entity.ts new file mode 100644 index 0000000..d76a50b --- /dev/null +++ b/src/backend/src/sswflow/flowsteprun.entity.ts @@ -0,0 +1,60 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 步骤运行(sswflow_flow_step_run)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../FlowStepRunEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_flow_step_run' }) +export class FlowStepRunEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_run_id', type: 'varchar', length: 50, nullable: true }) + runId: string; + + @Column({ name: 'f_step_id', type: 'varchar', length: 50, nullable: true }) + stepId: string; + + @Column({ name: 'f_operator_key', type: 'varchar', length: 100, nullable: true }) + operatorKey: string; + + @Column({ name: 'f_label', type: 'varchar', length: 255, nullable: true }) + label: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_progress', type: 'int', nullable: true, default: 0 }) + progress: number; + + @Column({ name: 'f_seq', type: 'int', nullable: true, default: 0 }) + seq: number; + + @Column({ name: 'f_start_time', type: 'timestamp', nullable: true }) + startTime: Date; + + @Column({ name: 'f_end_time', type: 'timestamp', nullable: true }) + endTime: Date; + + @Column({ name: 'f_cost_ms', type: 'int', nullable: true, default: 0 }) + costMs: number; + + @Column({ name: 'f_error_msg', type: 'varchar', length: 2000, nullable: true }) + errorMsg: string; + + @Column({ name: 'f_parties', type: 'text', nullable: true }) + parties: string; + + @Column({ name: 'f_params_snapshot', type: 'text', nullable: true }) + paramsSnapshot: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/flowsteprun.service.ts b/src/backend/src/sswflow/flowsteprun.service.ts new file mode 100644 index 0000000..16d79f9 --- /dev/null +++ b/src/backend/src/sswflow/flowsteprun.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { FlowStepRunEntity } from './flowsteprun.entity'; + +/** 步骤运行服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class FlowStepRunService { + constructor( + @InjectRepository(FlowStepRunEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as FlowStepRunEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as FlowStepRunEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as FlowStepRunEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/operator.controller.ts b/src/backend/src/sswflow/operator.controller.ts new file mode 100644 index 0000000..a34b81b --- /dev/null +++ b/src/backend/src/sswflow/operator.controller.ts @@ -0,0 +1,61 @@ +import { Controller, Get, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { OPERATOR_CATALOG, allOperators, findOperator } from './catalog/operator-catalog'; +import { MPC_OPERATOR_MAP } from './engine/mpc-operator-map'; + +/** + * 算子协议目录 —— 对齐 ssw-mvp OperatorController + OperatorCatalogService。 + * catalog.json 是画布节点类型/端口/参数的唯一事实来源; + * 额外返回每个算子在 ssw-mpc 上的能力状态,前端可据此显示「原生/降级」。 + */ +@Controller('api/ssw/sswflow/Operator') +export class OperatorController { + constructor( + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + if (!(await this.perm.hasModule(u.userId, u.isAdmin, 'sswflow/Flow'))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('Catalog') + async catalog(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success({ + ...OPERATOR_CATALOG, + categories: OPERATOR_CATALOG.categories.map((c: any) => ({ + ...c, + operators: (c.operators || []).map((o: any) => ({ + ...o, + mpc: MPC_OPERATOR_MAP[o.key] || { status: 'unsupported', crate: '-', note: '未登记' }, + })), + })), + }); + } + + @Get('Keys') + async keys(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(allOperators().map((o) => o.key)); + } + + @Get('Info') + async info(@Req() req: any, @Query('key') key: string) { + const g = await this.guard(req); + if (g) return g; + const op = findOperator(key); + return op + ? ActionResult.success({ ...op, mpc: MPC_OPERATOR_MAP[key] || null }) + : ActionResult.fail(400, `未知算子 ${key}`); + } +} diff --git a/src/backend/src/sswflow/party.controller.ts b/src/backend/src/sswflow/party.controller.ts new file mode 100644 index 0000000..763c553 --- /dev/null +++ b/src/backend/src/sswflow/party.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { PartyService } from './party.service'; + +const MODULE_KEY = 'sswflow/Party'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 参与方 —— /api/ssw/sswflow/Party/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/Party') +export class PartyController { + constructor( + private readonly svc: PartyService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/party.entity.ts b/src/backend/src/sswflow/party.entity.ts new file mode 100644 index 0000000..797028b --- /dev/null +++ b/src/backend/src/sswflow/party.entity.ts @@ -0,0 +1,60 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 参与方(sswflow_party)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../PartyEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_party' }) +export class PartyEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_party_code', type: 'varchar', length: 100, nullable: true }) + partyCode: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_organize_id', type: 'varchar', length: 50, nullable: true }) + organizeId: string; + + @Column({ name: 'f_org_name', type: 'varchar', length: 255, nullable: true }) + orgName: string; + + @Column({ name: 'f_endpoint', type: 'varchar', length: 500, nullable: true }) + endpoint: string; + + @Column({ name: 'f_role', type: 'varchar', length: 32, nullable: true }) + role: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_self_mark', type: 'int', nullable: true, default: 0 }) + selfMark: number; + + @Column({ name: 'f_compute_mode', type: 'varchar', length: 50, nullable: true }) + computeMode: string; + + @Column({ name: 'f_node_config', type: 'text', nullable: true }) + nodeConfig: string; + + @Column({ name: 'f_cert_pem', type: 'text', nullable: true }) + certPem: string; + + @Column({ name: 'f_desc', type: 'varchar', length: 1000, nullable: true }) + desc: string; + + @Column({ name: 'f_last_heartbeat_time', type: 'timestamp', nullable: true }) + lastHeartbeatTime: Date; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/party.service.ts b/src/backend/src/sswflow/party.service.ts new file mode 100644 index 0000000..17829d0 --- /dev/null +++ b/src/backend/src/sswflow/party.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { PartyEntity } from './party.entity'; + +/** 参与方服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class PartyService { + constructor( + @InjectRepository(PartyEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as PartyEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as PartyEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as PartyEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/project.controller.ts b/src/backend/src/sswflow/project.controller.ts new file mode 100644 index 0000000..0a50626 --- /dev/null +++ b/src/backend/src/sswflow/project.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { ProjectService } from './project.service'; + +const MODULE_KEY = 'sswflow/Project'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 项目 —— /api/ssw/sswflow/Project/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/Project') +export class ProjectController { + constructor( + private readonly svc: ProjectService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/project.entity.ts b/src/backend/src/sswflow/project.entity.ts new file mode 100644 index 0000000..8f78d42 --- /dev/null +++ b/src/backend/src/sswflow/project.entity.ts @@ -0,0 +1,39 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 项目(sswflow_project)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../ProjectEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_project' }) +export class ProjectEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_project_code', type: 'varchar', length: 100, nullable: true }) + projectCode: string; + + @Column({ name: 'f_name', type: 'varchar', length: 255, nullable: true }) + name: string; + + @Column({ name: 'f_desc', type: 'varchar', length: 1000, nullable: true }) + desc: string; + + @Column({ name: 'f_owner_party_id', type: 'varchar', length: 50, nullable: true }) + ownerPartyId: string; + + @Column({ name: 'f_compute_mode', type: 'varchar', length: 50, nullable: true }) + computeMode: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/project.service.ts b/src/backend/src/sswflow/project.service.ts new file mode 100644 index 0000000..097169e --- /dev/null +++ b/src/backend/src/sswflow/project.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { ProjectEntity } from './project.entity'; + +/** 项目服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class ProjectService { + constructor( + @InjectRepository(ProjectEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as ProjectEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as ProjectEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as ProjectEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/projectparty.controller.ts b/src/backend/src/sswflow/projectparty.controller.ts new file mode 100644 index 0000000..efba5a1 --- /dev/null +++ b/src/backend/src/sswflow/projectparty.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { ProjectPartyService } from './projectparty.service'; + +const MODULE_KEY = 'sswflow/ProjectParty'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 项目参与方 —— /api/ssw/sswflow/ProjectParty/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/ProjectParty') +export class ProjectPartyController { + constructor( + private readonly svc: ProjectPartyService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/projectparty.entity.ts b/src/backend/src/sswflow/projectparty.entity.ts new file mode 100644 index 0000000..6d0571b --- /dev/null +++ b/src/backend/src/sswflow/projectparty.entity.ts @@ -0,0 +1,39 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 项目参与方(sswflow_project_party)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../ProjectPartyEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_project_party' }) +export class ProjectPartyEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_project_id', type: 'varchar', length: 50, nullable: true }) + projectId: string; + + @Column({ name: 'f_party_id', type: 'varchar', length: 50, nullable: true }) + partyId: string; + + @Column({ name: 'f_role', type: 'varchar', length: 32, nullable: true }) + role: string; + + @Column({ name: 'f_join_status', type: 'varchar', length: 32, nullable: true }) + joinStatus: string; + + @Column({ name: 'f_invite_time', type: 'timestamp', nullable: true }) + inviteTime: Date; + + @Column({ name: 'f_join_time', type: 'timestamp', nullable: true }) + joinTime: Date; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/projectparty.service.ts b/src/backend/src/sswflow/projectparty.service.ts new file mode 100644 index 0000000..db8c0fb --- /dev/null +++ b/src/backend/src/sswflow/projectparty.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { ProjectPartyEntity } from './projectparty.entity'; + +/** 项目参与方服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class ProjectPartyService { + constructor( + @InjectRepository(ProjectPartyEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as ProjectPartyEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as ProjectPartyEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as ProjectPartyEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/runevent.controller.ts b/src/backend/src/sswflow/runevent.controller.ts new file mode 100644 index 0000000..b24a09b --- /dev/null +++ b/src/backend/src/sswflow/runevent.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from '../sys/permission.service'; +import { RunEventService } from './runevent.service'; + +const MODULE_KEY = 'sswflow/RunEvent'; // == base_module.f_url_address == 前端 Route path == 菜单守卫 key + +/** 运行事件 —— /api/ssw/sswflow/RunEvent/{List|Save|Delete};登录 + 四源合并菜单守卫。 */ +@Controller('api/ssw/sswflow/RunEvent') +export class RunEventController { + constructor( + private readonly svc: RunEventService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private async guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, MODULE_KEY))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.list()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.save(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guard(req); + if (g) return g; + await this.svc.remove(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sswflow/runevent.entity.ts b/src/backend/src/sswflow/runevent.entity.ts new file mode 100644 index 0000000..9243603 --- /dev/null +++ b/src/backend/src/sswflow/runevent.entity.ts @@ -0,0 +1,48 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 运行事件(sswflow_run_event)—— 抽取自 ssw-mvp `boot/ssw-sswflow/.../RunEventEntity.java` + * 契约:f_ 列 + 主键 f_id varchar(50) + 软删 f_delete_mark;迁 JNPF 时对应 SuperEntity 子类。 + */ +@Entity({ name: 'sswflow_run_event' }) +export class RunEventEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id: string; + + @Column({ name: 'f_run_id', type: 'varchar', length: 50, nullable: true }) + runId: string; + + @Column({ name: 'f_step_id', type: 'varchar', length: 50, nullable: true }) + stepId: string; + + @Column({ name: 'f_type', type: 'varchar', length: 50, nullable: true }) + type: string; + + @Column({ name: 'f_status', type: 'varchar', length: 32, nullable: true }) + status: string; + + @Column({ name: 'f_progress', type: 'int', nullable: true, default: 0 }) + progress: number; + + @Column({ name: 'f_level', type: 'varchar', length: 16, nullable: true }) + level: string; + + @Column({ name: 'f_message', type: 'varchar', length: 2000, nullable: true }) + message: string; + + @Column({ name: 'f_ts', type: 'timestamp', nullable: true }) + ts: Date; + + @Column({ name: 'f_sort_code', type: 'int', nullable: true, default: 0 }) + sortCode: number; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId: string; + + @Column({ name: 'f_creator_time', type: 'timestamp', nullable: true }) + creatorTime: Date; + + @Column({ name: 'f_delete_mark', type: 'int', nullable: true, default: 0 }) + deleteMark: number; + +} diff --git a/src/backend/src/sswflow/runevent.service.ts b/src/backend/src/sswflow/runevent.service.ts new file mode 100644 index 0000000..5f73e1e --- /dev/null +++ b/src/backend/src/sswflow/runevent.service.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { randomUUID } from 'crypto'; +import { RunEventEntity } from './runevent.entity'; + +/** 运行事件服务 —— 列表带软删过滤、删除是 update f_delete_mark=1、主键 36 位 UUID。 + * 迁 JNPF:对应 XxxServiceImpl extends SuperServiceImpl,逻辑逐行可译。 */ +@Injectable() +export class RunEventService { + constructor( + @InjectRepository(RunEventEntity) + private readonly repo: Repository, + ) {} + + async list(): Promise { + return this.repo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + } + + async get(id: string): Promise { + return this.repo.findOne({ where: { id, deleteMark: 0 } as any }); + } + + async save(item: Partial): Promise { + if (!item.id) { + const ent = this.repo.create({ + ...item, + id: randomUUID(), + creatorUserId: (item as any).creatorUserId || 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + return (await this.repo.save(ent)) as unknown as RunEventEntity; + } + const existing = await this.repo.findOne({ where: { id: item.id } as any }); + if (!existing) { + const created = this.repo.create({ ...item, creatorTime: new Date(), deleteMark: 0 } as any); + return (await this.repo.save(created)) as unknown as RunEventEntity; + } + Object.assign(existing, item); + return (await this.repo.save(existing)) as unknown as RunEventEntity; + } + + async remove(id: string): Promise { + await this.repo.update({ id } as any, { deleteMark: 1 } as any); + } +} diff --git a/src/backend/src/sswflow/sswflow.module.ts b/src/backend/src/sswflow/sswflow.module.ts new file mode 100644 index 0000000..075bfc5 --- /dev/null +++ b/src/backend/src/sswflow/sswflow.module.ts @@ -0,0 +1,73 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { AuthModule } from '../auth/auth.module'; +import { SysModule } from '../sys/sys.module'; + +import { ProjectEntity } from './project.entity'; +import { PartyEntity } from './party.entity'; +import { ProjectPartyEntity } from './projectparty.entity'; +import { DatasourceEntity } from './datasource.entity'; +import { DatasetEntity } from './dataset.entity'; +import { DatasetAuthEntity } from './datasetauth.entity'; +import { FlowEntity } from './flow.entity'; +import { FlowRunEntity } from './flowrun.entity'; +import { FlowStepRunEntity } from './flowsteprun.entity'; +import { RunEventEntity } from './runevent.entity'; +import { ArtifactEntity } from './artifact.entity'; +import { FlowScheduleEntity } from './flowschedule.entity'; + +import { ProjectService } from './project.service'; +import { PartyService } from './party.service'; +import { ProjectPartyService } from './projectparty.service'; +import { DatasourceService } from './datasource.service'; +import { DatasetService } from './dataset.service'; +import { DatasetAuthService } from './datasetauth.service'; +import { FlowService } from './flow.service'; +import { FlowRunService } from './flowrun.service'; +import { FlowStepRunService } from './flowsteprun.service'; +import { RunEventService } from './runevent.service'; +import { ArtifactService } from './artifact.service'; +import { FlowScheduleService } from './flowschedule.service'; +import { EngineRegistry } from './engine/engine-registry'; + +import { ProjectController } from './project.controller'; +import { PartyController } from './party.controller'; +import { ProjectPartyController } from './projectparty.controller'; +import { DatasourceController } from './datasource.controller'; +import { DatasetController } from './dataset.controller'; +import { DatasetAuthController } from './datasetauth.controller'; +import { FlowController } from './flow.controller'; +import { FlowRunController } from './flowrun.controller'; +import { FlowStepRunController } from './flowsteprun.controller'; +import { RunEventController } from './runevent.controller'; +import { ArtifactController } from './artifact.controller'; +import { FlowScheduleController } from './flowschedule.controller'; +import { OperatorController } from './operator.controller'; +import { EngineController } from './engine.controller'; + +/** sswflow 业务模块(appCode=sswflow)—— 12 张 f_ 表 + 14 个控制器 + 可插拔执行引擎。 */ +@Module({ + imports: [ + TypeOrmModule.forFeature([ + ProjectEntity, PartyEntity, ProjectPartyEntity, DatasourceEntity, + DatasetEntity, DatasetAuthEntity, FlowEntity, FlowRunEntity, + FlowStepRunEntity, RunEventEntity, ArtifactEntity, FlowScheduleEntity, + ]), + AuthModule, + SysModule, + ], + controllers: [ + ProjectController, PartyController, ProjectPartyController, DatasourceController, + DatasetController, DatasetAuthController, FlowController, FlowRunController, + FlowStepRunController, RunEventController, ArtifactController, FlowScheduleController, + OperatorController, EngineController, + ], + providers: [ + ProjectService, PartyService, ProjectPartyService, DatasourceService, + DatasetService, DatasetAuthService, FlowService, FlowRunService, + FlowStepRunService, RunEventService, ArtifactService, FlowScheduleService, + EngineRegistry, + ], + exports: [FlowRunService, EngineRegistry], +}) +export class SswflowModule {} diff --git a/src/backend/src/sys/authorize.controller.ts b/src/backend/src/sys/authorize.controller.ts new file mode 100644 index 0000000..4ac20c3 --- /dev/null +++ b/src/backend/src/sys/authorize.controller.ts @@ -0,0 +1,58 @@ +import { Body, Controller, Get, Param, Put, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { SysService } from './sys.service'; + +/** + * 统一授权 —— 契约对齐 JNPF:PUT /api/permission/Authority/Data/{objectId} + * body: { objectType: 'role', module: ['m1', 'm2', ...] } ← module 是**一维** String[] + * 依据:官方 AuthorizeDataUpForm.module 类型为 String[],AuthorizeServiceImpl.save + * 三处均用 Arrays.asList(form.getModule()) 展开;官方前端 MenuAuth.vue:139,144 + * 把 checked + halfChecked 合并成一个数组后赋值。 + * MVP 仅实现 module 一类(按钮/列/表单/数据范围待迁移补)。objectType 必须小写(JNPF 静默忽略大写)。 + */ +@Controller('api/permission/Authority') +export class AuthorizeController { + constructor( + private readonly svc: SysService, + private readonly auth: AuthService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + return null; + } + + /** + * 归一化 module:官方是一维数组。 + * 防御性兼容历史二维形态 [checked, halfChecked] —— 展平后同样能正确落库, + * 避免旧调用方(或按旧文档接的集成)出现"接口 200 但授权只进第一条"。 + */ + private normalizeModule(raw: any): string[] { + if (!Array.isArray(raw)) return []; + return (Array.isArray(raw[0]) ? (raw as any[][]).flat() : raw).filter( + (x) => typeof x === 'string' && x.length > 0, + ); + } + + @Put('Data/:objectId') + async save( + @Req() req: any, + @Param('objectId') objectId: string, + @Body() body: any, + ) { + const g = this.guard(req); + if (g) return g; + const moduleIds = this.normalizeModule(body?.module); + await this.svc.saveRoleModules(objectId, moduleIds); + return ActionResult.success(null); + } + + @Get('RoleModules') + async roleModules(@Req() req: any, @Query('roleId') roleId: string) { + const g = this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.roleModules(roleId)); + } +} diff --git a/src/backend/src/sys/base-authorize.entity.ts b/src/backend/src/sys/base-authorize.entity.ts new file mode 100644 index 0000000..a8b6d6d --- /dev/null +++ b/src/backend/src/sys/base-authorize.entity.ts @@ -0,0 +1,42 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 授权关系表 —— 列名逐字对齐官方 `base_authorize` DDL(`JNPF-PostgreSQL.sql:812`)。 + * 官方列:f_id / f_item_type / f_item_id / f_object_type / f_object_id / f_sort_code / + * f_creator_* / f_delete_* / f_tenant_id / f_org_id + * 七类 item_type(module/button/column/form/resource/system/standing)共用这一张表。 + * MVP 仅实现 item_type='module';其余类别的行结构已兼容,迁移只需补写入逻辑。 + */ +@Entity('base_authorize') +export class BaseAuthorizeEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + /** 'user' / 'role' / 'organize' / 'position' */ + @Column({ name: 'f_object_type', type: 'varchar', length: 50 }) + objectType!: string; + + @Column({ name: 'f_object_id', type: 'varchar', length: 50 }) + objectId!: string; + + /** 'module' / 'button' / 'column' / 'form' / 'resource' / 'system' / 'standing' */ + @Column({ name: 'f_item_type', type: 'varchar', length: 50 }) + itemType!: string; + + /** 指向 base_module / base_module_button / base_module_scheme … 的 f_id */ + @Column({ name: 'f_item_id', type: 'varchar', length: 50 }) + itemId!: string; + + /** 官方额外列:授权所属组织(数据范围用) */ + @Column({ name: 'f_org_id', type: 'varchar', length: 50, nullable: true }) + orgId?: string; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-module.entity.ts b/src/backend/src/sys/base-module.entity.ts new file mode 100644 index 0000000..4ab653d --- /dev/null +++ b/src/backend/src/sys/base-module.entity.ts @@ -0,0 +1,57 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 菜单表 —— 列名逐字对齐官方 `base_module` DDL(`JNPF-PostgreSQL.sql:2209`)。 + * + * ⚠️ 两个语义陷阱(官方 DDL 注释为准): + * 1. `f_type INTEGER` 才是**类型**:1-目录 2-页面 3-功能 4-字典 5-报表 6-大屏 7-外链 8-门户 9-流程 10-报表 11-回传 + * 2. `f_category VARCHAR(50)` 是**分类**(字符串),不是类型数字 + * —— MVP 早期把这两者写反了(用 category 存 1/2),已按官方 DDL 修正。 + * + * `f_url_address` 存**末段 key**(如 `system/User`):前端挂载组件用它, + * 后端菜单守卫剥类名后缀与之比对(jnpf-permission 第四节匹配规则)。 + */ +@Entity('base_module') +export class BaseModuleEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + @Column({ name: 'f_full_name', type: 'varchar', length: 200 }) + fullName!: string; + + /** 末段 key(`system/User`),守卫比对用 */ + @Column({ name: 'f_url_address', type: 'varchar', length: 500, nullable: true }) + urlAddress?: string; + + @Column({ name: 'f_parent_id', type: 'varchar', length: 50, default: '0' }) + parentId!: string; + + /** 官方 `f_type INTEGER`:1-目录 2-页面 3-功能 …(类型语义在这里,不是 category) */ + @Column({ name: 'f_type', type: 'int', default: 2 }) + type!: number; + + /** 官方 `f_category VARCHAR(50)`:分类(字符串) */ + @Column({ name: 'f_category', type: 'varchar', length: 50, nullable: true }) + category?: string; + + @Column({ name: 'f_en_code', type: 'varchar', length: 200, nullable: true }) + enCode?: string; + + @Column({ name: 'f_icon', type: 'varchar', length: 500, nullable: true }) + icon?: string; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_enabled_mark', type: 'int', default: 1 }) + enabledMark!: number; + + @Column({ name: 'f_creator_time', type: 'timestamptz', nullable: true }) + creatorTime?: Date; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-organize.entity.ts b/src/backend/src/sys/base-organize.entity.ts new file mode 100644 index 0000000..9a5ab6c --- /dev/null +++ b/src/backend/src/sys/base-organize.entity.ts @@ -0,0 +1,44 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 组织机构表 —— 列名逐字对齐官方 `base_organize` DDL(`JNPF-PostgreSQL.sql:3178`)。 + * 树形:`f_parent_id='0'` 为根。 + * ⚠️ 官方 `f_category` 是 **VARCHAR(50)**(机构分类),不是 int; + * 且官方 **没有 `f_type` 列**(`f_type` 是 base_module 的)——别和 base_module 混。 + */ +@Entity('base_organize') +export class BaseOrganizeEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + @Column({ name: 'f_full_name', type: 'varchar', length: 200 }) + fullName!: string; + + @Column({ name: 'f_parent_id', type: 'varchar', length: 50, default: '0' }) + parentId!: string; + + /** 官方 `f_category VARCHAR(50)`:机构分类 */ + @Column({ name: 'f_category', type: 'varchar', length: 50, nullable: true }) + category?: string; + + @Column({ name: 'f_en_code', type: 'varchar', length: 200, nullable: true }) + enCode?: string; + + @Column({ name: 'f_manager_id', type: 'varchar', length: 50, nullable: true }) + managerId?: string; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_enabled_mark', type: 'int', default: 1 }) + enabledMark!: number; + + @Column({ name: 'f_creator_time', type: 'timestamptz', nullable: true }) + creatorTime?: Date; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-role-relation.entity.ts b/src/backend/src/sys/base-role-relation.entity.ts new file mode 100644 index 0000000..58c1d60 --- /dev/null +++ b/src/backend/src/sys/base-role-relation.entity.ts @@ -0,0 +1,34 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 用户 ↔ 角色 —— 列名逐字对齐官方 `base_role_relation` DDL(`JNPF-PostgreSQL.sql:3729`)。 + * + * ⚠️ 官方列只有 `f_role_id / f_object_type / f_object_id`,**没有 `f_user_id`**: + * 用户 id 存在 **`f_object_id`**(配 `f_object_type='user'`)。 + * 按 `f_user_id` 查会永远返回空 → 误判"该用户没角色"。本实体严格照官方,迁移零改列名。 + */ +@Entity('base_role_relation') +export class BaseRoleRelationEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + /** 'user' / 'organize' / 'position'(四源合并的对象类型) */ + @Column({ name: 'f_object_type', type: 'varchar', length: 50 }) + objectType!: string; + + /** ⚠️ 当 `f_object_type='user'` 时,这里是 **userId**(官方就是这样存的) */ + @Column({ name: 'f_object_id', type: 'varchar', length: 50 }) + objectId!: string; + + @Column({ name: 'f_role_id', type: 'varchar', length: 50 }) + roleId!: string; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-role.entity.ts b/src/backend/src/sys/base-role.entity.ts new file mode 100644 index 0000000..0a96bef --- /dev/null +++ b/src/backend/src/sys/base-role.entity.ts @@ -0,0 +1,46 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 角色表 —— 列名逐字对齐官方 `base_role` DDL(`JNPF-PostgreSQL.sql:3686`)。 + * 官方列:f_id / f_full_name / f_en_code / f_type / f_property_json / f_global_mark / + * f_description / f_enabled_mark / f_sort_code / f_creator_* / f_delete_* / f_tenant_id / + * f_is_condition / f_condition_json + * MVP 只落实际用到的列,其余留位;列名与官方一致,ETL 不受影响。 + */ +@Entity('base_role') +export class BaseRoleEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + @Column({ name: 'f_full_name', type: 'varchar', length: 200 }) + fullName!: string; + + @Column({ name: 'f_en_code', type: 'varchar', length: 200, nullable: true }) + enCode?: string; + + /** 官方注释:角色类型 user / Organize / Position */ + @Column({ name: 'f_type', type: 'varchar', length: 50, nullable: true }) + type?: string; + + @Column({ name: 'f_description', type: 'varchar', length: 500, nullable: true }) + description?: string; + + /** 官方注释:有效标志(0-禁用,1-启用) */ + @Column({ name: 'f_enabled_mark', type: 'int', default: 1 }) + enabledMark!: number; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId?: string; + + @Column({ name: 'f_creator_time', type: 'timestamptz', nullable: true }) + creatorTime?: Date; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-user-relation.entity.ts b/src/backend/src/sys/base-user-relation.entity.ts new file mode 100644 index 0000000..32de7d6 --- /dev/null +++ b/src/backend/src/sys/base-user-relation.entity.ts @@ -0,0 +1,32 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 用户 ↔ 组织 / 岗位 —— 列名逐字对齐官方 `base_user_relation` DDL(`JNPF-PostgreSQL.sql:4707`)。 + * 与 `base_role_relation` 不同,这里**有** `f_user_id`(官方注释:'用户主键')。 + * 两个表列名相反是官方设计,**不要统一**——统一了迁移就要反向改回来。 + */ +@Entity('base_user_relation') +export class BaseUserRelationEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + /** 官方 `f_user_id`(本表才有;base_role_relation 里对应字段叫 f_object_id) */ + @Column({ name: 'f_user_id', type: 'varchar', length: 50 }) + userId!: string; + + /** 'organize' / 'position' */ + @Column({ name: 'f_object_type', type: 'varchar', length: 50 }) + objectType!: string; + + @Column({ name: 'f_object_id', type: 'varchar', length: 50 }) + objectId!: string; + + @Column({ name: 'f_sort_code', type: 'bigint', default: 0 }) + sortCode!: number; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/base-user.entity.ts b/src/backend/src/sys/base-user.entity.ts new file mode 100644 index 0000000..2e30b9d --- /dev/null +++ b/src/backend/src/sys/base-user.entity.ts @@ -0,0 +1,64 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +/** + * 用户表 —— 列名逐字对齐官方 `base_user` DDL + * (`jnpf-database/PostgreSQL/JNPF-PostgreSQL.sql:4479`,并由 `jnpf_db_init.sql` 的 + * `INSERT INTO base_user (f_id, f_account, f_real_name, ...)` 二次确证)。 + * + * ⚠️ `f_account` 与 `f_is_administrator` **都带 f_ 前缀**。 + * 易错点:写成不带前缀的 `account` / `is_administrator` 就与官方 DDL 不符, + * 以官方 DDL 为准(本文件即按 DDL 写)。 + * + * TS 属性名保留 `account` / `isAdministrator`:JNPF 的 JSON 字段就是这个 + * (Java 侧 `@TableField("f_account") private String account;`),所以 API 契约不受影响。 + * + * ⚠️ 官方 DDL 对 `f_account` **没有 UNIQUE 约束**(唯一约束只有 `PRIMARY KEY (f_id, f_tenant_id)`), + * 账号唯一性由应用层保证 —— MVP 同样不加 DB 唯一约束,否则软删用户会永久占用账号。 + * 官方 PK 是复合主键 `(f_id, f_tenant_id)`;MVP 单租户固定 `'0'`,故只用 `f_id` 作主键(不影响数据 ETL)。 + */ +@Entity('base_user') +export class BaseUserEntity { + @PrimaryColumn({ name: 'f_id', type: 'varchar', length: 50 }) + id!: string; + + /** 官方 `f_tenant_id VARCHAR(50) DEFAULT '0' NOT NULL`;单租户固定 '0' */ + @Column({ name: 'f_tenant_id', type: 'varchar', length: 50, default: '0' }) + tenantId!: string; + + /** 官方 `f_account`。唯一性由应用层校验(DDL 无 UNIQUE) */ + @Column({ name: 'f_account', type: 'varchar', length: 50 }) + account!: string; + + @Column({ name: 'f_real_name', type: 'varchar', length: 50, nullable: true }) + realName?: string; + + /** 存 md5(明文)(与登录 cipher 解出的值比对)。JNPF 真实用 md5(md5(raw)+secretkey),secretkey 列已留位待迁移补。 */ + @Column({ name: 'f_password', type: 'varchar', length: 50, nullable: true }) + password?: string; + + @Column({ name: 'f_secretkey', type: 'varchar', length: 50, nullable: true }) + secretkey?: string; + + /** 官方 `f_is_administrator INTEGER`:1=管理员,登录直接放行(四源合并前短路) */ + @Column({ name: 'f_is_administrator', type: 'int', default: 0 }) + isAdministrator!: number; + + /** 官方 `f_role_id TEXT`:用户直挂角色 id(JSON 数组串)。MVP 走 base_role_relation,本列留位待迁移补。 */ + @Column({ name: 'f_role_id', type: 'text', nullable: true }) + roleId?: string; + + @Column({ name: 'f_organize_id', type: 'varchar', length: 50, nullable: true }) + organizeId?: string; + + @Column({ name: 'f_creator_user_id', type: 'varchar', length: 50, nullable: true }) + creatorUserId?: string; + + @Column({ name: 'f_creator_time', type: 'timestamptz', nullable: true }) + creatorTime?: Date; + + @Column({ name: 'f_enabled_mark', type: 'int', default: 1 }) + enabledMark!: number; + + @Column({ name: 'f_delete_mark', type: 'int', default: 0 }) + deleteMark!: number; +} diff --git a/src/backend/src/sys/module.controller.ts b/src/backend/src/sys/module.controller.ts new file mode 100644 index 0000000..482dd2f --- /dev/null +++ b/src/backend/src/sys/module.controller.ts @@ -0,0 +1,54 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from './permission.service'; +import { SysService } from './sys.service'; + +/** 菜单管理(树形)。 */ +@Controller('api/ssw/sys/Module') +export class ModuleController { + constructor( + private readonly svc: SysService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any, key: string) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, key))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req, 'system/Module'); + if (g) return g; + return ActionResult.success(await this.svc.listModules()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req, 'system/Module'); + if (g) return g; + return ActionResult.success(await this.svc.saveModule(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req, 'system/Module'); + if (g) return g; + await this.svc.deleteModule(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sys/organize.controller.ts b/src/backend/src/sys/organize.controller.ts new file mode 100644 index 0000000..e5124c2 --- /dev/null +++ b/src/backend/src/sys/organize.controller.ts @@ -0,0 +1,54 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from './permission.service'; +import { SysService } from './sys.service'; + +/** 机构管理(树形)。 */ +@Controller('api/ssw/sys/Organize') +export class OrganizeController { + constructor( + private readonly svc: SysService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any, key: string) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, key))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req, 'system/Organize'); + if (g) return g; + return ActionResult.success(await this.svc.listOrganize()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req, 'system/Organize'); + if (g) return g; + return ActionResult.success(await this.svc.saveOrganize(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req, 'system/Organize'); + if (g) return g; + await this.svc.deleteOrganize(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/src/sys/permission.service.ts b/src/backend/src/sys/permission.service.ts new file mode 100644 index 0000000..5fca59f --- /dev/null +++ b/src/backend/src/sys/permission.service.ts @@ -0,0 +1,117 @@ +import { Injectable } from '@nestjs/common'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { BaseAuthorizeEntity } from './base-authorize.entity'; +import { BaseRoleRelationEntity } from './base-role-relation.entity'; +import { BaseUserRelationEntity } from './base-user-relation.entity'; +import { BaseModuleEntity } from './base-module.entity'; + +export interface MenuNode { + id: string; + fullName: string; + urlAddress?: string; + icon?: string; + parentId: string; + children: MenuNode[]; +} + +/** + * 权限解析 —— 复刻 jnpf-permission 技能的「四源合并 + 管理员短路」思路,但用 TS 直查 base_* 表。 + * MVP 仅实现 item_type='module'(菜单)一类;迁 JNPF 时整段删掉,由 SswPermissionGuard / SswDataScopeResolver 接管。 + * 表结构与字段名完全一致,所以迁移时这段代码是「翻译」不是「重设计」。 + */ +@Injectable() +export class PermissionService { + constructor( + @InjectRepository(BaseAuthorizeEntity) + private readonly authRepo: Repository, + @InjectRepository(BaseRoleRelationEntity) + private readonly roleRelRepo: Repository, + @InjectRepository(BaseUserRelationEntity) + private readonly userRelRepo: Repository, + @InjectRepository(BaseModuleEntity) + private readonly moduleRepo: Repository, + ) {} + + /** 四源合并:用户直授 + 角色 + 组织 + 岗位(对应 SswPermissionGuard 的四条分查) */ + async resolveUserModuleIds(userId: string): Promise> { + const ids = new Set(); + await this.addAuthorized(ids, 'user', userId); + + const roleRels = await this.roleRelRepo.find({ + where: { objectType: 'user', objectId: userId } as any, + }); + for (const r of roleRels) await this.addAuthorized(ids, 'role', r.roleId); + + const orgRels = await this.userRelRepo.find({ + where: { userId, objectType: 'organize' } as any, + }); + for (const o of orgRels) await this.addAuthorized(ids, 'organize', o.objectId); + + const posRels = await this.userRelRepo.find({ + where: { userId, objectType: 'position' } as any, + }); + for (const p of posRels) await this.addAuthorized(ids, 'position', p.objectId); + + return ids; + } + + private async addAuthorized( + ids: Set, + objectType: string, + objectId: string, + ) { + const rows = await this.authRepo.find({ + where: { objectType, objectId, itemType: 'module', deleteMark: 0 } as any, + }); + rows.forEach((r) => r.itemId && ids.add(r.itemId)); + } + + /** 菜单守卫:管理员短路放行;非管理员比对 base_authorize 的 module 授权。 */ + async hasModule(userId: string, isAdmin: number, moduleKey: string): Promise { + if (isAdmin === 1) return true; // 管理员短路(与 JNPF 一致) + const mod = await this.moduleRepo.findOne({ + where: { urlAddress: moduleKey, deleteMark: 0 } as any, + }); + if (!mod) return true; // 未映射到菜单 → 放行(对应 SswPermissionGuard 的 warn 路径) + const ids = await this.resolveUserModuleIds(userId); + return ids.has(mod.id); + } + + /** 当前用户可见菜单树(admin 看全部) */ + async buildMenuList(userId: string, isAdmin: number): Promise { + const all = await this.moduleRepo.find({ + where: { deleteMark: 0 } as any, + order: { sortCode: 'ASC' } as any, + }); + let visible = all; + if (isAdmin !== 1) { + const ids = await this.resolveUserModuleIds(userId); + visible = all.filter((m) => ids.has(m.id)); + } + return this.toTree(visible); + } + + private toTree(list: BaseModuleEntity[]): MenuNode[] { + const map = new Map(); + list.forEach((m) => + map.set(m.id, { + id: m.id, + fullName: m.fullName, + urlAddress: m.urlAddress, + icon: m.icon, + parentId: m.parentId || '0', + children: [], + }), + ); + const roots: MenuNode[] = []; + map.forEach((node) => { + if (node.parentId && node.parentId !== '0' && map.has(node.parentId)) { + map.get(node.parentId)!.children.push(node); + } else { + roots.push(node); + } + }); + return roots; + } +} diff --git a/src/backend/src/sys/role.controller.ts b/src/backend/src/sys/role.controller.ts new file mode 100644 index 0000000..3c5058f --- /dev/null +++ b/src/backend/src/sys/role.controller.ts @@ -0,0 +1,62 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from './permission.service'; +import { SysService } from './sys.service'; + +/** 角色管理 + 角色→菜单授权查询。 */ +@Controller('api/ssw/sys/Role') +export class RoleController { + constructor( + private readonly svc: SysService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any, key: string) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, key))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req, 'system/Role'); + if (g) return g; + return ActionResult.success(await this.svc.listRoles()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req, 'system/Role'); + if (g) return g; + return ActionResult.success(await this.svc.saveRole(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req, 'system/Role'); + if (g) return g; + await this.svc.deleteRole(id); + return ActionResult.success(null); + } + + /** 查某角色已授权的菜单 id 列表(给授权页回显) */ + @Get('Modules') + async modules(@Req() req: any, @Query('roleId') roleId: string) { + const g = this.guard(req); + if (g) return g; + return ActionResult.success(await this.svc.roleModules(roleId)); + } +} diff --git a/src/backend/src/sys/seed.service.ts b/src/backend/src/sys/seed.service.ts new file mode 100644 index 0000000..8a55d9b --- /dev/null +++ b/src/backend/src/sys/seed.service.ts @@ -0,0 +1,199 @@ +import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { randomUUID } from 'crypto'; +import { md5Hex } from '../common/cipher'; +import { BaseUserEntity } from './base-user.entity'; +import { BaseRoleEntity } from './base-role.entity'; +import { BaseModuleEntity } from './base-module.entity'; +import { BaseAuthorizeEntity } from './base-authorize.entity'; +import { BaseRoleRelationEntity } from './base-role-relation.entity'; + +/** + * 启动种子 —— 两段式(存量库演进不依赖「删库重建」): + * + * 1) ensureBase(**每次启动都跑**,幂等):按 enCode 补内置角色、按 urlAddress 补内置菜单、 + * 补齐 admin 角色对内置菜单的授权。只补缺项: + * - 不覆盖已有行的值(人工改名/调序会被保留); + * - 同 urlAddress 已有行(含 deleteMark=1 软删)不再复活——手动删除是显式决策。 + * 派生项目新增内置角色/菜单,直接往下面的 roles / menus 数组加条目,重启即回灌存量库。 + * 2) firstSeed(**仅空库跑一次**,users=0):admin/123456(f_is_administrator=1)+ 挂内置角色。 + * 角色/菜单/授权行本身已由 ensureBase 建出,firstSeed 不重复写。 + * + * 注意:perm-smoke.sh 从下方 menus 数组字面量动态计算期望菜单树—— + * 保持该数组的字段(id/fullName/urlAddress/parentId/sortCode)与字面量形态不变; + * 本注释块内刻意不复写「数组名=[」的字面量写法,以免脚本正则误匹配到注释。 + * + * 列的写入值刻意带上 `f_tenant_id='0'`:官方这些表的 PK 是 `(f_id, f_tenant_id)` 且 + * `f_tenant_id` 是 `NOT NULL DEFAULT '0'`,单租户下固定 '0'。 + */ + +// 内置角色(ensureBase 按 enCode 幂等去重) +const roles = [ + { id: 'role_admin', enCode: 'admin', fullName: '管理员', sortCode: 1 }, + { id: 'role_user', enCode: 'user', fullName: '使用者', sortCode: 2 }, +]; + +// 内置菜单(ensureBase 按 urlAddress 幂等去重) +// f_type:1-目录 2-页面(官方语义,不是 f_category) +const menus = [ + { id: 'm_sys', fullName: '系统管理', urlAddress: 'system', parentId: '0', type: 1, icon: 'setting', sortCode: 1, deleteMark: 0 }, + { id: 'm_user', fullName: '用户管理', urlAddress: 'system/User', parentId: 'm_sys', type: 2, sortCode: 2, deleteMark: 0 }, + { id: 'm_role', fullName: '角色管理', urlAddress: 'system/Role', parentId: 'm_sys', type: 2, sortCode: 3, deleteMark: 0 }, + { id: 'm_org', fullName: '机构管理', urlAddress: 'system/Organize', parentId: 'm_sys', type: 2, sortCode: 4, deleteMark: 0 }, + { id: 'm_menu', fullName: '菜单管理', urlAddress: 'system/Module', parentId: 'm_sys', type: 2, sortCode: 5, deleteMark: 0 }, + { id: 'm_demo', fullName: 'Demo 示例', urlAddress: 'demo-item', parentId: '0', type: 2, icon: 'app', sortCode: 6, deleteMark: 0 }, + { id: 'm_product', fullName: '产品管理', urlAddress: 'shop/Product', parentId: '0', type: 2, icon: 'app', sortCode: 7, deleteMark: 0 }, + { id: 'm_book', fullName: '图书超市', urlAddress: 'books/Book', parentId: '0', type: 2, icon: 'app', sortCode: 8, deleteMark: 0 }, + // 隐私计算编排(sswflow)—— 目录 + 12 个页面;urlAddress 与 App.tsx Route / controller MODULE_KEY 三处一致 + { id: 'm_sswflow', fullName: '隐私计算编排', urlAddress: 'sswflow', parentId: '0', type: 1, icon: 'app', sortCode: 9, deleteMark: 0 }, + { id: 'm_flow', fullName: '流程编排', urlAddress: 'sswflow/Flow', parentId: 'm_sswflow', type: 2, sortCode: 10, deleteMark: 0 }, + { id: 'm_flowrun', fullName: '运行监控', urlAddress: 'sswflow/FlowRun', parentId: 'm_sswflow', type: 2, sortCode: 11, deleteMark: 0 }, + { id: 'm_project', fullName: '协作项目', urlAddress: 'sswflow/Project', parentId: 'm_sswflow', type: 2, sortCode: 12, deleteMark: 0 }, + { id: 'm_party', fullName: '参与方', urlAddress: 'sswflow/Party', parentId: 'm_sswflow', type: 2, sortCode: 13, deleteMark: 0 }, + { id: 'm_projectparty', fullName: '项目成员', urlAddress: 'sswflow/ProjectParty', parentId: 'm_sswflow', type: 2, sortCode: 14, deleteMark: 0 }, + { id: 'm_datasource', fullName: '数据源', urlAddress: 'sswflow/Datasource', parentId: 'm_sswflow', type: 2, sortCode: 15, deleteMark: 0 }, + { id: 'm_dataset', fullName: '数据集', urlAddress: 'sswflow/Dataset', parentId: 'm_sswflow', type: 2, sortCode: 16, deleteMark: 0 }, + { id: 'm_datasetauth', fullName: '数据集授权', urlAddress: 'sswflow/DatasetAuth', parentId: 'm_sswflow', type: 2, sortCode: 17, deleteMark: 0 }, + { id: 'm_flowsteprun', fullName: '步骤运行', urlAddress: 'sswflow/FlowStepRun', parentId: 'm_sswflow', type: 2, sortCode: 18, deleteMark: 0 }, + { id: 'm_runevent', fullName: '运行事件', urlAddress: 'sswflow/RunEvent', parentId: 'm_sswflow', type: 2, sortCode: 19, deleteMark: 0 }, + { id: 'm_artifact', fullName: '计算产物', urlAddress: 'sswflow/Artifact', parentId: 'm_sswflow', type: 2, sortCode: 20, deleteMark: 0 }, + { id: 'm_flowschedule', fullName: '周期调度', urlAddress: 'sswflow/FlowSchedule', parentId: 'm_sswflow', type: 2, sortCode: 21, deleteMark: 0 }, + // 数据基础设施(设备注册 + 链上存证)—— 与隐私计算编排平级的两个兄弟模块 + { id: 'm_infra', fullName: '数据基础设施', urlAddress: 'sswinfra', parentId: '0', type: 1, icon: 'app', sortCode: 22, deleteMark: 0 }, + { id: 'm_device', fullName: '设备注册', urlAddress: 'sswdevice/Device', parentId: 'm_infra', type: 2, sortCode: 23, deleteMark: 0 }, + { id: 'm_chain', fullName: '链上存证', urlAddress: 'sswchain/ChainBlock', parentId: 'm_infra', type: 2, sortCode: 24, deleteMark: 0 }, +]; + +@Injectable() +export class SeedService implements OnModuleInit { + private readonly logger = new Logger('Seed'); + private readonly TENANT = '0'; + + constructor( + @InjectRepository(BaseUserEntity) + private readonly userRepo: Repository, + @InjectRepository(BaseRoleEntity) + private readonly roleRepo: Repository, + @InjectRepository(BaseModuleEntity) + private readonly moduleRepo: Repository, + @InjectRepository(BaseAuthorizeEntity) + private readonly authRepo: Repository, + @InjectRepository(BaseRoleRelationEntity) + private readonly roleRelRepo: Repository, + ) {} + + async onModuleInit() { + try { + await this.ensureBase(); + if ((await this.userRepo.count()) === 0) await this.firstSeed(); + } catch (e: any) { + this.logger.warn('seed skip: ' + e.message); + } + } + + /** 幂等回灌:内置角色/菜单/admin 授权,缺则补、已有不动(每次启动都跑) */ + private async ensureBase() { + const haveRoles = await this.roleRepo.find(); + const newRoles = roles.filter((r) => !haveRoles.some((h) => h.enCode === r.enCode)); + if (newRoles.length) { + await this.roleRepo.save( + newRoles.map((r) => ({ + id: r.id, + tenantId: this.TENANT, + fullName: r.fullName, + enCode: r.enCode, + type: 'user', + enabledMark: 1, + sortCode: r.sortCode, + deleteMark: 0, + })) as any, + ); + this.logger.log(`ensure: 补角色 ${newRoles.map((r) => r.enCode).join(', ')}`); + } + + const haveMenus = await this.moduleRepo.find(); // 含软删行:同 urlAddress 不复活 + const newMenus = menus.filter((m) => !haveMenus.some((h) => h.urlAddress === m.urlAddress)); + if (newMenus.length) { + await this.moduleRepo.save( + newMenus.map((m) => ({ ...m, tenantId: this.TENANT, enabledMark: 1 })) as any, + ); + this.logger.log(`ensure: 补菜单 ${newMenus.map((m) => m.urlAddress).join(', ')}`); + } + + // ★ 内置菜单的**显示名**对齐:只改「内置 urlAddress 且当前名与内置名不同」的行。 + // 显示名不是路由契约(urlAddress 才是),改它不影响权限/路由, + // 所以这里可以安全回灌 —— 否则「区块链浏览器」这种旧名会永远留在存量库里。 + // 仍然不动:软删行、人工新增的菜单、人工改过的 urlAddress。 + const renamed = haveMenus.filter((h) => { + if (h.deleteMark !== 0) return false; + const builtin = menus.find((m) => m.urlAddress === h.urlAddress); + return !!builtin && builtin.fullName !== h.fullName; + }); + if (renamed.length) { + for (const h of renamed) { + const builtin = menus.find((m) => m.urlAddress === h.urlAddress)!; + await this.moduleRepo.update({ id: h.id } as any, { fullName: builtin.fullName } as any); + } + this.logger.log(`ensure: 对齐内置菜单显示名 ${renamed.map((h) => h.urlAddress).join(', ')}`); + } + + // admin 角色应看到全部内置菜单(取库里的真实行 id——派生项目可能改过主键;跳过软删行) + const adminRole = await this.roleRepo.findOne({ where: { enCode: 'admin' } as any }); + if (adminRole) { + const dbMenus = await this.moduleRepo.find(); + const builtinLive = dbMenus.filter( + (m) => m.deleteMark === 0 && menus.some((b) => b.urlAddress === m.urlAddress), + ); + const authed = await this.authRepo.find({ + where: { objectType: 'role', objectId: adminRole.id, itemType: 'module' } as any, + }); + const authedIds = new Set(authed.map((a) => a.itemId)); + const need = builtinLive.filter((m) => !authedIds.has(m.id)); + if (need.length) { + await this.authRepo.save( + need.map((m) => ({ + id: randomUUID(), + tenantId: this.TENANT, + objectType: 'role', + objectId: adminRole.id, + itemType: 'module', + itemId: m.id, + sortCode: 0, + deleteMark: 0, + })) as any, + ); + this.logger.log(`ensure: 补 admin 角色菜单授权 ${need.length} 条`); + } + } + } + + /** 首建(仅空库):admin 账号 + 挂内置角色(roleId 用内置常量,与 ensureBase 建的角色一致) */ + private async firstSeed() { + await this.userRepo.save({ + id: randomUUID(), + tenantId: this.TENANT, + account: 'admin', + realName: '管理员', + password: md5Hex('123456'), + isAdministrator: 1, + organizeId: '0', + creatorUserId: 'admin', + creatorTime: new Date(), + enabledMark: 1, + deleteMark: 0, + } as any); + + await this.roleRelRepo.save({ + id: randomUUID(), + tenantId: this.TENANT, + objectType: 'user', + objectId: 'admin', + roleId: 'role_admin', + sortCode: 0, + deleteMark: 0, + } as any); + + this.logger.log('first seed: admin/123456 已创建并挂内置角色'); + } +} diff --git a/src/backend/src/sys/sys.module.ts b/src/backend/src/sys/sys.module.ts new file mode 100644 index 0000000..83088cd --- /dev/null +++ b/src/backend/src/sys/sys.module.ts @@ -0,0 +1,43 @@ +import { Module, forwardRef } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { BaseUserEntity } from './base-user.entity'; +import { BaseRoleEntity } from './base-role.entity'; +import { BaseOrganizeEntity } from './base-organize.entity'; +import { BaseRoleRelationEntity } from './base-role-relation.entity'; +import { BaseUserRelationEntity } from './base-user-relation.entity'; +import { BaseModuleEntity } from './base-module.entity'; +import { BaseAuthorizeEntity } from './base-authorize.entity'; +import { PermissionService } from './permission.service'; +import { SysService } from './sys.service'; +import { SeedService } from './seed.service'; +import { UserController } from './user.controller'; +import { RoleController } from './role.controller'; +import { OrganizeController } from './organize.controller'; +import { ModuleController } from './module.controller'; +import { AuthorizeController } from './authorize.controller'; +import { AuthModule } from '../auth/auth.module'; + +@Module({ + imports: [ + forwardRef(() => AuthModule), + TypeOrmModule.forFeature([ + BaseUserEntity, + BaseRoleEntity, + BaseOrganizeEntity, + BaseRoleRelationEntity, + BaseUserRelationEntity, + BaseModuleEntity, + BaseAuthorizeEntity, + ]), + ], + controllers: [ + UserController, + RoleController, + OrganizeController, + ModuleController, + AuthorizeController, + ], + providers: [SysService, PermissionService, SeedService], + exports: [PermissionService, SysService], +}) +export class SysModule {} diff --git a/src/backend/src/sys/sys.service.ts b/src/backend/src/sys/sys.service.ts new file mode 100644 index 0000000..fd852e4 --- /dev/null +++ b/src/backend/src/sys/sys.service.ts @@ -0,0 +1,300 @@ +import { Injectable } from '@nestjs/common'; +import { randomUUID } from 'crypto'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; +import { md5Hex } from '../common/cipher'; +import { BizException } from '../common/business.exception'; +import { BaseUserEntity } from './base-user.entity'; +import { BaseRoleEntity } from './base-role.entity'; +import { BaseOrganizeEntity } from './base-organize.entity'; +import { BaseModuleEntity } from './base-module.entity'; +import { BaseAuthorizeEntity } from './base-authorize.entity'; +import { BaseRoleRelationEntity } from './base-role-relation.entity'; + +/** + * 系统管理(用户/角色/机构/菜单/授权)CRUD —— 表/列名逐字对齐官方 `base_*` DDL + * (`~/desktop/workspace/jnpf/jnpf-database/PostgreSQL/JNPF-PostgreSQL.sql`)。 + * + * 业务校验失败一律抛 BizException(400),由 ActionResultFilter 转成 ActionResult, + * 与官方 ResultExceptionHand 行为一致(官方对应 DataException / ImportException)。 + * + * MVP 不实现 JNPF 的低代码引擎;迁 JNPF 时本 Service 删掉,由 jnpf-common-all 的 SuperServiceImpl 接管。 + */ +@Injectable() +export class SysService { + constructor( + @InjectRepository(BaseUserEntity) + private readonly userRepo: Repository, + @InjectRepository(BaseRoleEntity) + private readonly roleRepo: Repository, + @InjectRepository(BaseOrganizeEntity) + private readonly orgRepo: Repository, + @InjectRepository(BaseModuleEntity) + private readonly moduleRepo: Repository, + @InjectRepository(BaseAuthorizeEntity) + private readonly authRepo: Repository, + @InjectRepository(BaseRoleRelationEntity) + private readonly roleRelRepo: Repository, + ) {} + + // ---------- User ---------- + async listUsers() { + const users = await this.userRepo.find({ + where: { deleteMark: 0 } as any, + order: { creatorTime: 'DESC' } as any, + }); + const rels = await this.roleRelRepo.find({ where: { objectType: 'user' } as any }); + const roles = await this.roleRepo.find({ where: { deleteMark: 0 } as any }); + const roleName = new Map(roles.map((r) => [r.id, r.fullName])); + return users.map((u) => { + const roleIds = rels.filter((r) => r.objectId === u.id).map((r) => r.roleId); + const { password, ...rest } = u as any; + return { + ...rest, + roleIds, + roleNames: roleIds.map((id) => roleName.get(id)).filter(Boolean), + }; + }); + } + + async saveUser(dto: any) { + if (!dto.account) throw new BizException('账号不能为空'); + + // 官方 DDL 对 f_account 没有 UNIQUE 约束,唯一性由应用层保证。 + // 只比未删除的用户 -> 软删掉的账号可以被重新启用(这也是官方不带 DB 唯一约束的原因)。 + const dup = await this.userRepo.findOne({ + where: { account: dto.account, deleteMark: 0 } as any, + }); + + if (!dto.id) { + if (dup) throw new BizException(`账号已存在:${dto.account}`); + + const ent = this.userRepo.create({ + id: randomUUID(), + tenantId: '0', + account: dto.account, + realName: dto.realName, + password: dto.password ? md5Hex(dto.password) : md5Hex('123456'), + isAdministrator: dto.isAdministrator ? 1 : 0, + organizeId: dto.organizeId || '0', + creatorUserId: 'admin', + creatorTime: new Date(), + enabledMark: 1, + deleteMark: 0, + } as any); + const saved = (await this.userRepo.save(ent)) as unknown as BaseUserEntity; + if (Array.isArray(dto.roleIds)) await this.setUserRoles(saved.id, dto.roleIds); + return saved; + } + + const existing = await this.userRepo.findOne({ where: { id: dto.id } as any }); + if (!existing) throw new BizException('用户不存在'); + if (dup && dup.id !== dto.id) throw new BizException(`账号已存在:${dto.account}`); + + Object.assign(existing, { + account: dto.account, + realName: dto.realName, + isAdministrator: dto.isAdministrator ? 1 : 0, + organizeId: dto.organizeId || '0', + } as any); + if (dto.password) existing.password = md5Hex(dto.password); + const saved = await this.userRepo.save(existing); + if (Array.isArray(dto.roleIds)) await this.setUserRoles(saved.id, dto.roleIds); + return saved; + } + + async setUserRoles(userId: string, roleIds: string[]) { + await this.roleRelRepo.delete({ objectType: 'user', objectId: userId } as any); + if (roleIds.length) { + await this.roleRelRepo.save( + roleIds.map((rid) => ({ + id: randomUUID(), + tenantId: '0', + objectType: 'user', + objectId: userId, + roleId: rid, + sortCode: 0, + deleteMark: 0, + })) as any, + ); + } + } + + async deleteUser(id: string) { + await this.userRepo.update({ id } as any, { deleteMark: 1 } as any); + await this.roleRelRepo.delete({ objectType: 'user', objectId: id } as any); + } + + // ---------- Role ---------- + async listRoles() { + return this.roleRepo.find({ + where: { deleteMark: 0 } as any, + order: { sortCode: 'ASC' } as any, + }); + } + + async saveRole(dto: any) { + if (!dto.fullName) throw new BizException('角色名称不能为空'); + + if (!dto.id) { + const dup = await this.roleRepo.findOne({ + where: { enCode: dto.enCode, deleteMark: 0 } as any, + }); + if (dup) throw new BizException(`角色编码已存在:${dto.enCode}`); + + return this.roleRepo.save({ + id: randomUUID(), + tenantId: '0', + fullName: dto.fullName, + enCode: dto.enCode, + type: dto.type ?? 'user', + description: dto.description, + enabledMark: 1, + sortCode: dto.sortCode ?? 0, + creatorUserId: 'admin', + creatorTime: new Date(), + deleteMark: 0, + } as any); + } + const ex = await this.roleRepo.findOne({ where: { id: dto.id } as any }); + if (!ex) throw new BizException('角色不存在'); + Object.assign(ex, { + fullName: dto.fullName, + enCode: dto.enCode, + type: dto.type ?? ex.type, + description: dto.description, + } as any); + return this.roleRepo.save(ex); + } + + async deleteRole(id: string) { + await this.roleRepo.update({ id } as any, { deleteMark: 1 } as any); + await this.authRepo.update( + { objectType: 'role', objectId: id } as any, + { deleteMark: 1 } as any, + ); + await this.roleRelRepo.delete({ roleId: id } as any); + } + + async roleModules(roleId: string) { + const rows = await this.authRepo.find({ + where: { objectType: 'role', itemType: 'module', objectId: roleId, deleteMark: 0 } as any, + }); + return rows.map((r) => r.itemId); + } + + /** 写角色→菜单授权(清旧+插新,item_type='module')。 */ + async saveRoleModules(roleId: string, moduleIds: string[]) { + await this.authRepo.update( + { objectType: 'role', itemType: 'module', objectId: roleId } as any, + { deleteMark: 1 } as any, + ); + if (moduleIds.length) { + await this.authRepo.save( + moduleIds.map((mid) => ({ + id: randomUUID(), + tenantId: '0', + objectType: 'role', + objectId: roleId, + itemType: 'module', + itemId: mid, + sortCode: 0, + deleteMark: 0, + })) as any, + ); + } + } + + // ---------- Organize ---------- + async listOrganize() { + return this.orgRepo.find({ + where: { deleteMark: 0 } as any, + order: { sortCode: 'ASC' } as any, + }); + } + + async saveOrganize(dto: any) { + if (!dto.fullName) throw new BizException('机构名称不能为空'); + + if (!dto.id) { + return this.orgRepo.save({ + id: randomUUID(), + tenantId: '0', + fullName: dto.fullName, + parentId: dto.parentId || '0', + category: dto.category ?? null, + sortCode: dto.sortCode ?? 0, + enabledMark: 1, + creatorTime: new Date(), + deleteMark: 0, + } as any); + } + const ex = await this.orgRepo.findOne({ where: { id: dto.id } as any }); + if (!ex) throw new BizException('机构不存在'); + Object.assign(ex, { + fullName: dto.fullName, + parentId: dto.parentId || '0', + category: dto.category ?? ex.category, + } as any); + return this.orgRepo.save(ex); + } + + async deleteOrganize(id: string) { + const children = await this.orgRepo.find({ + where: { parentId: id, deleteMark: 0 } as any, + }); + if (children.length) throw new BizException('该机构下还有子机构,先删除子机构'); + await this.orgRepo.update({ id } as any, { deleteMark: 1 } as any); + } + + // ---------- Module ---------- + async listModules() { + return this.moduleRepo.find({ + where: { deleteMark: 0 } as any, + order: { sortCode: 'ASC' } as any, + }); + } + + async saveModule(dto: any) { + if (!dto.fullName) throw new BizException('菜单名称不能为空'); + + // 官方语义:f_type INTEGER (1-目录 2-页面 3-功能 …);f_category 是 VARCHAR 分类。 + // 早期 MVP 把两者写反了(用 category 存 1/2),此处按官方 DDL 修正。 + if (!dto.id) { + return this.moduleRepo.save({ + id: randomUUID(), + tenantId: '0', + fullName: dto.fullName, + urlAddress: dto.urlAddress, + parentId: dto.parentId || '0', + type: dto.type ?? 2, + category: dto.category ?? null, + icon: dto.icon, + sortCode: dto.sortCode ?? 0, + enabledMark: 1, + creatorTime: new Date(), + deleteMark: 0, + } as any); + } + const ex = await this.moduleRepo.findOne({ where: { id: dto.id } as any }); + if (!ex) throw new BizException('菜单不存在'); + Object.assign(ex, { + fullName: dto.fullName, + urlAddress: dto.urlAddress, + parentId: dto.parentId || '0', + type: dto.type ?? ex.type, + category: dto.category ?? ex.category, + icon: dto.icon, + sortCode: dto.sortCode ?? 0, + } as any); + return this.moduleRepo.save(ex); + } + + async deleteModule(id: string) { + await this.moduleRepo.update({ id } as any, { deleteMark: 1 } as any); + await this.authRepo.update( + { itemType: 'module', itemId: id } as any, + { deleteMark: 1 } as any, + ); + } +} diff --git a/src/backend/src/sys/user.controller.ts b/src/backend/src/sys/user.controller.ts new file mode 100644 index 0000000..62930bf --- /dev/null +++ b/src/backend/src/sys/user.controller.ts @@ -0,0 +1,54 @@ +import { Body, Controller, Delete, Get, Post, Query, Req } from '@nestjs/common'; +import { ActionResult } from '../common/action-result'; +import { AuthService } from '../auth/auth.service'; +import { PermissionService } from './permission.service'; +import { SysService } from './sys.service'; + +/** 用户管理 —— 端点对齐 JNPF:GET/POST /api/ssw/sys/User/{List,Save} + DELETE /Delete?id= */ +@Controller('api/ssw/sys/User') +export class UserController { + constructor( + private readonly svc: SysService, + private readonly auth: AuthService, + private readonly perm: PermissionService, + ) {} + + private guard(req: any) { + const u = this.auth.resolve(req.headers['authorization']); + if (!u) return ActionResult.fail(600, '未登录'); + (req as any).user = u; + return null; + } + + private async guardModule(req: any, key: string) { + const g = this.guard(req); + if (g) return g; + const u = (req as any).user; + if (!(await this.perm.hasModule(u.userId, u.isAdmin, key))) { + return ActionResult.fail(403, '无菜单权限'); + } + return null; + } + + @Get('List') + async list(@Req() req: any) { + const g = await this.guardModule(req, 'system/User'); + if (g) return g; + return ActionResult.success(await this.svc.listUsers()); + } + + @Post('Save') + async save(@Req() req: any, @Body() body: any) { + const g = await this.guardModule(req, 'system/User'); + if (g) return g; + return ActionResult.success(await this.svc.saveUser(body)); + } + + @Delete('Delete') + async remove(@Req() req: any, @Query('id') id: string) { + const g = await this.guardModule(req, 'system/User'); + if (g) return g; + await this.svc.deleteUser(id); + return ActionResult.success(null); + } +} diff --git a/src/backend/tsconfig.build.json b/src/backend/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/src/backend/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/src/backend/tsconfig.json b/src/backend/tsconfig.json new file mode 100644 index 0000000..f0c8bca --- /dev/null +++ b/src/backend/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false, + "esModuleInterop": true + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "dist", "*.spec.ts", "vitest.config.ts", "test", "../tests/**"] +} diff --git a/src/frontend/index.html b/src/frontend/index.html new file mode 100644 index 0000000..22e90a6 --- /dev/null +++ b/src/frontend/index.html @@ -0,0 +1,12 @@ + + + + + + SSW JNPF Lite · React MVP + + +
+ + + diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json new file mode 100644 index 0000000..b180555 --- /dev/null +++ b/src/frontend/package-lock.json @@ -0,0 +1,2355 @@ +{ + "name": "ssw-jnpf-lite-react-frontend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ssw-jnpf-lite-react-frontend", + "version": "0.1.0", + "dependencies": { + "@xyflow/react": "^12.12.1", + "axios": "^1.7.0", + "crypto-js": "^4.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-router-dom": "^6.26.0" + }, + "devDependencies": { + "@types/crypto-js": "^4.2.2", + "@types/react": "^18.3.0", + "@types/react-dom": "^18.3.0", + "@vitejs/plugin-react": "^4.3.0", + "typescript": "^5.4.0", + "vite": "^5.2.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmmirror.com/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.29.7.tgz", + "integrity": "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.29.7.tgz", + "integrity": "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmmirror.com/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.8", + "resolved": "https://registry.npmmirror.com/@babel/traverse/-/traverse-7.29.8.tgz", + "integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.8", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmmirror.com/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmmirror.com/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@remix-run/router": { + "version": "1.23.4", + "resolved": "https://registry.npmmirror.com/@remix-run/router/-/router-1.23.4.tgz", + "integrity": "sha512-q7j5geK7xs3UJSdm9/iytUNclBnLmYx1EnSeCFXHPeutdqgIMeFeHtUZgS3EhlKxdBEAu8OwtJCwmLrEzpSs7Q==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.27", + "resolved": "https://registry.npmmirror.com/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", + "integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.3.tgz", + "integrity": "sha512-w3Jnvi1ocaVm/c7yVPpfB98XeSRBMyzp6njL5MVVbGyXjpmUkN+s6Hp4t0PqhGCCaI1ZHMKXt/w0lA1RCaLVcw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.3.tgz", + "integrity": "sha512-uI/ESiaIbbRYAEhzy8PCUWDp1hB0bjAqM06mW9flOoNO4Q8DQpeoREhBR5Hegfl+wpXiguyJv6XSPzEN7OxyHQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.3.tgz", + "integrity": "sha512-oxhrd1jmXLwWZ83eQYDXxuqRdkqkzrjR3JobKeuUyfdNZo11FuQIvqEOZhyIT7OBHxXoGslDDjN0cQcM6T0TqQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.3.tgz", + "integrity": "sha512-7/YiIMghVE8DrxKvNdorAaJVdriOFgOIpdStnPx8ppx5zfTwC3jBCSEAIzB7JD5404m65THl6H93UTTVUvypmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.3.tgz", + "integrity": "sha512-GXFZRRoMAytaI5z6N3Zhfw0WL18Q0M8r95D5hlC4GqE/lGk8pbSJNUBoOWDfbm6dTciqHj2nU87tI5f6XhQiOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.3.tgz", + "integrity": "sha512-77W+8X3ddYgPxUpB8nZFQs2Mq+wc4HVlcSRtApXLjYBcnPMkttrSnU8VwKQjeWYhMsITHFs5cWBQ8vz1Q+5RHQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.3.tgz", + "integrity": "sha512-FVkwK+iUC+mq+GipVK46rRVticfAPtvPUNlqlGXUDxdVk/UGjQiiiUVPUrEXdSpU2ufU0XxLGyTqDtBidDOVmg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.3.tgz", + "integrity": "sha512-+aGU1t3398yQOVj1Bz8o3e+KtswxAPvO+mtxtNdfXYMkXIHu7XhhkCD7/DEH9q8tF8uhDnMWvfpUKI8y1sZJsg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.3.tgz", + "integrity": "sha512-cR0kjpRXR2KJ2oQK8E2KTPtphs+b9hZ8IhTZubNryt/RsqgdOZBQ2Zq0q5UedtiIi0rs3jVhJh55RE1ZHUVGUA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.3.tgz", + "integrity": "sha512-y1RYi4Q3/9ByVWSSt9kX2ustE0B7kFYbJ6zZdVZVyqopZs3yhCTwRfrjIX4vezUJInma/Gs6BOFDJg7yZmJ0IQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.3.tgz", + "integrity": "sha512-DNhEA5viIj3Z5bZLE4z4oV8N5ozWqDwyt7T6KG7VdLDJ0nW+rNOYlphBl4/3HQkK75qipPLsVOfStHHOwN9WSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.3.tgz", + "integrity": "sha512-17gQCqrIpXBX2Cmi9/TygnVOqGbzsba/iaqcYSL8FY7lNugg+7AiYNs5c5nKWD+NRQha36Sa0CqkJqH4XVHwnQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.3.tgz", + "integrity": "sha512-6LwVnZRIyINpdku/yOcI8Tm9YqLmhHK5emmlOOnW9tO0SYEm1FmKPcsSAGp0NBlqR2P04xaND4jvN6sTHqhq8A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.3.tgz", + "integrity": "sha512-xMUqkTXlEUtI/p5AAukMwBRr1enU3efsTeF+bskeFfk8t1C9rcC8sLREcZXmTfAXEbvRdJVSonVJez3TMlbR3w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.3.tgz", + "integrity": "sha512-S3E94co9F9WRRqEaUoQZ38K1gCz6KiM+nL7/3ijq7fDGF3OznjS5TasgYITlvl27GQKtu4lOAOsr5MFwkijvOA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.3.tgz", + "integrity": "sha512-1QtRDwG42x5BJI3s9mxu5rEjDnfbSnk20HQ9/ylTAYnSwYwxMVb+Vgu34wzzTQ7ogqBybebgQNUDAvZVQ38DbA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.3.tgz", + "integrity": "sha512-BQhejF6ZXOpxbngiNTP12GCGQeaDVL2QXGeBVViKIYzFHM5RKxTxwUMB1fr1BeNFphFMpnRqC5QSXFSa4z6UQw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.3.tgz", + "integrity": "sha512-SXagRwnI2Wlwlitllu59UK/nGVbD1CKPcNqDplHwIC4BqJcpXFjD32d1R/RbuISa95HdQrZM3/7v4bKiowFaLA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.3.tgz", + "integrity": "sha512-2IPozoEALRCziGqE8O9KMK60PMu5TS1huv4fwoeCexj+WjmcwFtX9CTOVbfXCUqcELAubEwRFPYlzb/WvwY2HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.3.tgz", + "integrity": "sha512-AoxqosUHT9IX54hFn2TiN6A7d6ZKTtE6pd2bqWtqkkNJ6HJGaU6FRouGX8L1O7R/ZwsnCnpQrHzb4pDEx+UHRQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.3.tgz", + "integrity": "sha512-d+CaftKgmkFBzCwezMqqy1d0QNNYugqLCMcYVQWBy5SS2YfeMP8Q8ripkgx9O8IyBXXLHrJ+aaCV4U96usv6Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.3.tgz", + "integrity": "sha512-xXlDF6nR1eOuXbdDy5Hl5fmtY7teUDevF/k0O7IPoZe4Tpmdv+lgdE5JRsnhQtt37ql9P0VF2kAN9a0OCZdo+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.3.tgz", + "integrity": "sha512-YtXAgLN+JP7Ay6qG3eWhc7IHMQPzLc8r3uvhAvlJIoCz/4Q32+Bl9Fmnywidh8v1GOIMmymjovfqY9ETAtysvA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.3.tgz", + "integrity": "sha512-WuWtSJRNo549vzcfZyEgfqb6zeSgn1F+UE5kQ+BCjzz0W4MGCjntUHkZVc1VRuAM7+ULaSyhiPxD1spyewFvkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.3.tgz", + "integrity": "sha512-+lIKX7O0+IGe7WuhATaAMMeT7B76vfhXH/l9wLQL+nvyhbw2ohYCKIdWL56JfDu75CWt5oKRP4QFH/jkMtBquA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmmirror.com/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmmirror.com/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmmirror.com/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmmirror.com/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/crypto-js": { + "version": "4.2.2", + "resolved": "https://registry.npmmirror.com/@types/crypto-js/-/crypto-js-4.2.2.tgz", + "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-color": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/@types/d3-color/-/d3-color-3.1.3.tgz", + "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", + "license": "MIT" + }, + "node_modules/@types/d3-drag": { + "version": "3.0.7", + "resolved": "https://registry.npmmirror.com/@types/d3-drag/-/d3-drag-3.0.7.tgz", + "integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-interpolate": { + "version": "3.0.4", + "resolved": "https://registry.npmmirror.com/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", + "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", + "license": "MIT", + "dependencies": { + "@types/d3-color": "*" + } + }, + "node_modules/@types/d3-selection": { + "version": "3.0.12", + "resolved": "https://registry.npmmirror.com/@types/d3-selection/-/d3-selection-3.0.12.tgz", + "integrity": "sha512-Qe/KWYhEiIIxGs7HrAAjMfShxKldx19SJtr5zu53f3afPsdZNz7HHtdTLXo/kqeiWNXVycI24kSnfzBYkTzpgw==", + "license": "MIT" + }, + "node_modules/@types/d3-transition": { + "version": "3.0.9", + "resolved": "https://registry.npmmirror.com/@types/d3-transition/-/d3-transition-3.0.9.tgz", + "integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-zoom": { + "version": "3.0.9", + "resolved": "https://registry.npmmirror.com/@types/d3-zoom/-/d3-zoom-3.0.9.tgz", + "integrity": "sha512-0sE1406XBYJGiqD3AusTl9ZqC//2mIXix51tbom25gDCA8ri4xnSZg28CaSE8Srl6FClqABUKfsn0qghgdepMA==", + "license": "MIT", + "dependencies": { + "@types/d3-interpolate": "*", + "@types/d3-selection": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/prop-types": { + "version": "15.7.15", + "resolved": "https://registry.npmmirror.com/@types/prop-types/-/prop-types-15.7.15.tgz", + "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.3.31", + "resolved": "https://registry.npmmirror.com/@types/react/-/react-18.3.31.tgz", + "integrity": "sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.3.7", + "resolved": "https://registry.npmmirror.com/@types/react-dom/-/react-dom-18.3.7.tgz", + "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", + "devOptional": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^18.0.0" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "4.7.0", + "resolved": "https://registry.npmmirror.com/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz", + "integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.28.0", + "@babel/plugin-transform-react-jsx-self": "^7.27.1", + "@babel/plugin-transform-react-jsx-source": "^7.27.1", + "@rolldown/pluginutils": "1.0.0-beta.27", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.17.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" + } + }, + "node_modules/@xyflow/react": { + "version": "12.12.1", + "resolved": "https://registry.npmmirror.com/@xyflow/react/-/react-12.12.1.tgz", + "integrity": "sha512-g41OHmP+GL5wDBQKpgYt8AF6RlB4CrABtiStXhCMqdItK6gPdSpsuDk8V0YtdyvIvMPTjDJvkuLkz0JbSYu5Cw==", + "license": "MIT", + "dependencies": { + "@xyflow/system": "0.0.84", + "classcat": "^5.0.3", + "zustand": "^4.4.0" + }, + "peerDependencies": { + "@types/react": ">=17", + "@types/react-dom": ">=17", + "react": ">=17", + "react-dom": ">=17" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@xyflow/system": { + "version": "0.0.84", + "resolved": "https://registry.npmmirror.com/@xyflow/system/-/system-0.0.84.tgz", + "integrity": "sha512-96zfGFjH3oZ3T0MRdH4gJ0SlXuCIxbBuHVevZ4xry5UTxqjzjt010+LRdholgepq7jhrcaz1JNtzrETscwnkEA==", + "license": "MIT", + "dependencies": { + "@types/d3-drag": "^3.0.7", + "@types/d3-interpolate": "^3.0.4", + "@types/d3-selection": "^3.0.10", + "@types/d3-transition": "^3.0.8", + "@types/d3-zoom": "^3.0.8", + "d3-drag": "^3.0.0", + "d3-interpolate": "^3.0.1", + "d3-selection": "^3.0.0", + "d3-zoom": "^3.0.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmmirror.com/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.20.0", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.6", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.24", + "resolved": "https://registry.npmmirror.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.24.tgz", + "integrity": "sha512-hYrgxie335U08WqICoGqKRzV1HFXv6zdxwJE4ekCb80CM9a0SVVsN4QPwT67RraRo+9h8IATk6uxHJw7QSkdOg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/browserslist": { + "version": "4.29.0", + "resolved": "https://registry.npmmirror.com/browserslist/-/browserslist-4.29.0.tgz", + "integrity": "sha512-3GSvyjvDI4Dur1Meg2BekJquu5uF+9R9a1+5M1Mde192eZoXbeXjzgOsgqPS2V8D5wrrip0gR5Hf/GhWQ9ZzaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.23", + "caniuse-lite": "^1.0.30001810", + "electron-to-chromium": "^1.5.427", + "node-releases": "^2.0.55", + "update-browserslist-db": "^1.3.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/classcat": { + "version": "5.0.5", + "resolved": "https://registry.npmmirror.com/classcat/-/classcat-5.0.5.tgz", + "integrity": "sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==", + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.", + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/d3-color": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/d3-color/-/d3-color-3.1.1.tgz", + "integrity": "sha512-lfab8x0Bj0UO7SNsY8dZSbNIA6ipbkE3X0NG9nqjCu6CfCHZseuDnOSJY7hidKrjpP++i1M2qT+FlAdPKYRilA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/d3-dispatch/-/d3-dispatch-3.0.2.tgz", + "integrity": "sha512-sAzH4Y4nsLo8eSqw5jKiZt+LU2wZmL/qS+OkxQGjhwazB/D7TY34R/QK1eshfGr7cZEKymKZ/Haem7m+lu98Sg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/d3-drag/-/d3-drag-3.0.1.tgz", + "integrity": "sha512-OWeoayCq8J69hUIjvL+Mb6Q6Oaj/fyHV5XaXByEUAG+JUjIfTGDnk3qGpcXrD3VmQ3BSV96fcbM6fqq7C0tbPA==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/d3-ease/-/d3-ease-3.0.2.tgz", + "integrity": "sha512-B5znKqRmKROAN4oHWQ50W/qisVjA9GXh2WMsVKdFVp4DxWmcrOsweqgUOUVsv5th96kwaZlokU6SlV4J3gak1w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/d3-interpolate/-/d3-interpolate-3.0.2.tgz", + "integrity": "sha512-IRzGU62DtxhvsnSTWMQIdnoZ6gA+BCWwBon1EJI6SjoN595799b6z/QRBzXfFhE8iupUPp3042yBNo0STPqnzQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.1.tgz", + "integrity": "sha512-ODSf35vqCrlCfp7hrm0eZjvOosSXSYLjqvIlhMBV9q9VOx7EBJG6pc+uXBswEZNJgCGJ+qnKYcWutbZDIxe/Xg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/d3-timer/-/d3-timer-3.0.2.tgz", + "integrity": "sha512-1Il1aliroVSErrv5aulRBxAY+7+DnaoLIWGd1C6SsBTWDeobWiP/V69vwb8vT6abR1kKwaNe1196pmaQ1fK90A==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.2", + "resolved": "https://registry.npmmirror.com/d3-transition/-/d3-transition-3.0.2.tgz", + "integrity": "sha512-RcjCsdFgyFoDB+QXLC5m60ZkTN0k9zH+ovoLlTdJnDS1AbfbcuowiM4pCKSTOclNibS4f4J4cbv2m7O7y8NTOQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/d3-zoom/-/d3-zoom-3.0.1.tgz", + "integrity": "sha512-kfjD3BDQu/FOatpZ6JdMSyIoDwTxIpI29ySTI2J5ZlDaH1WbuJGQJ2Q9oJkWTEZEW98j6idezoomSD3Cn2zwiw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.430", + "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz", + "integrity": "sha512-e1QEj72Y4zd8RlNZVmoTg+iCOSVwpk05IOiiQwdrkwCSVlZfPthevErhE+nckGd2YbsXfp1SkisznhGVIXP2NQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmmirror.com/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.19", + "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.19.tgz", + "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.55", + "resolved": "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.55.tgz", + "integrity": "sha512-mIrE/Cw9y+9Au6dS5vDKDhQza9YvG6w+ZrS6X+ZzA7yFW/soAeaups4Qzn1bL6g5FVy8WtP79+0j82oPIbqRjQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.5.28", + "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.18", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmmirror.com/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmmirror.com/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, + "node_modules/react-refresh": { + "version": "0.17.0", + "resolved": "https://registry.npmmirror.com/react-refresh/-/react-refresh-0.17.0.tgz", + "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-router": { + "version": "6.30.6", + "resolved": "https://registry.npmmirror.com/react-router/-/react-router-6.30.6.tgz", + "integrity": "sha512-5HfK7k5im7LTOB0EqCQmfvy4C13G92Ssj1VTmouTK3AJvyjKTnFuCV0vcMAD/JS+JC4DvDIBRrlAeJIFjh5VWg==", + "license": "MIT", + "dependencies": { + "@remix-run/router": "1.23.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.30.6", + "resolved": "https://registry.npmmirror.com/react-router-dom/-/react-router-dom-6.30.6.tgz", + "integrity": "sha512-0RHKZz7wwffvkU+2MFVT2NnjK44ssLEV+m0CAJaS2Ksmorrwj7WxH00jO0SOCW26/tINUnJHToXblDs33I38YQ==", + "license": "MIT", + "dependencies": { + "@remix-run/router": "1.23.4", + "react-router": "6.30.6" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, + "node_modules/rollup": { + "version": "4.63.3", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.63.3.tgz", + "integrity": "sha512-1i2XreiAoMMXuPGD6Msj2xWrMMkHojNRKivInxGQcg7/1KuPuYlfUutLyh4drnOxUTHX9cHI4wFoat8D/NKaBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.3", + "@rollup/rollup-android-arm64": "4.63.3", + "@rollup/rollup-darwin-arm64": "4.63.3", + "@rollup/rollup-darwin-x64": "4.63.3", + "@rollup/rollup-freebsd-arm64": "4.63.3", + "@rollup/rollup-freebsd-x64": "4.63.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.3", + "@rollup/rollup-linux-arm-musleabihf": "4.63.3", + "@rollup/rollup-linux-arm64-gnu": "4.63.3", + "@rollup/rollup-linux-arm64-musl": "4.63.3", + "@rollup/rollup-linux-loong64-gnu": "4.63.3", + "@rollup/rollup-linux-loong64-musl": "4.63.3", + "@rollup/rollup-linux-ppc64-gnu": "4.63.3", + "@rollup/rollup-linux-ppc64-musl": "4.63.3", + "@rollup/rollup-linux-riscv64-gnu": "4.63.3", + "@rollup/rollup-linux-riscv64-musl": "4.63.3", + "@rollup/rollup-linux-s390x-gnu": "4.63.3", + "@rollup/rollup-linux-x64-gnu": "4.63.3", + "@rollup/rollup-linux-x64-musl": "4.63.3", + "@rollup/rollup-openbsd-x64": "4.63.3", + "@rollup/rollup-openharmony-arm64": "4.63.3", + "@rollup/rollup-win32-arm64-msvc": "4.63.3", + "@rollup/rollup-win32-ia32-msvc": "4.63.3", + "@rollup/rollup-win32-x64-gnu": "4.63.3", + "@rollup/rollup-win32-x64-msvc": "4.63.3", + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmmirror.com/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmmirror.com/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.3", + "resolved": "https://registry.npmmirror.com/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", + "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/use-sync-external-store": { + "version": "1.7.0", + "resolved": "https://registry.npmmirror.com/use-sync-external-store/-/use-sync-external-store-1.7.0.tgz", + "integrity": "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/vite": { + "version": "5.4.21", + "resolved": "https://registry.npmmirror.com/vite/-/vite-5.4.21.tgz", + "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/zustand": { + "version": "4.5.7", + "resolved": "https://registry.npmmirror.com/zustand/-/zustand-4.5.7.tgz", + "integrity": "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==", + "license": "MIT", + "dependencies": { + "use-sync-external-store": "^1.2.2" + }, + "engines": { + "node": ">=12.7.0" + }, + "peerDependencies": { + "@types/react": ">=16.8", + "immer": ">=9.0.6", + "react": ">=16.8" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + } + } + } + } +} diff --git a/src/frontend/package.json b/src/frontend/package.json new file mode 100644 index 0000000..13d02c1 --- /dev/null +++ b/src/frontend/package.json @@ -0,0 +1,28 @@ +{ + "name": "ssw-jnpf-lite-react-frontend", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "typecheck": "tsc --noEmit", + "preview": "vite preview" + }, + "dependencies": { + "@xyflow/react": "^12.12.1", + "axios": "^1.7.0", + "crypto-js": "^4.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-router-dom": "^6.26.0" + }, + "devDependencies": { + "@types/crypto-js": "^4.2.2", + "@types/react": "^18.3.0", + "@types/react-dom": "^18.3.0", + "@vitejs/plugin-react": "^4.3.0", + "typescript": "^5.4.0", + "vite": "^5.2.0" + } +} diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx new file mode 100644 index 0000000..10715c1 --- /dev/null +++ b/src/frontend/src/App.tsx @@ -0,0 +1,65 @@ +import { Routes, Route, Navigate, useLocation } from 'react-router-dom'; +import { JSX } from 'react'; +import Login from './views/Login'; +import Dashboard from './views/Dashboard'; +import DemoItem from './views/DemoItem'; +import Product from './views/Product'; +import Book from './views/Book'; +import UserManage from './views/UserManage'; +import RoleManage from './views/RoleManage'; +import OrganizeManage from './views/OrganizeManage'; +import MenuManage from './views/MenuManage'; +import Flow from './views/Flow'; +import FlowRun from './views/FlowRun'; +import Project from './views/Project'; +import Party from './views/Party'; +import ProjectParty from './views/ProjectParty'; +import Datasource from './views/Datasource'; +import Dataset from './views/Dataset'; +import DatasetAuth from './views/DatasetAuth'; +import FlowStepRun from './views/FlowStepRun'; +import RunEvent from './views/RunEvent'; +import Artifact from './views/Artifact'; +import FlowSchedule from './views/FlowSchedule'; +import Device from './views/Device'; +import ChainBlock from './views/ChainBlock'; +import { getToken } from './api/request'; + +function RequireAuth({ children }: { children: JSX.Element }) { + const token = getToken(); + const location = useLocation(); + if (!token) return ; + return children; +} + +/** 每条 Route path 去前导斜杠后必须与 seed.service.ts menus[].urlAddress、controller MODULE_KEY 一字不差。 */ +export default function App() { + return ( + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + ); +} diff --git a/src/frontend/src/api/artifact.ts b/src/frontend/src/api/artifact.ts new file mode 100644 index 0000000..58d9dc7 --- /dev/null +++ b/src/frontend/src/api/artifact.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 步骤产物 —— 端点与 @Controller('api/ssw/sswflow/Artifact') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listArtifacts = () => request.get('/ssw/sswflow/Artifact/List'); +export const saveArtifact = (dto: any) => request.post('/ssw/sswflow/Artifact/Save', dto); +export const deleteArtifact = (id: string) => + request.delete(`/ssw/sswflow/Artifact/Delete?id=${id}`); diff --git a/src/frontend/src/api/auth.ts b/src/frontend/src/api/auth.ts new file mode 100644 index 0000000..24cad54 --- /dev/null +++ b/src/frontend/src/api/auth.ts @@ -0,0 +1,19 @@ +import request from './request'; + +export async function login(account: string, passwordHex: string) { + const params = new URLSearchParams(); + params.set('account', account); + params.set('password', passwordHex); + params.set('grant_type', 'password'); + // Content-Type: application/x-www-form-urlencoded,与 JNPF 登录一致 + return (await request.post('/oauth/Login', params.toString(), { + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + })) as { token: string; expiresIn: number; tokenTypeName: string }; +} + +export async function currentUser() { + return (await request.get('/oauth/CurrentUser')) as { + userInfo: any; + menuList: any[]; + }; +} diff --git a/src/frontend/src/api/book.ts b/src/frontend/src/api/book.ts new file mode 100644 index 0000000..5c9d744 --- /dev/null +++ b/src/frontend/src/api/book.ts @@ -0,0 +1,5 @@ +import request from './request'; + +export const listBooks = () => request.get('/ssw/books/Book/List'); +export const saveBook = (dto: any) => request.post('/ssw/books/Book/Save', dto); +export const deleteBook = (id: string) => request.delete(`/ssw/books/Book/Delete?id=${id}`); \ No newline at end of file diff --git a/src/frontend/src/api/chainblock.ts b/src/frontend/src/api/chainblock.ts new file mode 100644 index 0000000..7bc7b85 --- /dev/null +++ b/src/frontend/src/api/chainblock.ts @@ -0,0 +1,10 @@ +import request from './request'; + +// 链上存证 —— 端点与 @Controller('api/ssw/sswchain/ChainBlock') 一一对应。 +export const listChainBlocks = () => request.get('/ssw/sswchain/ChainBlock/List'); +export const saveChainBlock = (dto: any) => request.post('/ssw/sswchain/ChainBlock/Save', dto); +export const deleteChainBlock = (id: string) => + request.delete(`/ssw/sswchain/ChainBlock/Delete?id=${id}`); + +/** 从真链同步存证(outbox 状态 + 链高度 + 合约只读读回)。 */ +export const syncChainBlocks = (body?: any) => request.post('/ssw/sswchain/ChainBlock/Sync', body || {}); diff --git a/src/frontend/src/api/dataset.ts b/src/frontend/src/api/dataset.ts new file mode 100644 index 0000000..ac8f223 --- /dev/null +++ b/src/frontend/src/api/dataset.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 数据集 —— 端点与 @Controller('api/ssw/sswflow/Dataset') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listDatasets = () => request.get('/ssw/sswflow/Dataset/List'); +export const saveDataset = (dto: any) => request.post('/ssw/sswflow/Dataset/Save', dto); +export const deleteDataset = (id: string) => + request.delete(`/ssw/sswflow/Dataset/Delete?id=${id}`); diff --git a/src/frontend/src/api/datasetauth.ts b/src/frontend/src/api/datasetauth.ts new file mode 100644 index 0000000..5e314a9 --- /dev/null +++ b/src/frontend/src/api/datasetauth.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 数据集授权 —— 端点与 @Controller('api/ssw/sswflow/DatasetAuth') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listDatasetAuths = () => request.get('/ssw/sswflow/DatasetAuth/List'); +export const saveDatasetAuth = (dto: any) => request.post('/ssw/sswflow/DatasetAuth/Save', dto); +export const deleteDatasetAuth = (id: string) => + request.delete(`/ssw/sswflow/DatasetAuth/Delete?id=${id}`); diff --git a/src/frontend/src/api/datasource.ts b/src/frontend/src/api/datasource.ts new file mode 100644 index 0000000..81589c5 --- /dev/null +++ b/src/frontend/src/api/datasource.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 数据源 —— 端点与 @Controller('api/ssw/sswflow/Datasource') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listDatasources = () => request.get('/ssw/sswflow/Datasource/List'); +export const saveDatasource = (dto: any) => request.post('/ssw/sswflow/Datasource/Save', dto); +export const deleteDatasource = (id: string) => + request.delete(`/ssw/sswflow/Datasource/Delete?id=${id}`); diff --git a/src/frontend/src/api/device.ts b/src/frontend/src/api/device.ts new file mode 100644 index 0000000..e6d52fe --- /dev/null +++ b/src/frontend/src/api/device.ts @@ -0,0 +1,10 @@ +import request from './request'; + +// 设备注册 —— 端点与 @Controller('api/ssw/sswdevice/Device') 一一对应。 +export const listDevices = () => request.get('/ssw/sswdevice/Device/List'); +export const saveDevice = (dto: any) => request.post('/ssw/sswdevice/Device/Save', dto); +export const deleteDevice = (id: string) => + request.delete(`/ssw/sswdevice/Device/Delete?id=${id}`); + +/** 从 ssw-mpc 控制面同步真实 TEE 节点注册表(真数据源)。 */ +export const syncDevices = () => request.post('/ssw/sswdevice/Device/Sync'); diff --git a/src/frontend/src/api/flow.ts b/src/frontend/src/api/flow.ts new file mode 100644 index 0000000..cd977d5 --- /dev/null +++ b/src/frontend/src/api/flow.ts @@ -0,0 +1,24 @@ +import request from './request'; + +// 流程 —— 端点与 @Controller('api/ssw/sswflow/Flow') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listFlows = () => request.get('/ssw/sswflow/Flow/List'); +export const saveFlow = (dto: any) => request.post('/ssw/sswflow/Flow/Save', dto); +export const deleteFlow = (id: string) => + request.delete(`/ssw/sswflow/Flow/Delete?id=${id}`); + +// 画布与校验(对齐 ssw-mvp api/sswflow.ts 的 flow.* 子集) +export const saveCanvas = (id: string, steps: any, edges: any) => + request.post('/ssw/sswflow/Flow/Canvas', { id, steps, edges }); +export const validateFlow = (id: string) => + request.post('/ssw/sswflow/Flow/Validate', { id }); +export const copyFlow = (id: string) => + request.post('/ssw/sswflow/Flow/Copy', { id }); +export const byProject = (projectId: string) => + request.get(`/ssw/sswflow/Flow/ByProject?projectId=${projectId}`); +export const compilePlan = (id: string) => + request.get(`/ssw/sswflow/Flow/CompilePlan?id=${id}`); + +// 算子目录 / 引擎状态 +export const operatorCatalog = () => request.get('/ssw/sswflow/Operator/Catalog'); +export const engineInfo = () => request.get('/ssw/sswflow/Engine/Info'); diff --git a/src/frontend/src/api/flowrun.ts b/src/frontend/src/api/flowrun.ts new file mode 100644 index 0000000..19366d9 --- /dev/null +++ b/src/frontend/src/api/flowrun.ts @@ -0,0 +1,24 @@ +import request from './request'; + +// 运行实例 —— 端点与 @Controller('api/ssw/sswflow/FlowRun') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listFlowRuns = () => request.get('/ssw/sswflow/FlowRun/List'); +export const saveFlowRun = (dto: any) => request.post('/ssw/sswflow/FlowRun/Save', dto); +export const deleteFlowRun = (id: string) => + request.delete(`/ssw/sswflow/FlowRun/Delete?id=${id}`); + +// 运行控制与观测(原 ssw-mvp 的 SSE 这里改为 Events 增量轮询) +export const startRun = (opts: any) => request.post('/ssw/sswflow/FlowRun/Start', opts); +export const stopRun = (runId: string) => request.post('/ssw/sswflow/FlowRun/Stop', { runId }); +export const runInfo = (id: string) => request.get(`/ssw/sswflow/FlowRun/Info?id=${id}`); +export const runSteps = (runId: string) => request.get(`/ssw/sswflow/FlowRun/Steps?runId=${runId}`); +export const runEvents = (runId: string, afterSeq = 0) => + request.get(`/ssw/sswflow/FlowRun/Events?runId=${runId}&afterSeq=${afterSeq}`); +export const runArtifacts = (runId: string, stepId?: string) => + request.get(`/ssw/sswflow/FlowRun/Artifacts?runId=${runId}${stepId ? `&stepId=${stepId}` : ''}`); +export const runOverview = (runId: string) => + request.get(`/ssw/sswflow/FlowRun/Overview?runId=${runId}`); +export const recentRuns = (limit = 50) => + request.get(`/ssw/sswflow/FlowRun/Recent?limit=${limit}`); +export const runsByFlow = (flowId: string, limit = 20) => + request.get(`/ssw/sswflow/FlowRun/ByFlow?flowId=${flowId}&limit=${limit}`); diff --git a/src/frontend/src/api/flowschedule.ts b/src/frontend/src/api/flowschedule.ts new file mode 100644 index 0000000..f5c0e28 --- /dev/null +++ b/src/frontend/src/api/flowschedule.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 周期调度 —— 端点与 @Controller('api/ssw/sswflow/FlowSchedule') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listFlowSchedules = () => request.get('/ssw/sswflow/FlowSchedule/List'); +export const saveFlowSchedule = (dto: any) => request.post('/ssw/sswflow/FlowSchedule/Save', dto); +export const deleteFlowSchedule = (id: string) => + request.delete(`/ssw/sswflow/FlowSchedule/Delete?id=${id}`); diff --git a/src/frontend/src/api/flowsteprun.ts b/src/frontend/src/api/flowsteprun.ts new file mode 100644 index 0000000..a306f59 --- /dev/null +++ b/src/frontend/src/api/flowsteprun.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 步骤运行 —— 端点与 @Controller('api/ssw/sswflow/FlowStepRun') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listFlowStepRuns = () => request.get('/ssw/sswflow/FlowStepRun/List'); +export const saveFlowStepRun = (dto: any) => request.post('/ssw/sswflow/FlowStepRun/Save', dto); +export const deleteFlowStepRun = (id: string) => + request.delete(`/ssw/sswflow/FlowStepRun/Delete?id=${id}`); diff --git a/src/frontend/src/api/party.ts b/src/frontend/src/api/party.ts new file mode 100644 index 0000000..70853b9 --- /dev/null +++ b/src/frontend/src/api/party.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 参与方 —— 端点与 @Controller('api/ssw/sswflow/Party') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listParties = () => request.get('/ssw/sswflow/Party/List'); +export const saveParty = (dto: any) => request.post('/ssw/sswflow/Party/Save', dto); +export const deleteParty = (id: string) => + request.delete(`/ssw/sswflow/Party/Delete?id=${id}`); diff --git a/src/frontend/src/api/product.ts b/src/frontend/src/api/product.ts new file mode 100644 index 0000000..3ad40fc --- /dev/null +++ b/src/frontend/src/api/product.ts @@ -0,0 +1,7 @@ +import request from './request'; + +// Product 业务 API —— 端点与后端 @Controller('api/ssw/shop/Product') 对应 +export const listProducts = () => request.get('/ssw/shop/Product/List'); +export const saveProduct = (dto: any) => request.post('/ssw/shop/Product/Save', dto); +export const deleteProduct = (id: string) => + request.delete(`/ssw/shop/Product/Delete?id=${id}`); diff --git a/src/frontend/src/api/project.ts b/src/frontend/src/api/project.ts new file mode 100644 index 0000000..934c08d --- /dev/null +++ b/src/frontend/src/api/project.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 项目 —— 端点与 @Controller('api/ssw/sswflow/Project') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listProjects = () => request.get('/ssw/sswflow/Project/List'); +export const saveProject = (dto: any) => request.post('/ssw/sswflow/Project/Save', dto); +export const deleteProject = (id: string) => + request.delete(`/ssw/sswflow/Project/Delete?id=${id}`); diff --git a/src/frontend/src/api/projectparty.ts b/src/frontend/src/api/projectparty.ts new file mode 100644 index 0000000..6841440 --- /dev/null +++ b/src/frontend/src/api/projectparty.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 项目参与方 —— 端点与 @Controller('api/ssw/sswflow/ProjectParty') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listProjectParties = () => request.get('/ssw/sswflow/ProjectParty/List'); +export const saveProjectParty = (dto: any) => request.post('/ssw/sswflow/ProjectParty/Save', dto); +export const deleteProjectParty = (id: string) => + request.delete(`/ssw/sswflow/ProjectParty/Delete?id=${id}`); diff --git a/src/frontend/src/api/request.ts b/src/frontend/src/api/request.ts new file mode 100644 index 0000000..aecc279 --- /dev/null +++ b/src/frontend/src/api/request.ts @@ -0,0 +1,72 @@ +import axios, { AxiosError, AxiosInstance } from 'axios'; + +/** + * 请求层 —— 复刻 JNPF/jweb 的 ActionResult 适配语义: + * - 统一 baseURL '/api'(dev 由 vite proxy 转发到 30000) + * - 拦截器处理 code:600/601/602 -> 清 token 跳 /login(对齐 jweb enum.ts: TOKEN_TIMEOUT/TOKEN_LOGGED/TOKEN_ERROR) + * - code !== 200 -> reject + * - 成功时把 ActionResult 的 data 解包抛给调用方 + * 迁 jweb(Vue) 时这些逻辑 1:1 对应 vben 的 defHttp 拦截器,前端零改。 + */ +const TOKEN_KEY = 'ssw_token'; + +export function getToken(): string | null { + return localStorage.getItem(TOKEN_KEY); +} +export function setToken(raw: string) { + const t = raw.startsWith('bearer ') ? raw : `bearer ${raw}`; + localStorage.setItem(TOKEN_KEY, t); +} +export function clearToken() { + localStorage.removeItem(TOKEN_KEY); +} + +interface SswRequest extends AxiosInstance { + get(url: string, config?: any): Promise; + post(url: string, data?: any, config?: any): Promise; + put(url: string, data?: any, config?: any): Promise; + delete(url: string, config?: any): Promise; +} + +const request = axios.create({ baseURL: '/api', timeout: 30000 }) as SswRequest; + +request.interceptors.request.use((config) => { + const token = getToken(); + config.headers.set('App-Code', 'sswflow'); + config.headers.set('Jnpf-Origin', 'pc'); + if (token) config.headers.set('Authorization', token); + return config; +}); + +function redirectLogin() { + if (location.pathname !== '/login') { + location.replace(`/login?next=${encodeURIComponent(location.pathname + location.search)}`); + } +} + +request.interceptors.response.use( + (resp) => { + const body = resp.data || {}; + if (body.code === 600 || body.code === 601 || body.code === 602) { + clearToken(); + redirectLogin(); + return Promise.reject(new Error('NOT_LOGIN')); + } + if (body.code !== undefined && body.code !== 200) { + return Promise.reject(new Error(body.msg || '操作失败')); + } + return body.data !== undefined ? body.data : body; + }, + (error: AxiosError) => { + const status = error.response?.status; + const body: any = error.response?.data || {}; + if (status === 401 || body.code === 600 || body.code === 601 || body.code === 602) { + clearToken(); + redirectLogin(); + return Promise.reject(new Error('NOT_LOGIN')); + } + return Promise.reject(new Error(body.msg || error.message || '请求失败')); + }, +); + +export default request; diff --git a/src/frontend/src/api/runevent.ts b/src/frontend/src/api/runevent.ts new file mode 100644 index 0000000..bae16ff --- /dev/null +++ b/src/frontend/src/api/runevent.ts @@ -0,0 +1,8 @@ +import request from './request'; + +// 运行事件 —— 端点与 @Controller('api/ssw/sswflow/RunEvent') 一一对应。 +// request 自动带 token、剥 ActionResult、处理 600/601/602。 +export const listRunEvents = () => request.get('/ssw/sswflow/RunEvent/List'); +export const saveRunEvent = (dto: any) => request.post('/ssw/sswflow/RunEvent/Save', dto); +export const deleteRunEvent = (id: string) => + request.delete(`/ssw/sswflow/RunEvent/Delete?id=${id}`); diff --git a/src/frontend/src/api/sys.ts b/src/frontend/src/api/sys.ts new file mode 100644 index 0000000..b20a40d --- /dev/null +++ b/src/frontend/src/api/sys.ts @@ -0,0 +1,36 @@ +import request from './request'; + +// 用户 +export const listUsers = () => request.get('/ssw/sys/User/List'); +export const saveUser = (dto: any) => request.post('/ssw/sys/User/Save', dto); +export const deleteUser = (id: string) => + request.delete(`/ssw/sys/User/Delete?id=${id}`); + +// 角色 +export const listRoles = () => request.get('/ssw/sys/Role/List'); +export const saveRole = (dto: any) => request.post('/ssw/sys/Role/Save', dto); +export const deleteRole = (id: string) => + request.delete(`/ssw/sys/Role/Delete?id=${id}`); +export const roleModules = (roleId: string) => + request.get(`/ssw/sys/Role/Modules?roleId=${roleId}`); + +// 机构 +export const listOrganize = () => request.get('/ssw/sys/Organize/List'); +export const saveOrganize = (dto: any) => request.post('/ssw/sys/Organize/Save', dto); +export const deleteOrganize = (id: string) => + request.delete(`/ssw/sys/Organize/Delete?id=${id}`); + +// 菜单 +export const listModules = () => request.get('/ssw/sys/Module/List'); +export const saveModule = (dto: any) => request.post('/ssw/sys/Module/Save', dto); +export const deleteModule = (id: string) => + request.delete(`/ssw/sys/Module/Delete?id=${id}`); + +// 统一授权(角色→菜单,对齐 JNPF PUT /api/permission/Authority/Data/{objectId}) +// module 是一维 String[](官方 AuthorizeDataUpForm.module = String[]); +// 半选节点由调用方合并进同一数组(对齐 MenuAuth.vue: [...checkedKeys, ...halfCheckedKeys]) +export const saveRoleModules = (roleId: string, moduleIds: string[]) => + request.put(`/permission/Authority/Data/${roleId}`, { + objectType: 'role', + module: moduleIds, + }); diff --git a/src/frontend/src/components/CrudPage.tsx b/src/frontend/src/components/CrudPage.tsx new file mode 100644 index 0000000..516e330 --- /dev/null +++ b/src/frontend/src/components/CrudPage.tsx @@ -0,0 +1,206 @@ +import { useEffect, useState } from 'react'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from '../views/ui'; + +export interface Field { key: string; label: string } +export interface CrudApi { + list: () => Promise; + save: (dto: any) => Promise; + remove: (id: string) => Promise; +} +export interface CrudPageProps { + title: string; + entity: string; + columns: Field[]; + fields: Field[]; + api: CrudApi; + readonly?: boolean; + /** 只读监控页可指定一个本地过滤字段(如 runId) */ + filterKey?: string; + /** 后端 appCode(默认 sswflow);新模块传其 appCode 以修正副标题路径 */ + apiBase?: string; + /** 「从真源同步」回调;有值才渲染同步按钮。body 携带 syncExtra 填的值。 */ + sync?: (body?: any) => Promise; + /** 同步按钮文案 */ + syncLabel?: string; + /** + * 同步前的额外输入(如 FISCO txHash)。填了会作为 body 传给 sync。 + * 值变了要重跑同步才生效 —— 不做隐式重查,避免误触。 + */ + syncExtra?: { key: string; label: string; placeholder?: string }; + /** 自定义单元格渲染(布尔位 / 徽标等) */ + renderCell?: (row: any, key: string) => React.ReactNode; + /** 顶部说明条(数据来源标注等) */ + banner?: React.ReactNode; +} + +/** 通用 CRUD 页:薄视图共用;字段一律用去前缀名(JNPF Jackson 剥 f_)。 */ +export default function CrudPage({ + title, entity, columns, fields, api, readonly, filterKey, apiBase, + sync, syncLabel, syncExtra, renderCell, banner, +}: CrudPageProps) { + const [rows, setRows] = useState([]); + const [editing, setEditing] = useState(null); + const [filter, setFilter] = useState(''); + const [err, setErr] = useState(''); + const [syncNote, setSyncNote] = useState(''); + const [extra, setExtra] = useState(''); + const [busy, setBusy] = useState(false); + + async function load() { + try { setRows((await api.list()) || []); } catch (e: any) { setErr(e.message); } + } + useEffect(() => { load(); }, [entity]); + + async function doSync() { + if (!sync) return; + setBusy(true); setErr(''); setSyncNote(''); + try { + const r = await sync(syncExtra && extra.trim() ? { [syncExtra.key]: extra.trim() } : {}); + setSyncNote(summarizeSync(r)); + await load(); + } catch (e: any) { + setErr(e.message); + } finally { + setBusy(false); + } + } + + async function save() { + try { + await api.save(editing); + setEditing(null); setErr(''); load(); + } catch (e: any) { setErr(e.message); } + } + async function remove(id: string) { + if (!confirm(`确认删除该${title}记录?(软删 f_delete_mark=1)`)) return; + try { await api.remove(id); load(); } catch (e: any) { setErr(e.message); } + } + + const shown = filterKey && filter + ? rows.filter((r) => String(r[filterKey] || '').includes(filter)) + : rows; + + return ( +
+
+
+

{title}

+ /api/ssw/{apiBase || 'sswflow'}/{entity} + + + {sync && ( + + )} + {!readonly && ( + + )} +
+ + {banner &&
{banner}
} + + {sync && syncExtra && ( +
+ {syncExtra.label} + setExtra(e.target.value)} + /> +
+ )} + + {syncNote && ( +
{syncNote}
+ )} + + {filterKey && ( +
+ setFilter(e.target.value)} /> +
+ )} + {err &&
{err}
} + + {editing && ( +
+

{editing.id ? '编辑' : '新增'}{title}

+
+ {fields.map((f) => ( + + ))} +
+
+ + +
+
+ )} + + + + + {columns.map((c) => )} + {!readonly && } + + + + {shown.map((r) => ( + + {columns.map((c) => ( + + ))} + {!readonly && ( + + )} + + ))} + {shown.length === 0 && ( + + )} + +
{c.label}操作
+ {renderCell ? renderCell(r, c.key) : format(r[c.key])} + + + +
暂无数据
+
+
+ ); +} + +/** 把同步结果摘要成一行人读文本(真源 / mock 要看得见)。 */ +function summarizeSync(r: any): string { + if (!r || typeof r !== 'object') return ''; + const bits: string[] = []; + if (r.source) bits.push(`数据来源:${r.source === 'mock' ? '接口不可达(占位)' : r.source}`); + if (typeof r.synced === 'number') bits.push(`同步 ${r.synced} 条`); + // ★ 下线:真源里消失的节点(控制面 /nodes 是「当前在线清单」)。 + if (typeof r.offline === 'number' && r.offline > 0) bits.push(`下线 ${r.offline} 个`); + if (r.height !== undefined && r.height !== null) bits.push(`链高度 ${r.height}`); + // ★ 链上出块回执:把三件套的结论说清楚,别只丢个哈希。 + if (r.txReceipt) { + const t = r.txReceipt; + const verdict = t.success ? '成功(0)' : (t.status === null || t.status === undefined ? '未出块' : `失败(${t.status})`); + bits.push(`链上回执 ${verdict} @块高 ${t.blockNumber ?? '-'}(${t.groupId}/${t.nodeName})`); + } + if (r.origin) bits.push(`出处 ${r.origin}`); + if (r.reason) bits.push(`原因:${r.reason}`); + return bits.join(' · '); +} + +function format(v: any): string { + if (v === null || v === undefined || v === '') return '-'; + if (v instanceof Date) return v.toLocaleString(); + if (typeof v === 'object') return JSON.stringify(v).slice(0, 80); + const s = String(v); + if (/^\d{4}-\d{2}-\d{2}T/.test(s)) return new Date(s).toLocaleString(); + return s.length > 80 ? s.slice(0, 80) + '…' : s; +} diff --git a/src/frontend/src/components/SswNode.tsx b/src/frontend/src/components/SswNode.tsx new file mode 100644 index 0000000..71fc26b --- /dev/null +++ b/src/frontend/src/components/SswNode.tsx @@ -0,0 +1,165 @@ +import { memo } from 'react'; +import { Handle, Position, type NodeProps } from '@xyflow/react'; +import './sswNode.css'; +import type { SswFlowNode } from '../utils/flowTransform'; + +/** + * 画布节点 —— 移植自 ssw-mvp `jweb/.../components/sswflow/SswNode.vue`(VueFlow 版), + * 改写为 React Flow(`@xyflow/react`)自定义节点。 + * + * 与原实现的关键差异(原实现的缺陷): + * 原 SswNode.vue 只有固定的 in / out 两个 Handle,而算子目录里 + * prep.intersect 有 left/right 两个输入、model.predict 有 model/in 两个输入、 + * prep.split 有 train/test 两个输出、prep.binning 有 out/rule 两个输出。 + * 多端口算子的第二个端口在原实现里**永远连不上**, + * 保存一轮后启动就报「输入端口未连线」。 + * 本实现按算子 ports 动态渲染 N 个 Handle,并给每个 Handle 一个 + * 明确的 handle id(= 端口 key),从根上消除这个问题。 + */ +const NODE_W = 190; + +function SswNodeInner({ data, selected }: NodeProps) { + const inputs = data.inputs || []; + const outputs = data.outputs || []; + const color = data.color || '#1677ff'; + + // 端口在节点纵向的分布:单端口 50%,多端口均匀铺开(留出上下边距) + const handleTop = (i: number, total: number) => + total <= 1 ? '50%' : `${((i + 1) * 100) / (total + 1)}%`; + + const status = data._runStatus; + const ring = + status === 'SUCCESS' ? '#52c41a' + : status === 'FAILED' ? '#ff4d4f' + : status === 'RUNNING' ? '#fa8c16' + : color; + const progress = Math.max(0, Math.min(100, Math.round(data._runProgress ?? 0))); + + return ( +
+ {/* 输入端口:每个算子输入端口一个 Handle,id = 端口 key */} + {inputs.map((p, i) => ( + + ))} + {/* 无输入端口的源节点(source.dataset)也要有一个 target 位, + 否则用户无法从它拖出连线 —— 追加一个只用于起手的隐形 target handle。 */} + {inputs.length === 0 && ( + + )} + +
+ {data.icon} + + {data.label} + + {status === 'RUNNING' && ( + + 计算中 + + )} +
+ +
+
{data.operatorKey}
+ {data.mpcStatus && ( +
+ {data.mpcCrate ? `${data.mpcCrate} · ` : ''}{data.mpcStatus} +
+ )} + {status && status !== 'PENDING' && ( +
+
+ {status} + {progress}% +
+
+
+
+ {data._runMsg && ( +
{data._runMsg}
+ )} +
+ )} +
+ + {/* 输出端口:每个算子输出端口一个 Handle,id = 端口 key */} + {outputs.map((p, i) => ( + + ))} + {/* 无输出端口的终端节点(sink.export)补一个 source 位以便下游继续连线 */} + {outputs.length === 0 && ( + + )} +
+ ); +} + +export default memo(SswNodeInner); diff --git a/src/frontend/src/components/sswNode.css b/src/frontend/src/components/sswNode.css new file mode 100644 index 0000000..d70bb02 --- /dev/null +++ b/src/frontend/src/components/sswNode.css @@ -0,0 +1,31 @@ +/* 画布节点补充样式 —— React 内联 style 无法定义 keyframes,动画放这里。 */ + +/* 正在计算的节点:脉冲光圈(对应 ssw-mvp 的 node-pulse) */ +@keyframes sswNodePulse { + 0%, 100% { box-shadow: 0 0 0 0 rgba(250, 140, 22, 0.35); } + 50% { box-shadow: 0 0 0 8px rgba(250, 140, 22, 0); } +} + +/* Handle 命中区放大:真实 handle 半径小,拖线很难点中。 + 用伪元素撑出一圈透明热区(pointer-events 不变,事件仍落到 handle 本身)。 */ +.react-flow__handle::after { + content: ''; + position: absolute; + inset: -8px; + border-radius: 50%; + background: transparent; + pointer-events: none; +} + +.react-flow__handle:hover { + box-shadow: 0 0 0 4px rgba(133, 183, 235, 0.35); +} + +/* 端口标签(多端口算子 hover 时显示端口名) */ +.ssw-port-tag { + position: absolute; + font-size: 9px; + color: #9aa7b5; + white-space: nowrap; + pointer-events: none; +} diff --git a/src/frontend/src/main.tsx b/src/frontend/src/main.tsx new file mode 100644 index 0000000..6291701 --- /dev/null +++ b/src/frontend/src/main.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import { BrowserRouter } from 'react-router-dom'; +import App from './App'; + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + + + , +); diff --git a/src/frontend/src/utils/cipher.ts b/src/frontend/src/utils/cipher.ts new file mode 100644 index 0000000..a33f030 --- /dev/null +++ b/src/frontend/src/utils/cipher.ts @@ -0,0 +1,26 @@ +import CryptoJS from 'crypto-js'; + +/** + * 登录密码加密 —— 与 JNPF 后端 LiteLoginController / dacli / ssw-jnpf-lite(Vue) 完全一致。 + * 检验向量:encryptPassword('123456') === + * 'd4958348e22108119b3ef57b022c83f4bf857dd0b247eaab15b9a43d47ee3c503900f7135bf0de255bc33620c3cdc02b' + */ +const CIPHER_KEY = 'EY8WePvjM5GGwQzn'; + +function md5(str: string): string { + return CryptoJS.MD5(str).toString(); +} + +export function encryptPassword(plain: string): string { + const key = CryptoJS.enc.Utf8.parse(md5(CIPHER_KEY)); + const src = CryptoJS.enc.Utf8.parse(md5(plain)); + return CryptoJS.AES.encrypt(src, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }) + .ciphertext.toString(CryptoJS.enc.Hex); +} + +export function md5Hex(str: string): string { + return md5(str); +} diff --git a/src/frontend/src/utils/flowTransform.ts b/src/frontend/src/utils/flowTransform.ts new file mode 100644 index 0000000..b832890 --- /dev/null +++ b/src/frontend/src/utils/flowTransform.ts @@ -0,0 +1,203 @@ +/** + * 画布数据在「前端 React Flow 形态」与「后端 FlowGraph 形态」之间互转。 + * + * 移植自 ssw-mvp `jweb/apps/jnpf-web-apps-main/src/views/ssw/utils/flowTransform.ts` + * (原为 VueFlow 版,本项目改用同门 React Flow `@xyflow/react`,API 一一对应)。 + * + * 前端 React Flow 节点:{ id, type:'sswNode', position:{x,y}, data:{...} } + * 前端 React Flow 边: { id, source, target, sourceHandle, targetHandle } + * + * 后端 step 形态(FlowGraph.parse 要求): + * { stepId, operatorKey, label, x, y, params } + * 后端 edge 形态: + * { edgeId, sourceStepId, targetStepId, sourcePort, targetPort } + * + * 端口语义(关键):sourceHandle / targetHandle 存的就是算子的**端口 key** + * (如 prep.intersect 的 left/right、model.predict 的 model/in、prep.split 的 train/test), + * 与后端 edge.sourcePort / edge.targetPort 逐字对应。 + */ +import type { Edge, Node } from '@xyflow/react'; + +/** 算子端口定义(与 catalog.json 的 inputs/outputs 同形) */ +export interface PortDef { + key: string; + label?: string; + type?: string; +} + +/** 算子定义(catalog.json 里的 operators[] + 分类元信息) */ +export interface OperatorDef { + key: string; + label: string; + desc?: string; + category?: string; + color?: string; + icon?: string; + terminal?: boolean; + inputs?: PortDef[]; + outputs?: PortDef[]; + params?: any[]; + mpc?: { status?: string; crate?: string; note?: string }; +} + +export type OpMap = Record; + +/** + * 分类元信息 —— ssw-mvp 前端 CATEGORY_META 只有 5 类,漏了 tee / zkp, + * 这里补齐 7 类(与后端 catalog.json 的 categories 一致)。 + */ +export const CATEGORY_META: Record = { + source: { color: '#2f7d5b', icon: '▣' }, + prep: { color: '#2f5f9e', icon: '◇' }, + stat: { color: '#7a5aa8', icon: '▤' }, + model: { color: '#a3662c', icon: '◈' }, + sink: { color: '#8c4a4a', icon: '◉' }, + tee: { color: '#3b7d8c', icon: '⛨' }, + zkp: { color: '#6d6f38', icon: '✦' }, +}; + +/** MPC 能力状态配色(native / partial / local / unsupported) */ +export const STATUS_COLOR: Record = { + native: '#2f7d5b', + partial: '#a3662c', + local: '#4a5a6a', + unsupported: '#8c4a4a', +}; + +/** React Flow 自定义节点的 data 载荷 */ +export type SswNodeData = { + label: string; + operatorKey: string; + category: string; + color: string; + icon: string; + params: Record; + inputs: PortDef[]; + outputs: PortDef[]; + dataset?: string; + /** MPC 能力标签(native/partial/local/unsupported),仅用于节点副标题 */ + mpcStatus?: string; + mpcCrate?: string; + mpcColor?: string; + /** 运行态回写(对应 ssw-mvp 的 _runStatus/_runProgress/_runMsg) */ + _runStatus?: string; + _runProgress?: number; + _runMsg?: string; +}; + +export type SswFlowNode = Node; +export type SswFlowEdge = Edge; + +/** React Flow → 后端 step */ +export function toBackendSteps(nodes: any[]): any[] { + return (nodes || []).map((n) => ({ + stepId: n.id, + operatorKey: n.data?.operatorKey, + label: n.data?.label ?? n.data?.operatorKey, + x: Math.round(n.position?.x ?? 0), + y: Math.round(n.position?.y ?? 0), + params: n.data?.params || {}, + })); +} + +/** + * React Flow → 后端 edge。 + * + * sourceHandle / targetHandle 才是用户实际拖线时指定的端口, + * 多端口算子(prep.intersect 的 left/right、model.predict 的 model/in、 + * prep.split 的 train/test、prep.binning 的 out/rule)必须用 handle, + * 不能回退到算子 inputs[0].key —— 否则自动保存时会把所有同向连线的 + * targetPort 收成同一端口,下游节点的非首个端口就会判「未连线」。 + * 算子首端口只作 handle 为空时的兜底。 + */ +export function toBackendEdges(edges: any[], nodes: any[], operatorMap: OpMap): any[] { + const opOf = (id: string): OperatorDef | undefined => { + const n = (nodes || []).find((x) => x.id === id); + return n?.data?.operatorKey ? operatorMap[n.data.operatorKey] : undefined; + }; + return (edges || []).map((e) => { + const srcOp = opOf(e.source); + const tgtOp = opOf(e.target); + const sourcePort = e.sourceHandle || srcOp?.outputs?.[0]?.key || 'out'; + const targetPort = e.targetHandle || tgtOp?.inputs?.[0]?.key || 'in'; + return { + edgeId: e.id, + sourceStepId: e.source, + targetStepId: e.target, + sourcePort, + targetPort, + }; + }); +} + +/** + * 后端 step → React Flow 节点。 + * + * 兜底布局:后端直插 / 旧数据常把步骤坐标写成 x=y=0,画布会把所有节点 + * 堆在左上角。这里对「没有任何有效坐标」的节点按索引做确定性网格级联, + * 保证打开即分散;有真实坐标的节点原样保留。 + */ +export function toRfNodes(steps: any[], operatorMap: OpMap): SswFlowNode[] { + return (steps || []).map((s, i) => { + const op = s.operatorKey ? operatorMap[s.operatorKey] : undefined; + const category = op?.category || (s.operatorKey || '').split('.')[0]; + const meta = CATEGORY_META[category] || { color: '#2f5f9e', icon: '◇' }; + const hasPos = !!(s.x || s.y); + const position = hasPos + ? { x: Number(s.x) || 0, y: Number(s.y) || 0 } + : { x: 120 + (i % 5) * 300, y: 120 + Math.floor(i / 5) * 220 }; + return { + id: s.stepId, + type: 'sswNode', + position, + data: { + label: s.label ?? s.operatorKey, + operatorKey: s.operatorKey, + category, + color: op?.color || meta.color, + icon: meta.icon, + params: s.params || {}, + inputs: op?.inputs || [], + outputs: op?.outputs || [], + dataset: '', + }, + } as SswFlowNode; + }); +} + +/** + * 后端 edge → React Flow 边。 + * + * 必须保留原始 sourcePort/targetPort:后端按算子真实端口存, + * 硬编码 'out'/'in' 会把多端口算子的端口吞掉,保存一轮之后 + * 启动就报「端口未连线」。 + * + * edgeId 必须非空且唯一 —— React Flow 用它做 key,undefined 会让 + * 整张图初始化中断(表现为节点全堆在原点、点击无反应)。 + */ +export function toRfEdges(edges: any[]): SswFlowEdge[] { + return (edges || []).map((e, i) => { + const source = e.sourceStepId; + const target = e.targetStepId; + const sourceHandle = e.sourcePort || 'out'; + const targetHandle = e.targetPort || 'in'; + const id = e.edgeId || `e-${source}-${sourceHandle}-${target}-${targetHandle}-${i}`; + return { id, source, target, sourceHandle, targetHandle } as SswFlowEdge; + }); +} + +/** 从后端返回的 steps/edges(数组或 JSON 字符串)解析为对象数组 */ +export function parseGraph(stepsJson?: any, edgesJson?: any): { steps: any[]; edges: any[] } { + return { steps: parseArray(stepsJson), edges: parseArray(edgesJson) }; +} + +export function parseArray(v: any): any[] { + if (Array.isArray(v)) return v; + if (v === undefined || v === null || v === '') return []; + try { + const parsed = JSON.parse(v); + return Array.isArray(parsed) ? parsed : []; + } catch { + return []; + } +} diff --git a/src/frontend/src/views/Artifact.tsx b/src/frontend/src/views/Artifact.tsx new file mode 100644 index 0000000..e7ff721 --- /dev/null +++ b/src/frontend/src/views/Artifact.tsx @@ -0,0 +1,16 @@ +import { listArtifacts, saveArtifact, deleteArtifact } from '../api/artifact'; +import CrudPage from '../components/CrudPage'; + +/** 步骤产物 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function Artifact() { + return ( + + ); +} diff --git a/src/frontend/src/views/Book.tsx b/src/frontend/src/views/Book.tsx new file mode 100644 index 0000000..b66a094 --- /dev/null +++ b/src/frontend/src/views/Book.tsx @@ -0,0 +1,155 @@ +import { useEffect, useState } from 'react'; +import { listBooks, saveBook, deleteBook } from '../api/book'; +import { wrap, card, btn, btnDanger, input as inputStyle, tableStyle, th, td } from './ui'; + +// 字段用去前缀名:id / title / author / isbn / category / price / stock +// (JNPF 后端 Jackson 会剥掉 f_ 前缀) +interface Book { + id: string; + title?: string; + author?: string; + isbn?: string; + category?: string; + price?: string; + stock?: number; +} + +export default function Books() { + const [items, setItems] = useState([]); + const [form, setForm] = useState({ + title: '', + author: '', + isbn: '', + category: '', + price: '', + stock: '', + }); + + async function load() { + const data = await listBooks(); + setItems(data || []); + } + useEffect(() => { + load(); + }, []); + + function update(k: keyof Book, v: string) { + setForm((f) => ({ ...f, [k]: v })); + } + + async function add() { + if (!form.title) return; + await saveBook({ + title: form.title, + author: form.author || undefined, + isbn: form.isbn || undefined, + category: form.category || undefined, + price: form.price || '0.00', + stock: form.stock ? Number(form.stock) : 0, + }); + setForm({ title: '', author: '', isbn: '', category: '', price: '', stock: '' }); + load(); + } + async function del(id: string) { + await deleteBook(id); + load(); + } + + return ( +
+
+

图书超市

+
+ update('title', e.target.value)} + placeholder="书名" + style={inputStyle} + /> + update('author', e.target.value)} + placeholder="作者" + style={inputStyle} + /> + update('isbn', e.target.value)} + placeholder="ISBN" + style={inputStyle} + /> + update('category', e.target.value)} + placeholder="分类" + style={inputStyle} + /> + update('price', e.target.value)} + placeholder="价格" + style={inputStyle} + /> + update('stock', e.target.value)} + placeholder="库存" + style={inputStyle} + /> +
+
+ + +
+ + + + + + + + + + + + + + {items.map((it) => ( + + + + + + + + + + ))} + {items.length === 0 && ( + + + + )} + +
书名作者ISBN分类价格库存操作
{it.title}{it.author}{it.isbn}{it.category}¥{it.price}{it.stock} + +
+ 暂无数据 +
+
+
+ ); +} \ No newline at end of file diff --git a/src/frontend/src/views/ChainBlock.tsx b/src/frontend/src/views/ChainBlock.tsx new file mode 100644 index 0000000..7505e53 --- /dev/null +++ b/src/frontend/src/views/ChainBlock.tsx @@ -0,0 +1,96 @@ +import { listChainBlocks, saveChainBlock, deleteChainBlock, syncChainBlocks } from '../api/chainblock'; +import CrudPage from '../components/CrudPage'; + +/** + * 链上存证 —— **Receipt / 回执**视图。 + * + * ★★ 这不是通用区块浏览器:ssw-mpc 的 `mpc chain` **没有**区块浏览命令, + * 链上对象只有 Receipt / Member / PolicyBundleRecord 三类。 + * 所以这里展示的是「链上登记的回执」+「FISCO 交易回执」。 + * + * ★★ 「验证通过」拆成四句,不合并成一个 ok=1: + * userDataOk(用户数据)/ measOk(镜像度量)/ tcbOk(TCB 门槛)/ chipSig(芯片验签)。 + * `chipSig = 否` 的含义是「绑定成立但没做芯片验签」,不是「没绑定」。 + * + * ★ FISCO 回执的 status:**0 = 执行成功**(与 web3 的 0x1 相反)。 + * 判定要三件套齐:status==0 + transactionHash 非空 + blockNumber>0。 + */ +export default function ChainBlock() { + return ( + + 数据来源:ssw-mpc chain 的 outbox(待上链表)与 FISCO 链只读读回 + (chain contract read)。链上对象是 Receipt,不是区块。 + FISCO 成功判据三件套:status==0(与 web3 相反)+ + transactionHash 非空 + blockNumber>0。 + + } + columns={[ + { key: 'orderId', label: '订单ID' }, + { key: 'decisionId', label: '决策ID' }, + { key: 'resultHash', label: '结果摘要' }, + { key: 'link', label: '链路' }, + { key: 'userDataOk', label: '用户数据' }, + { key: 'measOk', label: '度量' }, + { key: 'tcbOk', label: 'TCB' }, + { key: 'chipSig', label: '芯片验签' }, + { key: 'status', label: '链上状态' }, + { key: 'blockNumber', label: '出块高度' }, + { key: 'txHash', label: '交易哈希' }, + { key: 'source', label: '来源' }, + ]} + fields={[ + { key: 'orderId', label: '订单ID' }, + { key: 'decisionId', label: '决策ID' }, + { key: 'resultHash', label: '结果摘要(32字节hex)' }, + { key: 'inputHash', label: '输入摘要(32字节hex)' }, + { key: 'userData', label: '绑定值(64字节hex)' }, + { key: 'link', label: '链路(p2p/relay/unknown)' }, + { key: 'linkBinding', label: '绑定摘要(32字节hex)' }, + { key: 'digest', label: '链上规范摘要(SM3)' }, + { key: 'txHash', label: '交易哈希' }, + { key: 'contractAddress', label: '合约地址' }, + { key: 'gasUsed', label: 'gasUsed' }, + ]} + renderCell={(row, key) => { + if (['userDataOk', 'measOk', 'tcbOk', 'chipSig'].includes(key)) { + if (row[key] === null || row[key] === undefined) return '-'; + // ★ chipSig=否 的含义是「绑定成立但没做芯片验签」,不是「没绑定」。 + if (key === 'chipSig' && !row[key]) return '未做验签'; + return row[key] ? '通过' : '未通过'; + } + if (key === 'status') { + if (row.status === null || row.status === undefined) { + return row.txHash ? '未出块' : '待上链'; + } + // FISCO:status==0 是成功(与 web3 相反)。 + return row.status === 0 ? '成功(0)' : `失败(${row.status})`; + } + if (key === 'blockNumber') { + return row.blockNumber === null || row.blockNumber === undefined ? '-' : row.blockNumber; + } + if (key === 'source') { + const s = String(row.source || ''); + return s === 'mock' ? '接口不可达(占位)' : (s || '-'); + } + const v = row[key]; + if (v === null || v === undefined || v === '') return '-'; + const s = String(v); + return s.length > 60 ? s.slice(0, 60) + '…' : s; + }} + api={{ list: listChainBlocks, save: saveChainBlock, remove: deleteChainBlock }} + sync={(body?: any) => syncChainBlocks(body || {})} + syncLabel="从真链同步" + syncExtra={{ + key: 'txHash', + label: 'FISCO txHash(可选)', + placeholder: '0x… 填了会查链上出块回执(getTransactionReceipt 4 参)', + }} + readonly={false} + /> + ); +} diff --git a/src/frontend/src/views/Dashboard.tsx b/src/frontend/src/views/Dashboard.tsx new file mode 100644 index 0000000..1a4974b --- /dev/null +++ b/src/frontend/src/views/Dashboard.tsx @@ -0,0 +1,64 @@ +import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { currentUser } from '../api/auth'; +import { clearToken } from '../api/request'; +import { wrap, card, btnGhost, btn } from './ui'; + +interface MenuNode { + id: string; + fullName: string; + urlAddress?: string; + icon?: string; + parentId: string; + children: MenuNode[]; +} + +export default function Dashboard() { + const nav = useNavigate(); + const [menu, setMenu] = useState([]); + const [user, setUser] = useState(null); + + useEffect(() => { + currentUser() + .then((d) => { + setMenu(d.menuList || []); + setUser(d.userInfo); + }) + .catch(() => {}); + }, []); + + function goto(addr?: string) { + if (addr) nav('/' + addr); + } + function logout() { + clearToken(); + location.reload(); + } + + return ( +
+
+

SSW MPC Flow · 隐私计算编排

+
+ {user?.userAccount} {user?.isAdministrator ? '(管理员)' : ''} +
+

功能菜单

+ {menu.map((node) => ( +
+
{node.fullName}
+
+ {node.children.map((c) => ( + + ))} +
+
+ ))} + +
+
+ ); +} diff --git a/src/frontend/src/views/Dataset.tsx b/src/frontend/src/views/Dataset.tsx new file mode 100644 index 0000000..38d0e8a --- /dev/null +++ b/src/frontend/src/views/Dataset.tsx @@ -0,0 +1,16 @@ +import { listDatasets, saveDataset, deleteDataset } from '../api/dataset'; +import CrudPage from '../components/CrudPage'; + +/** 数据集 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function Dataset() { + return ( + + ); +} diff --git a/src/frontend/src/views/DatasetAuth.tsx b/src/frontend/src/views/DatasetAuth.tsx new file mode 100644 index 0000000..ac70817 --- /dev/null +++ b/src/frontend/src/views/DatasetAuth.tsx @@ -0,0 +1,16 @@ +import { listDatasetAuths, saveDatasetAuth, deleteDatasetAuth } from '../api/datasetauth'; +import CrudPage from '../components/CrudPage'; + +/** 数据集授权 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function DatasetAuth() { + return ( + + ); +} diff --git a/src/frontend/src/views/Datasource.tsx b/src/frontend/src/views/Datasource.tsx new file mode 100644 index 0000000..b199f70 --- /dev/null +++ b/src/frontend/src/views/Datasource.tsx @@ -0,0 +1,16 @@ +import { listDatasources, saveDatasource, deleteDatasource } from '../api/datasource'; +import CrudPage from '../components/CrudPage'; + +/** 数据源 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function Datasource() { + return ( + + ); +} diff --git a/src/frontend/src/views/DemoItem.tsx b/src/frontend/src/views/DemoItem.tsx new file mode 100644 index 0000000..b3979e5 --- /dev/null +++ b/src/frontend/src/views/DemoItem.tsx @@ -0,0 +1,101 @@ +import { useEffect, useState } from 'react'; +import request from '../api/request'; + +// 注意:字段用去前缀名(title/status/id),与 JNPF 后端 Jackson 的 f-前缀剥离一致 +interface DemoItem { + id: string; + title?: string; + status?: string; +} + +export default function DemoItem() { + const [items, setItems] = useState([]); + const [title, setTitle] = useState(''); + + async function load() { + const data = await request.get('/ssw/demo/DemoItem/List'); + setItems(data || []); + } + useEffect(() => { + load(); + }, []); + + async function add() { + if (!title) return; + await request.post('/ssw/demo/DemoItem/Save', { title, status: '草稿' }); + setTitle(''); + load(); + } + async function del(id: string) { + await request.delete(`/ssw/demo/DemoItem/Delete?id=${id}`); + load(); + } + + return ( +
+
+

DemoItem

+
+ setTitle(e.target.value)} + placeholder="标题" + style={input} + /> + +
+
    + {items.map((it) => ( +
  • + + {it.title}({it.status}) + + +
  • + ))} +
+ +
+
+ ); +} + +const wrap: React.CSSProperties = { minHeight: '100vh', padding: 40, background: '#0f1419', color: '#eee' }; +const card: React.CSSProperties = { + display: 'flex', + flexDirection: 'column', + gap: 12, + padding: 24, + background: '#1a1f26', + borderRadius: 12, + minWidth: 360, +}; +const input: React.CSSProperties = { + padding: 8, + borderRadius: 6, + border: '1px solid #333', + background: '#0f1419', + color: '#eee', +}; +const btn: React.CSSProperties = { + padding: 8, + borderRadius: 6, + border: 0, + background: '#185fa5', + color: '#fff', + cursor: 'pointer', +}; +const link: React.CSSProperties = { + padding: 8, + background: 'transparent', + border: 0, + color: '#85b7eb', + cursor: 'pointer', + textAlign: 'left', +}; diff --git a/src/frontend/src/views/Device.tsx b/src/frontend/src/views/Device.tsx new file mode 100644 index 0000000..e2970ac --- /dev/null +++ b/src/frontend/src/views/Device.tsx @@ -0,0 +1,89 @@ +import { listDevices, saveDevice, deleteDevice, syncDevices } from '../api/device'; +import CrudPage from '../components/CrudPage'; + +/** + * 设备注册 —— **TEE 节点注册表**视图。 + * + * ★ 字段严格对齐 ssw-mpc 的 TeeNode(crates/mpc-tee/src/schedule.rs): + * site / host / platform / tcb / capacity / device_present / qemu_present / + * firmware_present / image_present / kbs_reachable / kbc / measurement。 + * 平台真实取值是 `sev-snp` / `hygon-csv`(不是 edge/gateway/compute_node)。 + * + * ★ 能力位一律展示为「在位 / 缺失」,因为 TeeNode 的能力位**默认全 false, + * 漏填即被 admit 拒绝**(fail-closed),不是可选项。 + */ +export default function Device() { + return ( + + 数据来源:ssw-mpc control-plane 的节点注册表(GET /nodes)。 + 设备不是手工登记的 —— 是 TEE 节点经 hostd 向控制面自报的, + 点「从控制面同步」拉取真实注册表。 + 平台取值 sev-snp / hygon-csv; + 密钥代理模式 cc_kbc / offline_fs_kbc::null。 +
+ 状态列说明:控制面 /nodes 返回的是当前活跃节点 + (超过 TTL 90s 未心跳会被自动剔除),所以「离线」= 该节点已不在真源清单里, + 同步时会自动标出 —— 不代表节点被删除,只是此刻没在自报。 + + } + columns={[ + { key: 'online', label: '状态' }, + { key: 'key', label: '注册键(site@host)' }, + { key: 'site', label: '站点' }, + { key: 'host', label: '主机' }, + { key: 'platform', label: '平台' }, + { key: 'tcb', label: 'TCB' }, + { key: 'capacity', label: '容量' }, + { key: 'devicePresent', label: 'TEE设备' }, + { key: 'kbc', label: '密钥代理' }, + { key: 'kbsReachable', label: 'KBS可达' }, + { key: 'measurement', label: '度量' }, + { key: 'lastSeen', label: '最近自报' }, + { key: 'source', label: '来源' }, + ]} + fields={[ + { key: 'key', label: '注册键(site@host)' }, + { key: 'site', label: '站点' }, + { key: 'host', label: '主机' }, + { key: 'platform', label: '平台(sev-snp/hygon-csv)' }, + { key: 'tcb', label: 'TCB' }, + { key: 'capacity', label: '容量' }, + { key: 'kbc', label: '密钥代理模式' }, + { key: 'kbsEndpoint', label: 'KBS地址' }, + { key: 'measurement', label: '镜像度量(64 hex)' }, + { key: 'descriptor', label: 'TeeNode 描述符' }, + ]} + renderCell={(row, key) => { + if (key === 'online') { + // null = 从未同步过(人工登记),1 = 真源在线,0 = 真源里已消失。 + if (row.online === null || row.online === undefined) return '未登记'; + return row.online ? '在线' : '离线'; + } + if (key === 'devicePresent' || key === 'kbsReachable') { + return row[key] ? '在位' : '缺失'; + } + if (key === 'source') { + const s = String(row.source || ''); + return s === 'mock' ? '接口不可达(占位)' : (s || '-'); + } + if (key === 'lastSeen' && row.lastSeen) { + const n = Number(row.lastSeen); + return Number.isFinite(n) ? new Date(n * 1000).toLocaleString() : String(row.lastSeen); + } + const v = row[key]; + if (v === null || v === undefined || v === '') return '-'; + const s = String(v); + return s.length > 70 ? s.slice(0, 70) + '…' : s; + }} + api={{ list: listDevices, save: saveDevice, remove: deleteDevice }} + sync={syncDevices} + syncLabel="从控制面同步" + readonly={false} + /> + ); +} diff --git a/src/frontend/src/views/Flow.tsx b/src/frontend/src/views/Flow.tsx new file mode 100644 index 0000000..ce508e8 --- /dev/null +++ b/src/frontend/src/views/Flow.tsx @@ -0,0 +1,493 @@ +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { + ReactFlow, ReactFlowProvider, Background, BackgroundVariant, MiniMap, + Controls, Panel, MarkerType, + useReactFlow, addEdge as addFlowEdge, applyNodeChanges, applyEdgeChanges, + type NodeChange, type EdgeChange, type Connection, type NodeTypes, type Edge, +} from '@xyflow/react'; +import '@xyflow/react/dist/style.css'; +import { + listFlows, saveFlow, deleteFlow, saveCanvas, validateFlow, copyFlow, + compilePlan, operatorCatalog, engineInfo, +} from '../api/flow'; +import { startRun } from '../api/flowrun'; +import SswNode from '../components/SswNode'; +import { + CATEGORY_META, STATUS_COLOR, parseArray, + toBackendSteps, toBackendEdges, toRfNodes, toRfEdges, + type OpMap, type SswFlowNode, type SswFlowEdge, +} from '../utils/flowTransform'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from './ui'; + +/** + * 流程编排(DAG 画布)—— 从 ssw-mvp 的 jweb FlowEditor.vue 抽取语义。 + * + * 画布组件:**React Flow(@xyflow/react)**,与原项目用的 VueFlow 同属 xyflow 家族, + * API 一一对应(VueFlow→ReactFlow / useVueFlow→useReactFlow / v-model:nodes→nodes+onNodesChange)。 + * + * 画布数据保持后端形态:steps[{stepId,operatorKey,label,x,y,params}] / + * edges[{edgeId,sourceStepId,sourcePort,targetStepId,targetPort}],与 flowTransform.ts 等价。 + */ + +const nodeTypes: NodeTypes = { sswNode: SswNode as any }; + +const EDGE_STYLE = { strokeWidth: 2, stroke: '#6f8ba8' }; +const EDGE_MARKER = { type: MarkerType.ArrowClosed, color: '#6f8ba8', width: 16, height: 16 }; +const DEFAULT_EDGE_OPTIONS = { type: 'smoothstep', style: EDGE_STYLE, markerEnd: EDGE_MARKER }; + +export default function Flow() { + return ( + + + + ); +} + +function FlowInner() { + const [flows, setFlows] = useState([]); + const [flowId, setFlowId] = useState(''); + const [name, setName] = useState(''); + const [nodes, setNodes] = useState([]); + const [edges, setEdges] = useState([]); + const [catalog, setCatalog] = useState(null); + const [selected, setSelected] = useState(''); + const [linkTo, setLinkTo] = useState(''); + const [linkSourcePort, setLinkSourcePort] = useState(''); + const [linkTargetPort, setLinkTargetPort] = useState(''); + const [msg, setMsg] = useState(''); + const [plan, setPlan] = useState(''); + const [engine, setEngine] = useState(null); + const [runId, setRunId] = useState(''); + const [locked, setLocked] = useState(false); + const rf = useReactFlow(); + // 打开新流程时用来触发一次 fitView(节点是异步载入的,fitViewOnInit 只在挂载时生效) + const pendingFit = useRef(false); + + const ops: any[] = catalog + ? catalog.categories.flatMap((c: any) => (c.operators || []).map((o: any) => ({ ...o, category: c.key, categoryLabel: c.label }))) + : []; + const opMap: OpMap = useMemo( + () => Object.fromEntries(ops.map((o) => [o.key, o])) as OpMap, + [ops], + ); + + async function loadFlows() { + const data = await listFlows(); + setFlows(data || []); + if (!flowId && data?.length) openFlow(data[0]); + } + + useEffect(() => { + operatorCatalog().then(setCatalog).catch(() => {}); + engineInfo().then(setEngine).catch(() => {}); + }, []); // eslint-disable-line react-hooks/exhaustive-deps + + // 必须等算子目录到位再载入流程:节点的输入/输出端口来自算子定义, + // 目录没到就开流程 → 节点渲染出来没有 Handle,用户连不了线。 + useEffect(() => { + if (!catalog) return; + loadFlows(); + }, [catalog]); // eslint-disable-line react-hooks/exhaustive-deps + + // 节点/边异步载入完成后补一次 fitView —— 否则节点可能落在视口外看不到。 + useEffect(() => { + if (!pendingFit.current) return; + if (nodes.length === 0) return; + pendingFit.current = false; + const t = setTimeout(() => { + rf.fitView({ padding: 0.2 }).catch(() => {}); + }, 60); + return () => clearTimeout(t); + }, [nodes, rf]); + + function openFlow(f: any) { + setFlowId(f.id); setName(f.name || ''); + const steps = parseArray(f.steps); + const rawEdges = parseArray(f.edges); + setNodes(toRfNodes(steps, opMap)); + setEdges(toRfEdges(rawEdges)); + setSelected(''); setMsg(''); setPlan(''); setRunId(''); + pendingFit.current = true; + } + + async function createFlow() { + const f = await saveFlow({ name: name || '新建隐私计算流程', desc: '', steps: '[]', edges: '[]' }); + setName(''); await loadFlows(); openFlow(f); + } + + /** 把当前 React Flow 画布存回后端(steps/edges 转成后端形态) */ + async function saveCanvasNow() { + if (!flowId) return false; + const steps = toBackendSteps(nodes); + const es = toBackendEdges(edges, nodes, opMap); + await saveCanvas(flowId, steps, es); + return true; + } + + async function save() { + if (!flowId) { setMsg('请先选择或新建流程'); return; } + await saveFlow({ id: flowId, name }); + await saveCanvasNow(); + setMsg('画布已保存(steps/edges 以 JSON 字符串落 f_steps/f_edges)'); + loadFlows(); + } + async function validate() { + if (!flowId) return; + await save(); + const r: any = await validateFlow(flowId); + setMsg(r.valid ? `✅ 校验通过,拓扑序 ${r.order.length} 个节点` : '❌ ' + r.issues.map((i: any) => i.message).join(';')); + } + async function doCopy() { + const f: any = await copyFlow(flowId); + await loadFlows(); openFlow(f); setMsg('已复制流程'); + } + async function showPlan() { + if (!flowId) return; + await save(); + const r: any = await compilePlan(flowId); + setPlan(`# ${r.command}\n# ${r.note}\n\n${r.plan}`); + setMsg('已编译 ssw-mpc 作业计划(mpc orch run)'); + } + async function run() { + if (!flowId) return; + await save(); + const r: any = await startRun({ flowId, trigger: 'MANUAL', mode: 'FULL' }); + setRunId(r.id); + setMsg(`运行已发起:${r.id}`); + } + async function removeFlow(id: string) { + if (!confirm('确认删除该流程?')) return; + await deleteFlow(id); + setFlowId(''); setNodes([]); setEdges([]); loadFlows(); + } + + // ---------------- React Flow 交互 ---------------- + + const onNodesChange = useCallback((changes: NodeChange[]) => { + setNodes((nds) => applyNodeChanges(changes, nds)); + }, []); + const onEdgesChange = useCallback((changes: EdgeChange[]) => { + setEdges((eds) => applyEdgeChanges(changes, eds)); + }, []); + + /** + * 拖线落点 —— sourceHandle/targetHandle 就是算子的端口 key, + * 必须原样带进 edge(否则多端口算子的第二个端口会被吞掉)。 + */ + const onConnect = useCallback((conn: Connection) => { + const c = conn as Connection & Partial; + setEdges((eds) => addFlowEdge({ + ...DEFAULT_EDGE_OPTIONS, + ...c, + id: `e-${c.source}-${c.sourceHandle || 'out'}-${c.target}-${c.targetHandle || 'in'}-${Date.now().toString(36)}`, + }, eds) as SswFlowEdge[]); + setMsg(`已连线 ${c.source} [${c.sourceHandle || 'out'}] → ${c.target} [${c.targetHandle || 'in'}]`); + }, []); + + const onNodeClick = useCallback((_e: any, node: SswFlowNode) => { + setSelected(node.id); + }, []); + + const addNode = (op: any) => { + const id = `n-${Date.now().toString(36)}-${Math.floor(Math.random() * 1e4).toString(36)}`; + const category = op.category || (op.key || '').split('.')[0]; + const meta = CATEGORY_META[category] || { color: '#2f5f9e', icon: '◇' }; + const node: SswFlowNode = { + id, + type: 'sswNode', + position: { x: 60 + (nodes.length % 4) * 250, y: 60 + Math.floor(nodes.length / 4) * 160 }, + data: { + label: op.label, + operatorKey: op.key, + category, + color: meta.color, + icon: meta.icon, + params: Object.fromEntries((op.params || []) + .filter((p: any) => p.default !== undefined) + .map((p: any) => [p.key, p.default])), + inputs: op.inputs || [], + outputs: op.outputs || [], + mpcStatus: op.mpc?.status, + mpcCrate: op.mpc?.crate, + mpcColor: STATUS_COLOR[op.mpc?.status], + }, + } as SswFlowNode; + setNodes((prev) => [...prev, node]); + setSelected(id); setMsg(`已添加节点:${op.key}(${op.mpc?.status || '-'})`); + }; + + function removeSelected() { + setNodes((prev) => prev.filter((n) => n.id !== selected)); + setEdges((prev) => prev.filter((e) => e.source !== selected && e.target !== selected)); + setSelected(''); + } + + /** + * 属性面板改参数 —— 走 React state 的不可变更新。 + * (ssw-mvp 在 VueFlow 里必须用 updateNodeData 写回内部 store, + * 因为原地改 node.data 不触发 Vue 响应式;React 侧不需要这层, + * state 变更后 会自动同步进内部 store。) + */ + function updateStep(patch: Partial) { + if (!selected) return; + setNodes((prev) => prev.map((n) => (n.id === selected ? { ...n, data: { ...n.data, ...patch } } : n))); + } + + function addEdge() { + if (!selected || !linkTo || selected === linkTo) return; + const src = opMap[nodes.find((n) => n.id === selected)?.data?.operatorKey || '']; + const tgt = opMap[nodes.find((n) => n.id === linkTo)?.data?.operatorKey || '']; + if (!(tgt?.inputs || []).length) { setMsg('目标节点没有输入端口'); return; } + // 端口必须显式选:prep.intersect 有 left/right 两个输入,model.predict 有 model/in 两个输入, + // 固定取 inputs[0] 会让第二个端口永远连不上(校验器随后报「输入端口未连线」)。 + const srcPorts = (src?.outputs || []).map((o: any) => o.key); + const tgtPorts = (tgt?.inputs || []).map((i: any) => i.key); + const sourcePort = srcPorts.includes(linkSourcePort) ? linkSourcePort : (srcPorts[0] || 'out'); + const targetPort = tgtPorts.includes(linkTargetPort) ? linkTargetPort : (tgtPorts[0] || 'in'); + const edgeId = `e-${selected}-${sourcePort}-${linkTo}-${targetPort}-${Date.now().toString(36)}`; + setEdges((prev) => [...prev, { + ...DEFAULT_EDGE_OPTIONS, + id: edgeId, source: selected, target: linkTo, + sourceHandle: sourcePort, targetHandle: targetPort, + } as SswFlowEdge]); + setMsg(`已连线 ${selected} [${sourcePort}] → ${linkTo} [${targetPort}]`); + } + + function removeEdge(id: string) { + setEdges((prev) => prev.filter((e) => e.id !== id)); + } + + const sel = nodes.find((n) => n.id === selected); + const selOp = sel ? opMap[sel.data.operatorKey] : null; + // 只列出与当前节点相关的连线(计数与列表必须一致) + const selEdges = edges.filter((e) => e.source === selected || e.target === selected); + + return ( +
+
+
+

隐私计算流程编排

+ + 执行底座:{engine?.driver === 'mpc' ? 'ssw-mpc(Rust CLI)' : 'simulation(本地模拟)'} + {engine?.mpc && !engine.mpc.available && ` · ${engine.mpc.detail}`} + + +
+ + {/* 流程选择 + 操作条 */} +
+ + setName(e.target.value)} /> + + + + + + + {flowId && } +
+ {msg &&
{msg}
} + {runId && ( +
+ 运行已发起 {runId} → 打开运行监控 +
+ )} + +
+ {/* 算子目录 */} +
+
算子目录 · {ops.length} 个
+ {catalog?.categories.map((c: any) => ( +
+
+ {CATEGORY_META[c.key]?.icon} {c.label} +
+ {(c.operators || []).map((op: any) => ( + + ))} +
+ ))} + {!catalog &&
加载中…
} +
+ + {/* 画布 —— React Flow */} +
+ + + n?.data?.color || '#1677ff'} + maskColor="rgba(13,18,24,0.7)" + /> + + +
+ + +
+
+ {nodes.length === 0 && ( + +
从左侧点击算子添加节点 · 拖动端口连线
+
+ )} +
+
+ + {/* 属性面板 */} +
+
节点属性
+ {!sel &&
点击画布节点进行编辑
} + {sel && ( + <> +
{sel.data.operatorKey}
+ + {(selOp?.params || []).map((p: any) => ( + + ))} +
+
连线到节点
+ + {/* 源端口:多输出算子(prep.split 的 train/test、prep.binning 的 out/rule)必须显式选 */} + {(selOp?.outputs || []).length > 1 && ( + + )} + {/* 目标端口:prep.intersect(left/right)、model.predict(model/in) 必须显式选 */} + {(() => { + const tgtOp = opMap[nodes.find((n) => n.id === linkTo)?.data?.operatorKey || '']; + const ins = tgtOp?.inputs || []; + if (ins.length <= 1) return null; + return ( + + ); + })()} + +
+
+ 已有连线 {selEdges.length} 条 +
    + {selEdges.map((e) => ( +
  • + {/* 出边显示对端节点的入端口;入边显示落在本节点上的端口 */} + {e.source === selected + ? <>→ {e.target.slice(0, 8)} [{e.targetHandle || 'in'}] + : <>← {e.source.slice(0, 8)} [{e.targetHandle || 'in'}]} + +
  • + ))} + {selEdges.length === 0 &&
  • 暂无
  • } +
+
+ + + )} +
+
+ + {plan && ( +
+

ssw-mpc 作业计划(mpc orch run --plan)

+
{plan}
+
+ )} + +

流程列表

+ + + + {flows.map((f) => ( + + + + + + + ))} + {flows.length === 0 && } + +
名称节点/连线上次运行操作
{f.name}{parseArray(f.steps).length} / {parseArray(f.edges).length}{f.lastRunStatus || '-'}
暂无流程,先新建一个
+
+
+ ); +} diff --git a/src/frontend/src/views/FlowRun.tsx b/src/frontend/src/views/FlowRun.tsx new file mode 100644 index 0000000..774df5a --- /dev/null +++ b/src/frontend/src/views/FlowRun.tsx @@ -0,0 +1,176 @@ +import { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { startRun, stopRun, runOverview, recentRuns } from '../api/flowrun'; +import { engineInfo } from '../api/flow'; +import { wrap, card, btn, btnDanger, btnGhost, tableStyle, th, td } from './ui'; + +/** 运行监控 —— 替代 ssw-mvp 的 TeeExecutionFlow.vue + SSE,改为 Events 增量轮询。 */ +const STATUS_COLOR: Record = { + PENDING: '#9aa7b5', RUNNING: '#85b7eb', SUCCESS: '#7fd1a4', + FAILED: '#ff8a80', STOPPED: '#e0b06a', SKIPPED: '#7a8492', +}; +const LEVEL_COLOR: Record = { INFO: '#9aa7b5', WARN: '#e0b06a', ERROR: '#ff8a80' }; + +export default function FlowRun() { + const [runs, setRuns] = useState([]); + const [runId, setRunId] = useState(''); + const [detail, setDetail] = useState(null); + const [engine, setEngine] = useState(null); + const [err, setErr] = useState(''); + + async function loadRuns() { + try { setRuns((await recentRuns(50)) || []); } catch (e: any) { setErr(e.message); } + } + useEffect(() => { + loadRuns(); + engineInfo().then(setEngine).catch(() => {}); + }, []); + + // 运行中按 1.2s 轮询(对应原 SSE 的 EventSource,前端零依赖) + useEffect(() => { + if (!runId) return; + let alive = true; + const tick = async () => { + try { + const d: any = await runOverview(runId); + if (alive) { setDetail(d); setErr(''); } + } catch (e: any) { if (alive) setErr(e.message); } + }; + tick(); + const t = setInterval(tick, 1200); + return () => { alive = false; clearInterval(t); }; + }, [runId]); + + async function stop() { await stopRun(runId); setErr('已下发终止指令'); loadRuns(); } + async function rerun() { + const d: any = await startRun({ flowId: detail?.run?.flowId, trigger: 'RERUN', mode: 'FULL' }); + setRunId(d.id); loadRuns(); + } + + const run = detail?.run; + const steps = detail?.steps || []; + const events = detail?.events || []; + const artifacts = detail?.artifacts || []; + const busy = run && ['PENDING', 'RUNNING'].includes(run.status); + + return ( +
+
+
+

运行监控

+ + + {runId && busy && } + {runId && } + → 去流程编排 +
+ {err &&
{err}
} + + {/* 引擎能力条 */} + {engine && ( +
+ 驱动 {engine.driver} · + 引擎 {engine.engines?.join(' / ')} · + ssw-mpc 二进制 {engine.mpc?.available ? '✅ 可用' : '⚠ 未探测到'} · + 算子能力 native {engine.summary?.native} / partial {engine.summary?.partial} / + local {engine.summary?.local} / unsupported {engine.summary?.unsupported} · + 真实下发 {engine.realExec ? '开启' : '关闭(产物标记 simulated)'} + {!engine.mpc?.available &&
{engine.mpc?.detail}
} +
+ )} + +
+ {/* 运行列表 */} +
+

最近运行

+
+ {runs.map((r) => ( +
setRunId(r.id)} + style={{ padding: 10, marginBottom: 6, borderRadius: 8, cursor: 'pointer', + background: runId === r.id ? '#243448' : '#121820', + border: `1px solid ${runId === r.id ? '#85b7eb' : '#2a3340'}` }}> +
{r.flowName || r.flowId}
+
+ {r.status} · + {r.trigger} · {r.runMode || 'FULL'} · {r.costMs ?? '-'} ms +
+
{r.id}
+
+ ))} + {runs.length === 0 &&
暂无运行记录
} +
+
+ + {/* 详情 */} +
+ {!runId &&
从左侧选择一次运行查看详情
} + {run && ( + <> +
+ + + + +
+ +

步骤(拓扑序)

+ + + + {steps.map((s: any) => ( + + + + + + + + + ))} + {steps.length === 0 && } + +
序算子状态进度耗时错误
{s.seq}{s.label}
{s.operatorKey}
{s.status}{s.progress}%{s.costMs ?? '-'}{s.errorMsg || '-'}
暂无步骤
+ +

事件流(run_event.f_sort_code 增量)

+
+ {events.map((e: any) => ( +
+ #{e.sortCode} [{e.level}] {e.message} +
+ ))} + {events.length === 0 &&
暂无事件
} +
+ +

计算产物

+ + + + {artifacts.map((a: any) => ( + + + + + + + + ))} + {artifacts.length === 0 && } + +
端口类型标题摘要行数
{a.portKey}{a.type}{a.title}{a.summary}{a.rowCount}
暂无产物
+ + )} +
+
+
+
+ ); +} + +function Badge({ label, value, color }: { label: string; value: string; color?: string }) { + return ( +
+
{label}
+
{value}
+
+ ); +} diff --git a/src/frontend/src/views/FlowSchedule.tsx b/src/frontend/src/views/FlowSchedule.tsx new file mode 100644 index 0000000..bf4d3f6 --- /dev/null +++ b/src/frontend/src/views/FlowSchedule.tsx @@ -0,0 +1,16 @@ +import { listFlowSchedules, saveFlowSchedule, deleteFlowSchedule } from '../api/flowschedule'; +import CrudPage from '../components/CrudPage'; + +/** 周期调度 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function FlowSchedule() { + return ( + + ); +} diff --git a/src/frontend/src/views/FlowStepRun.tsx b/src/frontend/src/views/FlowStepRun.tsx new file mode 100644 index 0000000..b8c06f2 --- /dev/null +++ b/src/frontend/src/views/FlowStepRun.tsx @@ -0,0 +1,16 @@ +import { listFlowStepRuns, saveFlowStepRun, deleteFlowStepRun } from '../api/flowsteprun'; +import CrudPage from '../components/CrudPage'; + +/** 步骤运行 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function FlowStepRun() { + return ( + + ); +} diff --git a/src/frontend/src/views/Login.tsx b/src/frontend/src/views/Login.tsx new file mode 100644 index 0000000..a578d85 --- /dev/null +++ b/src/frontend/src/views/Login.tsx @@ -0,0 +1,81 @@ +import { useState } from 'react'; +import { useNavigate, useLocation } from 'react-router-dom'; +import { login } from '../api/auth'; +import { setToken } from '../api/request'; +import { encryptPassword } from '../utils/cipher'; + +export default function Login() { + const [account, setAccount] = useState('admin'); + const [password, setPassword] = useState('123456'); + const [err, setErr] = useState(''); + const nav = useNavigate(); + const loc = useLocation(); + + async function onSubmit(e: React.FormEvent) { + e.preventDefault(); + setErr(''); + try { + const hex = encryptPassword(password); + const res = await login(account, hex); + setToken(res.token); + const next = (loc.state as any)?.from?.pathname || '/'; + nav(next); + } catch (e: any) { + setErr(e.message || '登录失败'); + } + } + + return ( +
+
+

SSW JNPF Lite · React

+ setAccount(e.target.value)} placeholder="账号" style={input} /> + setPassword(e.target.value)} + type="password" + placeholder="密码" + style={input} + /> + {err &&
{err}
} + +
默认 admin / 123456
+
+
+ ); +} + +const wrap: React.CSSProperties = { + minHeight: '100vh', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: '#0f1419', + color: '#eee', +}; +const card: React.CSSProperties = { + display: 'flex', + flexDirection: 'column', + gap: 12, + padding: 24, + background: '#1a1f26', + borderRadius: 12, + width: 300, +}; +const input: React.CSSProperties = { + padding: 8, + borderRadius: 6, + border: '1px solid #333', + background: '#0f1419', + color: '#eee', +}; +const btn: React.CSSProperties = { + padding: 10, + borderRadius: 6, + border: 0, + background: '#185fa5', + color: '#fff', + cursor: 'pointer', +}; diff --git a/src/frontend/src/views/MenuManage.tsx b/src/frontend/src/views/MenuManage.tsx new file mode 100644 index 0000000..35f5438 --- /dev/null +++ b/src/frontend/src/views/MenuManage.tsx @@ -0,0 +1,155 @@ +import { useEffect, useState } from 'react'; +import * as api from '../api/sys'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from './ui'; + +export default function MenuManage() { + const [rows, setRows] = useState([]); + const [editing, setEditing] = useState(null); + const [form, setForm] = useState({ + fullName: '', + urlAddress: '', + parentId: '0', + type: 2, + icon: '', + sortCode: 0, + }); + + async function load() { + setRows(await api.listModules()); + } + useEffect(() => { + load(); + }, []); + + const nameOf = (id: string) => + id === '0' ? '(根)' : (rows.find((r) => r.id === id)?.fullName ?? id); + + function openEdit(r?: any) { + if (r) + setForm({ + fullName: r.fullName, + urlAddress: r.urlAddress || '', + parentId: r.parentId || '0', + type: r.type ?? 2, + icon: r.icon || '', + sortCode: r.sortCode ?? 0, + }); + else setForm({ fullName: '', urlAddress: '', parentId: '0', type: 2, icon: '', sortCode: 0 }); + setEditing(r || {}); + } + async function submit() { + if (!form.fullName) return alert('菜单名必填'); + await api.saveModule({ ...form, id: editing?.id }); + setEditing(null); + await load(); + } + async function del(id: string) { + if (!confirm('确认删除该菜单?')) return; + await api.deleteModule(id); + await load(); + } + + return ( +
+
+

菜单管理

+ + + + + + + + + + + + + {rows.map((r) => ( + + + + + + + + ))} + +
名称地址(key)上级排序操作
{r.fullName}{r.urlAddress}{nameOf(r.parentId)}{r.sortCode} + {' '} + +
+ + {editing && ( +
+

{editing.id ? '编辑' : '新增'}菜单

+
+ setForm({ ...form, fullName: e.target.value })} + /> + setForm({ ...form, urlAddress: e.target.value })} + /> + + + setForm({ ...form, icon: e.target.value })} + /> + setForm({ ...form, sortCode: +e.target.value })} + /> +
+
+ + +
+
+ )} +
+
+ ); +} diff --git a/src/frontend/src/views/OrganizeManage.tsx b/src/frontend/src/views/OrganizeManage.tsx new file mode 100644 index 0000000..baf69ef --- /dev/null +++ b/src/frontend/src/views/OrganizeManage.tsx @@ -0,0 +1,112 @@ +import { useEffect, useState } from 'react'; +import * as api from '../api/sys'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from './ui'; + +export default function OrganizeManage() { + const [rows, setRows] = useState([]); + const [editing, setEditing] = useState(null); + const [form, setForm] = useState({ fullName: '', parentId: '0' }); + + async function load() { + setRows(await api.listOrganize()); + } + useEffect(() => { + load(); + }, []); + + const nameOf = (id: string) => + id === '0' ? '(根)' : (rows.find((r) => r.id === id)?.fullName ?? id); + + function openEdit(r?: any) { + if (r) setForm({ fullName: r.fullName, parentId: r.parentId || '0' }); + else setForm({ fullName: '', parentId: '0' }); + setEditing(r || {}); + } + async function submit() { + if (!form.fullName) return alert('机构名必填'); + await api.saveOrganize({ ...form, id: editing?.id }); + setEditing(null); + await load(); + } + async function del(id: string) { + if (!confirm('确认删除该机构?')) return; + try { + await api.deleteOrganize(id); + } catch (e: any) { + return alert(e.message || '删除失败'); + } + await load(); + } + + return ( +
+
+

机构管理

+ + + + + + + + + + + {rows.map((r) => ( + + + + + + ))} + +
名称上级操作
{r.fullName}{nameOf(r.parentId)} + {' '} + +
+ + {editing && ( +
+

{editing.id ? '编辑' : '新增'}机构

+
+ setForm({ ...form, fullName: e.target.value })} + /> + +
+
+ + +
+
+ )} +
+
+ ); +} diff --git a/src/frontend/src/views/Party.tsx b/src/frontend/src/views/Party.tsx new file mode 100644 index 0000000..7c022b3 --- /dev/null +++ b/src/frontend/src/views/Party.tsx @@ -0,0 +1,16 @@ +import { listParties, saveParty, deleteParty } from '../api/party'; +import CrudPage from '../components/CrudPage'; + +/** 参与方 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function Party() { + return ( + + ); +} diff --git a/src/frontend/src/views/Product.tsx b/src/frontend/src/views/Product.tsx new file mode 100644 index 0000000..7029228 --- /dev/null +++ b/src/frontend/src/views/Product.tsx @@ -0,0 +1,93 @@ +import { useEffect, useState } from 'react'; +import { listProducts, saveProduct, deleteProduct } from '../api/product'; +import { wrap, card, btn, btnDanger, input as inputStyle, tableStyle, th, td } from './ui'; + +// 字段用去前缀名:id / title / price(后端 Jackson 会剥掉 f_ 前缀) +interface Product { + id: string; + title?: string; + price?: string; +} + +export default function Product() { + const [items, setItems] = useState([]); + const [title, setTitle] = useState(''); + const [price, setPrice] = useState(''); + + async function load() { + const data = await listProducts(); + setItems(data || []); + } + useEffect(() => { + load(); + }, []); + + async function add() { + if (!title) return; + await saveProduct({ title, price: price || '0.00' }); + setTitle(''); + setPrice(''); + load(); + } + async function del(id: string) { + await deleteProduct(id); + load(); + } + + return ( +
+
+

产品管理

+
+ setTitle(e.target.value)} + placeholder="产品名称" + style={inputStyle} + /> + setPrice(e.target.value)} + placeholder="价格" + style={{ ...inputStyle, width: 100 }} + /> + + +
+ + + + + + + + + + {items.map((it) => ( + + + + + + ))} + {items.length === 0 && ( + + + + )} + +
名称价格操作
{it.title}¥{it.price} + +
+ 暂无数据 +
+
+
+ ); +} diff --git a/src/frontend/src/views/Project.tsx b/src/frontend/src/views/Project.tsx new file mode 100644 index 0000000..d9a693e --- /dev/null +++ b/src/frontend/src/views/Project.tsx @@ -0,0 +1,16 @@ +import { listProjects, saveProject, deleteProject } from '../api/project'; +import CrudPage from '../components/CrudPage'; + +/** 项目 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function Project() { + return ( + + ); +} diff --git a/src/frontend/src/views/ProjectParty.tsx b/src/frontend/src/views/ProjectParty.tsx new file mode 100644 index 0000000..383e0b2 --- /dev/null +++ b/src/frontend/src/views/ProjectParty.tsx @@ -0,0 +1,16 @@ +import { listProjectParties, saveProjectParty, deleteProjectParty } from '../api/projectparty'; +import CrudPage from '../components/CrudPage'; + +/** 项目参与方 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function ProjectParty() { + return ( + + ); +} diff --git a/src/frontend/src/views/RoleManage.tsx b/src/frontend/src/views/RoleManage.tsx new file mode 100644 index 0000000..d140892 --- /dev/null +++ b/src/frontend/src/views/RoleManage.tsx @@ -0,0 +1,153 @@ +import { useEffect, useState } from 'react'; +import * as api from '../api/sys'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from './ui'; + +export default function RoleManage() { + const [rows, setRows] = useState([]); + const [modules, setModules] = useState([]); + const [editing, setEditing] = useState(null); + const [form, setForm] = useState({ fullName: '', enCode: '', description: '' }); + // 授权面板 + const [authRoleId, setAuthRoleId] = useState(''); + const [checked, setChecked] = useState([]); + + async function load() { + setRows(await api.listRoles()); + setModules(await api.listModules()); + } + useEffect(() => { + load(); + }, []); + + function openEdit(r?: any) { + if (r) setForm({ fullName: r.fullName, enCode: r.enCode || '', description: r.description || '' }); + else setForm({ fullName: '', enCode: '', description: '' }); + setEditing(r || {}); + } + async function submit() { + if (!form.fullName) return alert('角色名必填'); + await api.saveRole({ ...form, id: editing?.id }); + setEditing(null); + await load(); + } + async function del(id: string) { + if (!confirm('确认删除该角色?')) return; + await api.deleteRole(id); + await load(); + } + async function openAuth(roleId: string) { + setAuthRoleId(roleId); + const ids = (await api.roleModules(roleId)) || []; + setChecked(ids); + } + async function saveAuth() { + await api.saveRoleModules(authRoleId, checked); + alert('授权已保存'); + } + + return ( +
+
+

角色管理

+ + + + + + + + + + + {rows.map((r) => ( + + + + + + ))} + +
角色名编码操作
{r.fullName}{r.enCode} + {' '} + {' '} + +
+ + {editing && ( +
+

{editing.id ? '编辑' : '新增'}角色

+
+ setForm({ ...form, fullName: e.target.value })} + /> + setForm({ ...form, enCode: e.target.value })} + /> + setForm({ ...form, description: e.target.value })} + /> +
+
+ + +
+
+ )} + + {authRoleId && ( +
+

角色菜单授权({authRoleId})

+
+ {modules.map((m) => ( + + ))} +
+
+ + +
+
+ )} +
+
+ ); +} diff --git a/src/frontend/src/views/RunEvent.tsx b/src/frontend/src/views/RunEvent.tsx new file mode 100644 index 0000000..2ddd998 --- /dev/null +++ b/src/frontend/src/views/RunEvent.tsx @@ -0,0 +1,16 @@ +import { listRunEvents, saveRunEvent, deleteRunEvent } from '../api/runevent'; +import CrudPage from '../components/CrudPage'; + +/** 运行事件 —— 用通用 CRUD 页承载,字段为去前缀名(JNPF Jackson 剥 f_)。 */ +export default function RunEvent() { + return ( + + ); +} diff --git a/src/frontend/src/views/UserManage.tsx b/src/frontend/src/views/UserManage.tsx new file mode 100644 index 0000000..ee379ce --- /dev/null +++ b/src/frontend/src/views/UserManage.tsx @@ -0,0 +1,148 @@ +import { useEffect, useState } from 'react'; +import * as api from '../api/sys'; +import { wrap, card, btn, btnDanger, btnGhost, input, tableStyle, th, td } from './ui'; + +export default function UserManage() { + const [rows, setRows] = useState([]); + const [roleOptions, setRoleOptions] = useState([]); + const [editing, setEditing] = useState(null); + const [form, setForm] = useState({ + account: '', + realName: '', + password: '', + isAdministrator: false, + roleIds: [] as string[], + }); + + async function load() { + setRows(await api.listUsers()); + setRoleOptions(await api.listRoles()); + } + useEffect(() => { + load(); + }, []); + + function openEdit(r?: any) { + if (r) + setForm({ + account: r.account, + realName: r.realName || '', + password: '', + isAdministrator: r.isAdministrator === 1, + roleIds: r.roleIds || [], + }); + else setForm({ account: '', realName: '', password: '', isAdministrator: false, roleIds: [] }); + setEditing(r || {}); + } + async function submit() { + if (!form.account) return alert('账号必填'); + await api.saveUser({ ...form, id: editing?.id }); + setEditing(null); + await load(); + } + async function del(id: string) { + if (!confirm('确认删除该用户?')) return; + await api.deleteUser(id); + await load(); + } + + return ( +
+
+

用户管理

+ + + + + + + + + + + + + {rows.map((r) => ( + + + + + + + + ))} + +
账号姓名角色管理员操作
{r.account}{r.realName}{(r.roleNames || []).join(',')}{r.isAdministrator === 1 ? '是' : '否'} + {' '} + +
+ + {editing && ( +
+

{editing.id ? '编辑' : '新增'}用户

+
+ setForm({ ...form, account: e.target.value })} + /> + setForm({ ...form, realName: e.target.value })} + /> + setForm({ ...form, password: e.target.value })} + /> + + +
+
+ + +
+
+ )} +
+
+ ); +} diff --git a/src/frontend/src/views/ui.ts b/src/frontend/src/views/ui.ts new file mode 100644 index 0000000..d6ff532 --- /dev/null +++ b/src/frontend/src/views/ui.ts @@ -0,0 +1,46 @@ +import { CSSProperties } from 'react'; + +export const wrap: CSSProperties = { + minHeight: '100vh', + padding: 24, + background: '#0f1419', + color: '#eee', + fontFamily: 'system-ui, sans-serif', +}; +export const card: CSSProperties = { + background: '#1a1f26', + borderRadius: 12, + padding: 20, +}; +export const btn: CSSProperties = { + padding: '8px 14px', + borderRadius: 6, + border: 0, + background: '#185fa5', + color: '#fff', + cursor: 'pointer', +}; +export const btnDanger: CSSProperties = { ...btn, background: '#a1322b' }; +export const btnGhost: CSSProperties = { ...btn, background: '#2a3340' }; +export const input: CSSProperties = { + padding: 8, + borderRadius: 6, + border: '1px solid #333', + background: '#0f1419', + color: '#eee', +}; +export const tableStyle: CSSProperties = { + width: '100%', + borderCollapse: 'collapse', + marginTop: 12, +}; +export const th: CSSProperties = { + textAlign: 'left', + padding: '8px', + borderBottom: '1px solid #2a3340', + color: '#9aa7b5', +}; +export const td: CSSProperties = { + padding: '8px', + borderBottom: '1px solid #1f2630', +}; diff --git a/src/frontend/tsconfig.json b/src/frontend/tsconfig.json new file mode 100644 index 0000000..0dd4381 --- /dev/null +++ b/src/frontend/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "strict": false, + "noUnusedLocals": false, + "noUnusedParameters": false, + "esModuleInterop": true + }, + "include": ["src"] +} diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts new file mode 100644 index 0000000..fcb0b8d --- /dev/null +++ b/src/frontend/vite.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + server: { + host: '127.0.0.1', // macOS 上 vite 默认只 bind ::1 (IPv6),强制 IPv4 避免 127.0.0.1 被 reset + port: 5173, + strictPort: true, // 端口被占直接报错而不是自动换端口(让 perm-smoke 端口断言稳定) + proxy: { + // 所有 /api 请求转发到 NestJS 后端(30000),与 JNPF 网关代理一致 + '/api': 'http://127.0.0.1:30000', + }, + }, +});