- Stripped 11 business crates (health, ai, dialysis, plugins) - Cleaned AppState, AppConfig, main.rs from business coupling - Reduced migrations from 169 to 53 (base-only) - Removed health_provider trait from erp-core - Removed business integration tests - Removed gateway rate limiting middleware - Base capabilities: auth, RBAC, JWT, config, workflow, message, plugin, audit, crypto, RLS, multi-tenant Cargo check: OK Cargo test: OK
55 lines
1.9 KiB
Plaintext
55 lines
1.9 KiB
Plaintext
package erp:plugin;
|
||
|
||
/// 宿主暴露给插件的 API(插件 import 这些函数)
|
||
interface host-api {
|
||
/// 插入记录(宿主自动注入 tenant_id, id, created_at 等标准字段)
|
||
db-insert: func(entity: string, data: list<u8>) -> result<list<u8>, string>;
|
||
|
||
/// 查询记录(自动注入 tenant_id 过滤 + 软删除过滤)
|
||
db-query: func(entity: string, filter: list<u8>, pagination: list<u8>) -> result<list<u8>, string>;
|
||
|
||
/// 更新记录(自动检查 version 乐观锁)
|
||
db-update: func(entity: string, id: string, data: list<u8>, version: s64) -> result<list<u8>, string>;
|
||
|
||
/// 软删除记录
|
||
db-delete: func(entity: string, id: string) -> result<_, string>;
|
||
|
||
/// 发布领域事件
|
||
event-publish: func(event-type: string, payload: list<u8>) -> result<_, string>;
|
||
|
||
/// 读取系统配置
|
||
config-get: func(key: string) -> result<list<u8>, string>;
|
||
|
||
/// 写日志(自动关联 tenant_id + plugin_id)
|
||
log-write: func(level: string, message: string);
|
||
|
||
/// 获取当前用户信息
|
||
current-user: func() -> result<list<u8>, string>;
|
||
|
||
/// 检查当前用户权限
|
||
check-permission: func(permission: string) -> result<bool, string>;
|
||
|
||
/// 根据编号规则生成下一个编号(如 INV-2026-0001)
|
||
numbering-generate: func(rule-key: string) -> result<string, string>;
|
||
|
||
/// 读取插件配置项
|
||
setting-get: func(key: string) -> result<list<u8>, string>;
|
||
}
|
||
|
||
/// 插件导出的 API(宿主调用这些函数)
|
||
interface plugin-api {
|
||
/// 插件初始化(加载时调用一次)
|
||
init: func() -> result<_, string>;
|
||
|
||
/// 租户创建时调用
|
||
on-tenant-created: func(tenant-id: string) -> result<_, string>;
|
||
|
||
/// 处理订阅的事件
|
||
handle-event: func(event-type: string, payload: list<u8>) -> result<_, string>;
|
||
}
|
||
|
||
world plugin-world {
|
||
import host-api;
|
||
export plugin-api;
|
||
}
|