概述
每个插件根目录都要有 module.metadata.json。目录名、metadata.name 与包身份必须一致。该文件会复制到 available-plugins 与 installed-plugins。
- 路径 — plugins/<plugin-name>/module.metadata.json
- 用于 @Module name、DI 与安装界面
- pluginDependencies 决定启动 / 注册顺序
1. 字段
| 字段 | 类型 | 用途 |
|---|---|---|
| name | string | 唯一插件 id — 须与目录名一致 |
| type | string | 保留(常为 "") |
| pluginVersion | string | 本插件 semver |
| description | string | 模块 / 安装界面简述 |
| moduleEntryObject | string | 后端入口导出名(通常 "Module") |
| requiredBasedVersion | string | 兼容的核心 / @quan-erp/* 版本线 |
| pluginDependencies | object | 其他插件名 → 须先加载的 semver 范围 |
2. 示例
见英文代码块中的 inventory 示例。
JSONplugins/inventory/module.metadata.json
1{
2 "name": "inventory",
3 "type": "",
4 "pluginVersion": "1.0.0",
5 "description": "Inventory management system",
6 "moduleEntryObject": "Module",
7 "requiredBasedVersion": "1.0.0",
8 "pluginDependencies": {
9 "products": "^1.0.0",
10 "accounting": "^1.0.0"
11 }
12}3. pluginDependencies
键是提供者的 metadata.name;值是其 pluginVersion 的 semver 范围。核心先加载提供者,缺失或不兼容会阻止启动。
- 使用 @Inject(Service, "other-plugin") 时必须声明
- {} 表示无插件依赖
- 提供者升版本时同步范围
- 参见「工作原理」与「导出服务」
规则
- name === plugins/ 下目录名
- requiredBasedVersion 对齐运行中的核心
- 使用 import … with { type: "json" }
- 重命名或升版本后重建并重新安装