@chatbi-v/core 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -20
- package/dist/chunk-O74KYN5N.mjs +1 -0
- package/dist/config-manager-LQITPSUA.mjs +1 -0
- package/dist/domain/plugin-manager.d.ts +9 -0
- package/dist/domain/plugin-runtime.d.ts +5 -0
- package/dist/index.cjs +6 -2515
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +6 -2376
- package/package.json +14 -14
- package/dist/chunk-IOE2RMEZ.mjs +0 -75
- package/dist/config-manager-YVMVSPES.mjs +0 -8
package/README.md
CHANGED
|
@@ -2,35 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
ChatBI 核心模块,提供插件管理、基础设施接口及通用 API 引擎。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 模块功能说明
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- **微内核架构**: 实现插件的注册、生命周期管理与隔离。
|
|
8
|
+
- **领域驱动设计**: 严格区分领域逻辑 (`domain`)、外部接口 (`ports`) 和具体实现 (`adapters`)。
|
|
9
|
+
- **API 引擎**: 统一的 API 请求管理,支持同步、流式请求及拦截器。
|
|
10
|
+
- **存储管理**: 提供隔离的存储适配器,确保插件数据互不干扰。
|
|
10
11
|
|
|
11
|
-
##
|
|
12
|
+
## 安装和使用方法
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
- `api/`: 通用 API 请求引擎。
|
|
15
|
-
- `domain/`: 核心领域逻辑(插件管理器、运行时、沙箱)。
|
|
16
|
-
- `ports/`: 核心接口定义(端口)。
|
|
17
|
-
|
|
18
|
-
## 功能
|
|
14
|
+
### 安装
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @chatbi-v/core
|
|
18
|
+
```
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
### 使用示例
|
|
25
21
|
|
|
26
22
|
```typescript
|
|
27
|
-
import {
|
|
23
|
+
import { PluginManager, LocalStorageAdapter } from '@chatbi-v/core';
|
|
24
|
+
|
|
25
|
+
// 初始化插件管理器
|
|
26
|
+
const storage = new LocalStorageAdapter();
|
|
27
|
+
const pluginManager = new PluginManager(storage);
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
// 注册并初始化插件
|
|
30
30
|
pluginManager.register({
|
|
31
31
|
id: 'my-plugin',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
metadata: { name: 'My Plugin', type: 'business' },
|
|
33
|
+
onLoad: async (context) => {
|
|
34
|
+
console.log('Plugin loaded', context.pluginId);
|
|
35
|
+
}
|
|
35
36
|
});
|
|
36
37
|
```
|
|
38
|
+
|
|
39
|
+
## API 文档链接
|
|
40
|
+
|
|
41
|
+
详细 API 文档请参考 [docs/index.html](https://github.com/your-repo/docs/index.html) 或运行 `npm run docs:dev` 本地查看。
|
|
42
|
+
|
|
43
|
+
## 开发注意事项
|
|
44
|
+
|
|
45
|
+
- **禁止引入 UI 框架**: 本模块为纯逻辑层,不得包含 React/AntD 等 UI 依赖。
|
|
46
|
+
- **禁止反向依赖**: `core` 不得依赖 `plugins` 或 `apps` 中的任何代码。
|
|
47
|
+
- **类型安全**: 优先使用 `ports` 中定义的接口。
|
|
48
|
+
|
|
49
|
+
## 架构原则 (Architecture Principles)
|
|
50
|
+
|
|
51
|
+
- **业务无关性 (Business Agnostic)**: `core` 包禁止包含任何具体的业务模型、业务逻辑或业务常量。
|
|
52
|
+
- **共享契约 (Shared Contract)**: `core` 只定义通用的技术契约(如 `Plugin`, `StoragePort`, `ApiAdapter`)。
|
|
53
|
+
- **插件驱动 (Plugin Driven)**: 所有的业务逻辑应由插件实现。
|
|
54
|
+
|
|
55
|
+
## 目录结构
|
|
56
|
+
|
|
57
|
+
- `adapters/`: 基础设施的具体实现(如 LocalStorage, Axios)。
|
|
58
|
+
- `api/`: 通用 API 请求引擎。
|
|
59
|
+
- `domain/`: 核心领域逻辑(插件管理器、运行时、沙箱)。
|
|
60
|
+
- `ports/`: 核心接口定义(端口)。
|
|
61
|
+
- `utils/`: 通用工具函数。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=class{config=new Map;set(t,e){this.config.set(t,e)}get(t){return this.config.get(t)}merge(t){Object.keys(t).forEach(e=>{let i=this.config.get(e),n=t[e];i&&typeof i=="object"&&n&&typeof n=="object"?this.config.set(e,{...i,...n}):this.config.set(e,n)})}getAll(){return Object.fromEntries(this.config)}},c=new s;export{s as a,c as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-O74KYN5N.mjs";export{a as ConfigManager,b as configManager};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file plugin-manager.ts
|
|
3
|
+
* @description 插件管理器,负责插件的注册、生命周期管理、状态持久化及扩展点收集
|
|
4
|
+
* @author ChatBI Team
|
|
5
|
+
*/
|
|
1
6
|
import { DefaultEventBus } from '../event-bus';
|
|
2
7
|
import { Plugin, PluginExtension, RouteConfig, SlotPosition } from '../ports/plugin-port';
|
|
3
8
|
import { StoragePort } from '../ports/storage-port';
|
|
@@ -133,6 +138,10 @@ export declare class PluginManager {
|
|
|
133
138
|
* @param config 插件配置
|
|
134
139
|
*/
|
|
135
140
|
loadRemotePlugin(pluginId: string, url: string, config: any): Promise<Plugin | null>;
|
|
141
|
+
/**
|
|
142
|
+
* IIFE 模式加载插件
|
|
143
|
+
*/
|
|
144
|
+
private loadIIFEPlugin;
|
|
136
145
|
/**
|
|
137
146
|
* 实例化插件
|
|
138
147
|
*/
|