@chatbi-v/core 1.0.2 → 1.0.4

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.
@@ -69,3 +69,35 @@ export interface RequestOptions extends Partial<ApiRequestConfig> {
69
69
  /** 允许其他属性 (例如 axios 配置) */
70
70
  [key: string]: any;
71
71
  }
72
+ /**
73
+ * API 响应拦截上下文
74
+ */
75
+ export interface ApiResponseContext {
76
+ /** 原始响应数据 (AxiosResponse 或 Fetch Response) */
77
+ response: any;
78
+ /** 响应状态码 */
79
+ status: number;
80
+ /** 响应头 */
81
+ headers: Record<string, string>;
82
+ /** 业务数据 (Body) */
83
+ data: any;
84
+ /** 请求配置 */
85
+ config: ApiRequestConfig;
86
+ }
87
+ /**
88
+ * API 拦截器接口
89
+ */
90
+ export interface ApiInterceptor {
91
+ /**
92
+ * 拦截请求
93
+ * @param config 请求配置
94
+ * @returns 返回修改后的配置
95
+ */
96
+ interceptRequest?: (config: ApiRequestConfig) => ApiRequestConfig | Promise<ApiRequestConfig>;
97
+ /**
98
+ * 拦截响应
99
+ * @param context 响应上下文
100
+ * @returns 如果返回 true,表示该拦截器已处理(劫持)了该响应,后续逻辑将中止
101
+ */
102
+ interceptResponse?: (context: ApiResponseContext) => boolean | Promise<boolean>;
103
+ }
@@ -28,6 +28,7 @@ export declare const Slot: {
28
28
  readonly MessageContentRenderer: "message-content-renderer";
29
29
  readonly SidebarSystem: "sidebar-system";
30
30
  readonly SidebarBottom: "sidebar-bottom";
31
+ readonly RootLayout: "root-layout";
31
32
  readonly Custom: "custom";
32
33
  };
33
34
  export type SlotType = typeof Slot[keyof typeof Slot];
@@ -189,4 +190,14 @@ export interface PluginMetadata {
189
190
  configuration?: PluginConfigItem[];
190
191
  /** 存储定义(Schema) */
191
192
  storage?: StorageItemSchema[];
193
+ /**
194
+ * 系统状态绑定
195
+ * @description 将插件配置自动同步到系统 UI 状态
196
+ */
197
+ systemStateBindings?: {
198
+ configKey: string;
199
+ stateKey: string;
200
+ /** 预设转换逻辑: 'theme-mode' | 'identity' 等 */
201
+ transform?: 'theme-mode' | 'identity';
202
+ }[];
192
203
  }
@@ -1,4 +1,4 @@
1
1
  export * from './logger';
2
- export * from './stream-parser';
3
2
  export * from './date';
3
+ export * from './url';
4
4
  export declare const version = "1.0.0";
@@ -0,0 +1,16 @@
1
+ type KeepStrategy = 'first' | 'last' | 'search' | 'hash';
2
+ /**
3
+ * 把当前地址中所有出现的参数合并成一份。
4
+ * 重复 key 的处理策略:
5
+ * - 'first' : 按出现顺序,第一次的值生效
6
+ * - 'last' : 按出现顺序,最后一次的值生效(默认,最直观)
7
+ * - 'search' : 只要 search 里出现过,就用 search 的
8
+ * - 'hash' : 只要 hash 里出现过,就用 hash 的
9
+ */
10
+ export declare function normalizeParams(strategy?: KeepStrategy): URLSearchParams;
11
+ /**
12
+ * 清除 URL 中的特定参数并返回新的 URL
13
+ * @description 同时处理 search 和 hash 中的参数
14
+ */
15
+ export declare function cleanUrlParams(keysToRemove: string[]): string;
16
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chatbi-v/core",
3
- "version": "1.0.2",
4
- "main": "dist/index.mjs",
3
+ "version": "1.0.4",
4
+ "main": "dist/index.cjs",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -13,17 +13,19 @@
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs"
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.cjs"
17
18
  },
18
19
  "./package.json": "./package.json"
19
20
  },
20
21
  "dependencies": {
21
- "axios": "^1.13.2"
22
+ "axios": "^1.13.2",
23
+ "dayjs": "^1.11.10"
22
24
  },
23
25
  "peerDependencies": {
24
26
  "react": ">=18.0.0",
25
27
  "react-dom": ">=18.0.0",
26
- "@chatbi-v/cli": "1.0.2"
28
+ "@chatbi-v/cli": "1.0.9"
27
29
  },
28
30
  "devDependencies": {
29
31
  "tsup": "^8.5.1",
@@ -1,6 +0,0 @@
1
- import { Plugin } from '../ports/plugin-port';
2
- /**
3
- * 插件契约测试套件
4
- * @description 验证插件实现是否符合核心契约
5
- */
6
- export declare function verifyPluginContract(plugin: Plugin): void;
@@ -1,26 +0,0 @@
1
- /**
2
- * 流数据事件接口
3
- * @description 定义流式传输中的事件结构
4
- */
5
- export interface StreamEvent {
6
- /** 事件类型:消息、数据、待办事项、日志或错误 */
7
- event: 'message' | 'data' | 'todos' | 'log' | 'error' | 'think' | 'page';
8
- /** 事件携带的数据 */
9
- data: any;
10
- }
11
- /**
12
- * 解析流数据块
13
- * @description 将 SSE (Server-Sent Events) 格式的字符串解析为事件对象数组
14
- *
15
- * 支持的格式:
16
- * 格式 1:
17
- * event: 'message' | 'data' | 'todos' | 'error'
18
- * data: object | string
19
- *
20
- * 格式 2:
21
- * data: object | string
22
- *
23
- * @param chunk 接收到的流数据块字符串
24
- * @returns 解析后的事件数组
25
- */
26
- export declare function parseStreamChunk(chunk: string): StreamEvent[];