@kepoai/provider 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/api/index.d.ts +63 -12
  2. package/package.json +1 -1
package/api/index.d.ts CHANGED
@@ -48,6 +48,24 @@ export interface OptionEvent {
48
48
  currentTarget: Options
49
49
  }
50
50
 
51
+ // 配置事件成功结果结构
52
+ export interface OptionEventSuccessResult {
53
+ success: true
54
+ data?: unknown
55
+ }
56
+
57
+ // 配置事件失败结果结构
58
+ export interface OptionEventFailureResult {
59
+ success: false
60
+ error: string
61
+ }
62
+
63
+ // 配置事件允许返回的结果类型
64
+ export type OptionEventResult = void | OptionEventSuccessResult | OptionEventFailureResult
65
+
66
+ // 配置事件处理函数签名
67
+ export type OptionEventHandler = (e: OptionEvent) => Promise<OptionEventResult> | OptionEventResult
68
+
51
69
  // 配置选项基础结构
52
70
  interface OptionBase<T> {
53
71
  key: string
@@ -64,10 +82,10 @@ interface OptionBase<T> {
64
82
  export interface InputOption extends OptionBase<string> {
65
83
  type: 'input';
66
84
  event?: { // 事件结构
67
- onLoad?: (e: OptionEvent) => void; // 加载事件
68
- onChange?: (e: OptionEvent) => void; // 改变事件
69
- onFocus?: (e: OptionEvent) => void; // 聚焦事件
70
- onBlur?: (e: OptionEvent) => void; // 失焦事件
85
+ onLoad?: OptionEventHandler; // 加载事件
86
+ onChange?: OptionEventHandler; // 改变事件
87
+ onFocus?: OptionEventHandler; // 聚焦事件
88
+ onBlur?: OptionEventHandler; // 失焦事件
71
89
  }
72
90
  }
73
91
 
@@ -80,9 +98,9 @@ export interface SelectOption extends OptionBase<string[]> {
80
98
  multiple: boolean;
81
99
  search?: string,
82
100
  event?: {
83
- onLoad?: (e: OptionEvent) => void;
84
- onSearch?: (e: OptionEvent) => void;
85
- onChange?: (e: OptionEvent) => void;
101
+ onLoad?: OptionEventHandler;
102
+ onSearch?: OptionEventHandler;
103
+ onChange?: OptionEventHandler;
86
104
  }
87
105
  }
88
106
 
@@ -90,9 +108,9 @@ export interface SelectOption extends OptionBase<string[]> {
90
108
  export interface SwitchOption extends OptionBase<boolean> {
91
109
  type: 'switch';
92
110
  event?: {
93
- onLoad?: (e: OptionEvent) => void;
111
+ onLoad?: OptionEventHandler;
94
112
 
95
- onChange?: (e: OptionEvent) => void;
113
+ onChange?: OptionEventHandler;
96
114
  }
97
115
  }
98
116
 
@@ -100,8 +118,8 @@ export interface SwitchOption extends OptionBase<boolean> {
100
118
  export interface ButtonOption extends OptionBase<string> {
101
119
  type: 'button';
102
120
  event: ?{
103
- onLoad?: (e: OptionEvent) => void;
104
- onClick: (e: OptionEvent) => void;
121
+ onLoad?: OptionEventHandler;
122
+ onClick: OptionEventHandler;
105
123
  }
106
124
  }
107
125
 
@@ -147,6 +165,40 @@ export interface Events {
147
165
  onHide?: (props: EventProps) => void; // 隐藏事件
148
166
  }
149
167
 
168
+ // 简化请求查询参数值
169
+ export type SimpleFetchQueryValue = string | number | boolean | null | undefined
170
+
171
+ // 简化请求选项
172
+ export interface SimpleFetchOptions {
173
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD'
174
+ baseURL?: string
175
+ query?: Record<string, SimpleFetchQueryValue>
176
+ params?: Record<string, SimpleFetchQueryValue>
177
+ headers?: Record<string, string>
178
+ body?: string | Record<string, unknown> | ArrayBuffer | Uint8Array
179
+ responseType?: 'json' | 'text' | 'arrayBuffer'
180
+ timeout?: number
181
+ ignoreResponseError?: boolean
182
+ }
183
+
184
+ // 简化请求 raw 返回结构
185
+ export interface SimpleFetchRawResponse<T> {
186
+ status: number
187
+ statusText: string
188
+ ok: boolean
189
+ url: string
190
+ headers: Record<string, string>
191
+ data: T
192
+ }
193
+
194
+ // Build Mode / Provider 专用的会话感知简化请求能力
195
+ export interface SimpleFetch {
196
+ <T = unknown>(url: string, options?: SimpleFetchOptions): Promise<T>
197
+ raw<T = unknown>(url: string, options?: SimpleFetchOptions): Promise<SimpleFetchRawResponse<T>>
198
+ }
199
+
200
+ export const $fetch: SimpleFetch
201
+
150
202
  // AI 消息结构
151
203
  export interface AiMessage {
152
204
  role: 'system' | 'user' | 'assistant'
@@ -178,7 +230,6 @@ export interface AiCompleteResult {
178
230
  text: string
179
231
  usage: AiUsage
180
232
  quota: AiQuotaSnapshot
181
- model: string
182
233
  source: string
183
234
  requestId: string
184
235
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kepoai/provider",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "files": [
6
6
  "api"