@blueking/chat-helper 0.0.1-beta.9 → 0.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 +631 -141
- package/dist/agent/type.d.ts +27 -2
- package/dist/agent/type.ts.js +1 -1
- package/dist/agent/use-agent.d.ts +464 -484
- package/dist/agent/use-agent.ts.js +191 -42
- package/dist/event/ag-ui.d.ts +37 -7
- package/dist/event/ag-ui.ts.js +225 -173
- package/dist/event/type.d.ts +99 -107
- package/dist/event/type.ts.js +34 -11
- package/dist/http/fetch/fetch.d.ts +5 -1
- package/dist/http/fetch/fetch.ts.js +40 -51
- package/dist/http/fetch/index.d.ts +1 -0
- package/dist/http/fetch/index.ts.js +133 -3
- package/dist/http/index.d.ts +14 -5
- package/dist/http/index.ts.js +59 -3
- package/dist/http/module/index.d.ts +13 -5
- package/dist/http/module/index.ts.js +2 -1
- package/dist/http/module/message.d.ts +22 -5
- package/dist/http/module/message.ts.js +51 -4
- package/dist/http/module/session.d.ts +4 -1
- package/dist/http/module/session.ts.js +66 -4
- package/dist/http/transform/agent.ts.js +11 -8
- package/dist/http/transform/message.d.ts +6 -6
- package/dist/http/transform/message.ts.js +566 -118
- package/dist/http/transform/session.ts.js +9 -1
- package/dist/index.d.ts +2983 -3314
- package/dist/index.ts.js +27 -5
- package/dist/mediator/index.d.ts +2 -0
- package/dist/mediator/index.ts.js +26 -0
- package/dist/mediator/type.d.ts +50 -0
- package/dist/mediator/type.ts.js +28 -0
- package/dist/mediator/use-mediator.d.ts +7 -0
- package/dist/mediator/use-mediator.ts.js +47 -0
- package/dist/message/type.d.ts +280 -146
- package/dist/message/type.ts.js +16 -15
- package/dist/message/use-message.d.ts +847 -963
- package/dist/message/use-message.ts.js +230 -37
- package/dist/session/type.d.ts +10 -0
- package/dist/session/use-session.d.ts +2006 -2214
- package/dist/session/use-session.ts.js +198 -33
- package/dist/type.d.ts +2 -0
- package/package.json +11 -6
package/dist/event/type.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare enum
|
|
3
|
-
|
|
1
|
+
import { type IMessageApi, type MessageRole, type MessageStatus } from '../message/type';
|
|
2
|
+
export declare enum CustomEventName {
|
|
3
|
+
FlowAgentEnd = "flow_agent_end",
|
|
4
|
+
FlowAgentResult = "flow_agent_result",
|
|
5
|
+
FlowAgentStart = "flow_agent_start",
|
|
6
|
+
KnowledgeRagEnd = "knowledge_rag_end",
|
|
7
|
+
KnowledgeRagResult = "knowledge_rag_result",
|
|
8
|
+
KnowledgeRagStart = "knowledge_rag_start",
|
|
9
|
+
KnowledgeRagTextContent = "knowledge_rag_text_content",
|
|
10
|
+
ReferenceDocument = "reference_document",
|
|
11
|
+
TempMessage = "temp_message"
|
|
4
12
|
}
|
|
5
13
|
export declare enum EventType {
|
|
6
14
|
ActivityDelta = "ACTIVITY_DELTA",
|
|
@@ -30,23 +38,49 @@ export declare enum EventType {
|
|
|
30
38
|
ToolCallResult = "TOOL_CALL_RESULT",
|
|
31
39
|
ToolCallStart = "TOOL_CALL_START"
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
/** BKFlow 收敛后的节点状态 - task.node 的状态枚举 */
|
|
42
|
+
export declare enum FlowNodeState {
|
|
43
|
+
/** 失败 */
|
|
44
|
+
Failed = "failed",
|
|
45
|
+
/** 执行中 */
|
|
46
|
+
Running = "running",
|
|
47
|
+
/** 成功 */
|
|
48
|
+
Success = "success",
|
|
49
|
+
/** 挂起 */
|
|
50
|
+
Suspended = "suspended"
|
|
51
|
+
}
|
|
52
|
+
/** BKFLOW 原始状态 - task 的状态枚举 */
|
|
53
|
+
export declare enum FlowTaskState {
|
|
54
|
+
/** 执行中 */
|
|
55
|
+
Blocked = "BLOCKED",
|
|
56
|
+
/** 执行中 */
|
|
57
|
+
Created = "CREATED",
|
|
58
|
+
/** 失败 */
|
|
59
|
+
Failed = "FAILED",
|
|
60
|
+
/** 成功 */
|
|
61
|
+
Finished = "FINISHED",
|
|
62
|
+
/** 执行中 */
|
|
63
|
+
LoopReady = "LOOP_READY",
|
|
64
|
+
/** 执行中 */
|
|
65
|
+
Ready = "READY",
|
|
66
|
+
/** 失败 */
|
|
67
|
+
Revoked = "REVOKED",
|
|
68
|
+
/** 失败 */
|
|
69
|
+
RollBackFailed = "ROLL_BACK_FAILED",
|
|
70
|
+
/** 执行中 */
|
|
71
|
+
RollBackSuccess = "ROLL_BACK_SUCCESS",
|
|
72
|
+
/** 执行中 */
|
|
73
|
+
RollingBack = "ROLLING_BACK",
|
|
74
|
+
/** 执行中 */
|
|
75
|
+
Running = "RUNNING",
|
|
76
|
+
/** 挂起 */
|
|
77
|
+
Suspended = "SUSPENDED"
|
|
38
78
|
}
|
|
39
79
|
/**
|
|
40
80
|
* Activity 代表 Agent 执行过程中的活动/动作/任务,可能包含结构化数据
|
|
41
81
|
* 活动状态的增量更新
|
|
42
82
|
* 记录活动类型 activityType
|
|
43
83
|
* 使用 JSON Patch (RFC 6902) 格式增量更新 Activity 数据
|
|
44
|
-
*
|
|
45
|
-
* @example ActivityDeltaEvent {
|
|
46
|
-
* activityType: "file_processing",
|
|
47
|
-
* messageId: "123",
|
|
48
|
-
* patch: [{ op: "add", path: "/title", value: "分析需求" }]
|
|
49
|
-
* }
|
|
50
84
|
*/
|
|
51
85
|
export interface IActivityDeltaEvent extends IBaseEvent {
|
|
52
86
|
activityType: string;
|
|
@@ -59,17 +93,6 @@ export interface IActivityDeltaEvent extends IBaseEvent {
|
|
|
59
93
|
* 活动状态的快照
|
|
60
94
|
* 记录活动类型 activityType
|
|
61
95
|
* 使用 JSON 格式存储 Activity 数据
|
|
62
|
-
*
|
|
63
|
-
* @example ActivitySnapshotEvent {
|
|
64
|
-
* activityType: "file_processing",
|
|
65
|
-
* messageId: "123",
|
|
66
|
-
* content: {
|
|
67
|
-
* title: "分析需求",
|
|
68
|
-
* status: "pending",
|
|
69
|
-
* progress: 0.5,
|
|
70
|
-
* },
|
|
71
|
-
* replace: true,
|
|
72
|
-
* }
|
|
73
96
|
*/
|
|
74
97
|
export interface IActivitySnapshotEvent extends IBaseEvent {
|
|
75
98
|
activityType: string;
|
|
@@ -78,10 +101,6 @@ export interface IActivitySnapshotEvent extends IBaseEvent {
|
|
|
78
101
|
replace?: boolean;
|
|
79
102
|
type: EventType.ActivitySnapshot;
|
|
80
103
|
}
|
|
81
|
-
export interface IBaseCustomEvent {
|
|
82
|
-
timestamp?: number;
|
|
83
|
-
type: CustomEventType;
|
|
84
|
-
}
|
|
85
104
|
export interface IBaseEvent {
|
|
86
105
|
timestamp?: number;
|
|
87
106
|
type: EventType;
|
|
@@ -89,26 +108,47 @@ export interface IBaseEvent {
|
|
|
89
108
|
/**
|
|
90
109
|
* 自定义事件
|
|
91
110
|
* 用于发送自定义事件到客户端
|
|
92
|
-
*
|
|
93
|
-
* @example CustomEvent {
|
|
94
|
-
* name: "custom_event",
|
|
95
|
-
* value: { type: CustomEventType.ReferenceDocument, data: { ... } }
|
|
96
|
-
* }
|
|
97
111
|
*/
|
|
98
112
|
export interface ICustomEvent extends IBaseEvent {
|
|
99
|
-
name:
|
|
113
|
+
name: CustomEventName;
|
|
100
114
|
type: EventType.Custom;
|
|
101
|
-
value:
|
|
115
|
+
value: IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue;
|
|
102
116
|
}
|
|
103
117
|
export type IEvent = IActivityDeltaEvent | IActivitySnapshotEvent | ICustomEvent | IMessagesSnapshotEvent | IRawEvent | IRunErrorEvent | IRunFinishedEvent | IRunStartedEvent | IStateDeltaEvent | IStateSnapshotEvent | IStepFinishedEvent | IStepStartedEvent | ITextMessageChunkEvent | ITextMessageContentEvent | ITextMessageEndEvent | ITextMessageStartEvent | IThinkingEndEvent | IThinkingStartEvent | IThinkingTextMessageContentEvent | IThinkingTextMessageEndEvent | IThinkingTextMessageStartEvent | IToolCallArgsEvent | IToolCallChunkEvent | IToolCallEndEvent | IToolCallResultEvent | IToolCallStartEvent;
|
|
118
|
+
export interface IFlowAgentEndCustomValue {
|
|
119
|
+
task_outputs: string[];
|
|
120
|
+
}
|
|
121
|
+
export interface IFlowAgentNode {
|
|
122
|
+
/** 耗时(s) */
|
|
123
|
+
elapsed_time: number;
|
|
124
|
+
/** 节点id */
|
|
125
|
+
id: string;
|
|
126
|
+
/** 节点名称 */
|
|
127
|
+
name: string;
|
|
128
|
+
/** 节点状态 */
|
|
129
|
+
state: FlowNodeState;
|
|
130
|
+
}
|
|
131
|
+
export interface IFlowAgentResultCustomValue {
|
|
132
|
+
nodes: Record<string, IFlowAgentNode>;
|
|
133
|
+
task_id: number;
|
|
134
|
+
task_name: string;
|
|
135
|
+
task_outputs: string[];
|
|
136
|
+
task_state: FlowTaskState;
|
|
137
|
+
}
|
|
138
|
+
export interface IFlowAgentStartCustomValue {
|
|
139
|
+
task_id: string;
|
|
140
|
+
}
|
|
141
|
+
export type IKnowledgeRagResultCustomValue = IReferenceDocumentCustomValue;
|
|
142
|
+
export interface IKnowledgeRagTextContentCustomValue {
|
|
143
|
+
cover: boolean;
|
|
144
|
+
chunk: {
|
|
145
|
+
content: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
104
148
|
/**
|
|
105
149
|
* 消息快照事件
|
|
106
150
|
* 用于记录当前时刻的完整消息状态
|
|
107
151
|
* 同步多端消息状态
|
|
108
|
-
*
|
|
109
|
-
* @example MessagesSnapshotEvent {
|
|
110
|
-
* messages: [{ ... }, { ... }]
|
|
111
|
-
* }
|
|
112
152
|
*/
|
|
113
153
|
export interface IMessagesSnapshotEvent extends IBaseEvent {
|
|
114
154
|
messages: IMessageApi[];
|
|
@@ -117,32 +157,17 @@ export interface IMessagesSnapshotEvent extends IBaseEvent {
|
|
|
117
157
|
/**
|
|
118
158
|
* 透传底层原始事件数据
|
|
119
159
|
* 保留完整的原始事件信息,不做解析
|
|
120
|
-
*
|
|
121
|
-
* // 同时对接多个 AI 服务
|
|
122
|
-
* @example RawEvent {
|
|
123
|
-
* event: { Claude 原始响应 },
|
|
124
|
-
* source: "anthropic"
|
|
125
|
-
* }
|
|
126
|
-
*
|
|
127
|
-
* @example RawEvent {
|
|
128
|
-
* event: { OpenAI 原始响应 },
|
|
129
|
-
* source: "openai"
|
|
130
|
-
* }
|
|
131
160
|
*/
|
|
132
161
|
export interface IRawEvent extends IBaseEvent {
|
|
133
162
|
event: unknown;
|
|
134
163
|
source?: string;
|
|
135
164
|
type: EventType.Raw;
|
|
136
165
|
}
|
|
137
|
-
export
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
title: string;
|
|
143
|
-
url: string;
|
|
144
|
-
}[];
|
|
145
|
-
}
|
|
166
|
+
export type IReferenceDocumentCustomValue = {
|
|
167
|
+
name: string;
|
|
168
|
+
originFileUrl?: string;
|
|
169
|
+
url: string;
|
|
170
|
+
}[];
|
|
146
171
|
export interface IRunErrorEvent extends IBaseEvent {
|
|
147
172
|
code?: string;
|
|
148
173
|
message: string;
|
|
@@ -164,13 +189,6 @@ export interface IRunFinishedEvent extends IBaseEvent {
|
|
|
164
189
|
* 关联会话线程 threadId
|
|
165
190
|
* 可以记录初始输入 input
|
|
166
191
|
* 支持嵌套运行(parentRunId 用于子 Agent 调用)
|
|
167
|
-
*
|
|
168
|
-
* @example RunStartedEvent {
|
|
169
|
-
* runId: 123,
|
|
170
|
-
* threadId: "thread_123",
|
|
171
|
-
* parentRunId: undefined,
|
|
172
|
-
* input: { messages: [...] },
|
|
173
|
-
* }
|
|
174
192
|
*/
|
|
175
193
|
export interface IRunStartedEvent extends IBaseEvent {
|
|
176
194
|
input?: unknown;
|
|
@@ -183,10 +201,6 @@ export interface IRunStartedEvent extends IBaseEvent {
|
|
|
183
201
|
* 状态增量更新事件
|
|
184
202
|
* 用于更新客户端状态
|
|
185
203
|
* 以 JSON Patch 格式增量更新状态
|
|
186
|
-
*
|
|
187
|
-
* @example StateDeltaEvent {
|
|
188
|
-
* delta: [{ op: "add", path: "/title", value: "分析需求" }]
|
|
189
|
-
* }
|
|
190
204
|
*/
|
|
191
205
|
export interface IStateDeltaEvent extends IBaseEvent {
|
|
192
206
|
delta: unknown;
|
|
@@ -196,10 +210,6 @@ export interface IStateDeltaEvent extends IBaseEvent {
|
|
|
196
210
|
* 状态快照事件
|
|
197
211
|
* 用于初始化或重置客户端状态
|
|
198
212
|
* 提供当前时刻的完整状态视图
|
|
199
|
-
*
|
|
200
|
-
* @example StateSnapshotEvent {
|
|
201
|
-
* snapshot: { ... }
|
|
202
|
-
* }
|
|
203
213
|
*/
|
|
204
214
|
export interface IStateSnapshotEvent extends IBaseEvent {
|
|
205
215
|
snapshot: unknown;
|
|
@@ -220,45 +230,40 @@ export interface IStepStartedEvent extends IBaseEvent {
|
|
|
220
230
|
stepName: string;
|
|
221
231
|
type: EventType.StepStarted;
|
|
222
232
|
}
|
|
233
|
+
export interface ITempMessageCustomValue {
|
|
234
|
+
message: string;
|
|
235
|
+
status: MessageStatus;
|
|
236
|
+
}
|
|
223
237
|
export interface ITextMessageChunkEvent extends IBaseEvent {
|
|
224
238
|
delta?: string;
|
|
225
|
-
messageId:
|
|
226
|
-
role?:
|
|
239
|
+
messageId: string;
|
|
240
|
+
role?: MessageRole;
|
|
227
241
|
type: EventType.TextMessageChunk;
|
|
228
242
|
}
|
|
229
243
|
export interface ITextMessageContentEvent extends IBaseEvent {
|
|
230
244
|
delta: string;
|
|
231
|
-
messageId:
|
|
245
|
+
messageId: string;
|
|
232
246
|
type: EventType.TextMessageContent;
|
|
233
247
|
}
|
|
234
248
|
export interface ITextMessageEndEvent extends IBaseEvent {
|
|
235
|
-
messageId:
|
|
249
|
+
messageId: string;
|
|
236
250
|
type: EventType.TextMessageEnd;
|
|
237
251
|
}
|
|
238
252
|
export interface ITextMessageStartEvent extends IBaseEvent {
|
|
239
|
-
messageId:
|
|
240
|
-
role:
|
|
253
|
+
messageId: string;
|
|
254
|
+
role: MessageRole;
|
|
241
255
|
type: EventType.TextMessageStart;
|
|
242
256
|
}
|
|
243
257
|
/**
|
|
244
258
|
* 思考结束事件
|
|
245
|
-
*
|
|
246
|
-
* @example ThinkingEndEvent {
|
|
247
|
-
* timestamp: 1734902400000,
|
|
248
|
-
* type: EventType.ThinkingEnd,
|
|
249
|
-
* }
|
|
250
259
|
*/
|
|
251
260
|
export interface IThinkingEndEvent extends IBaseEvent {
|
|
261
|
+
duration?: number;
|
|
252
262
|
type: EventType.ThinkingEnd;
|
|
253
263
|
}
|
|
254
264
|
/**
|
|
255
265
|
* 思考开始事件
|
|
256
266
|
* 记录思考的标题 title
|
|
257
|
-
*
|
|
258
|
-
* @example ThinkingStartEvent {
|
|
259
|
-
* title: "分析需求"
|
|
260
|
-
* type: EventType.ThinkingStart,
|
|
261
|
-
* }
|
|
262
267
|
*/
|
|
263
268
|
export interface IThinkingStartEvent extends IBaseEvent {
|
|
264
269
|
title?: string;
|
|
@@ -266,12 +271,6 @@ export interface IThinkingStartEvent extends IBaseEvent {
|
|
|
266
271
|
}
|
|
267
272
|
/**
|
|
268
273
|
* 思考文本消息内容事件
|
|
269
|
-
*
|
|
270
|
-
* @example ThinkingTextMessageContentEvent {
|
|
271
|
-
* timestamp: 1734902400000,
|
|
272
|
-
* type: EventType.ThinkingTextMessageContent,
|
|
273
|
-
* delta: "思考中..."
|
|
274
|
-
* }
|
|
275
274
|
*/
|
|
276
275
|
export interface IThinkingTextMessageContentEvent extends IBaseEvent {
|
|
277
276
|
delta: string;
|
|
@@ -279,22 +278,12 @@ export interface IThinkingTextMessageContentEvent extends IBaseEvent {
|
|
|
279
278
|
}
|
|
280
279
|
/**
|
|
281
280
|
* 思考文本消息结束事件
|
|
282
|
-
*
|
|
283
|
-
* @example ThinkingTextMessageEndEvent {
|
|
284
|
-
* timestamp: 1734902400000,
|
|
285
|
-
* type: EventType.ThinkingTextMessageEnd,
|
|
286
|
-
* }
|
|
287
281
|
*/
|
|
288
282
|
export interface IThinkingTextMessageEndEvent extends IBaseEvent {
|
|
289
283
|
type: EventType.ThinkingTextMessageEnd;
|
|
290
284
|
}
|
|
291
285
|
/**
|
|
292
286
|
* 思考文本消息开始事件
|
|
293
|
-
*
|
|
294
|
-
* @example ThinkingTextMessageStartEvent {
|
|
295
|
-
* timestamp: 1734902400000,
|
|
296
|
-
* type: EventType.ThinkingTextMessageStart,
|
|
297
|
-
* }
|
|
298
287
|
*/
|
|
299
288
|
export interface IThinkingTextMessageStartEvent extends IBaseEvent {
|
|
300
289
|
type: EventType.ThinkingTextMessageStart;
|
|
@@ -317,11 +306,14 @@ export interface IToolCallEndEvent extends IBaseEvent {
|
|
|
317
306
|
}
|
|
318
307
|
export interface IToolCallResultEvent extends IBaseEvent {
|
|
319
308
|
content: string;
|
|
309
|
+
duration?: number;
|
|
320
310
|
messageId: string;
|
|
321
311
|
toolCallId: string;
|
|
322
312
|
type: EventType.ToolCallResult;
|
|
323
313
|
}
|
|
324
314
|
export interface IToolCallStartEvent extends IBaseEvent {
|
|
315
|
+
description?: string;
|
|
316
|
+
mcpName?: string;
|
|
325
317
|
parentMessageId?: string;
|
|
326
318
|
toolCallId: string;
|
|
327
319
|
toolCallName: string;
|
package/dist/event/type.ts.js
CHANGED
|
@@ -22,10 +22,18 @@
|
|
|
22
22
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
23
23
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
|
-
*/ export var
|
|
26
|
-
(function(
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
*/ export var CustomEventName;
|
|
26
|
+
(function(CustomEventName) {
|
|
27
|
+
CustomEventName["FlowAgentEnd"] = "flow_agent_end";
|
|
28
|
+
CustomEventName["FlowAgentResult"] = "flow_agent_result";
|
|
29
|
+
CustomEventName["FlowAgentStart"] = "flow_agent_start";
|
|
30
|
+
CustomEventName["KnowledgeRagEnd"] = "knowledge_rag_end";
|
|
31
|
+
CustomEventName["KnowledgeRagResult"] = "knowledge_rag_result";
|
|
32
|
+
CustomEventName["KnowledgeRagStart"] = "knowledge_rag_start";
|
|
33
|
+
CustomEventName["KnowledgeRagTextContent"] = "knowledge_rag_text_content";
|
|
34
|
+
CustomEventName["ReferenceDocument"] = "reference_document";
|
|
35
|
+
CustomEventName["TempMessage"] = "temp_message";
|
|
36
|
+
})(CustomEventName || (CustomEventName = {}));
|
|
29
37
|
export var EventType;
|
|
30
38
|
(function(EventType) {
|
|
31
39
|
EventType["ActivityDelta"] = "ACTIVITY_DELTA";
|
|
@@ -55,10 +63,25 @@ export var EventType;
|
|
|
55
63
|
EventType["ToolCallResult"] = "TOOL_CALL_RESULT";
|
|
56
64
|
EventType["ToolCallStart"] = "TOOL_CALL_START";
|
|
57
65
|
})(EventType || (EventType = {}));
|
|
58
|
-
export var
|
|
59
|
-
(function(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})(
|
|
66
|
+
export var FlowNodeState;
|
|
67
|
+
(function(FlowNodeState) {
|
|
68
|
+
/** 失败 */ FlowNodeState["Failed"] = "failed";
|
|
69
|
+
/** 执行中 */ FlowNodeState["Running"] = "running";
|
|
70
|
+
/** 成功 */ FlowNodeState["Success"] = "success";
|
|
71
|
+
/** 挂起 */ FlowNodeState["Suspended"] = "suspended";
|
|
72
|
+
})(FlowNodeState || (FlowNodeState = {}));
|
|
73
|
+
export var FlowTaskState;
|
|
74
|
+
(function(FlowTaskState) {
|
|
75
|
+
/** 执行中 */ FlowTaskState["Blocked"] = "BLOCKED";
|
|
76
|
+
/** 执行中 */ FlowTaskState["Created"] = "CREATED";
|
|
77
|
+
/** 失败 */ FlowTaskState["Failed"] = "FAILED";
|
|
78
|
+
/** 成功 */ FlowTaskState["Finished"] = "FINISHED";
|
|
79
|
+
/** 执行中 */ FlowTaskState["LoopReady"] = "LOOP_READY";
|
|
80
|
+
/** 执行中 */ FlowTaskState["Ready"] = "READY";
|
|
81
|
+
/** 失败 */ FlowTaskState["Revoked"] = "REVOKED";
|
|
82
|
+
/** 失败 */ FlowTaskState["RollBackFailed"] = "ROLL_BACK_FAILED";
|
|
83
|
+
/** 执行中 */ FlowTaskState["RollBackSuccess"] = "ROLL_BACK_SUCCESS";
|
|
84
|
+
/** 执行中 */ FlowTaskState["RollingBack"] = "ROLLING_BACK";
|
|
85
|
+
/** 执行中 */ FlowTaskState["Running"] = "RUNNING";
|
|
86
|
+
/** 挂起 */ FlowTaskState["Suspended"] = "SUSPENDED";
|
|
87
|
+
})(FlowTaskState || (FlowTaskState = {}));
|
|
@@ -3,11 +3,14 @@ export interface ApiResponse<T = unknown> {
|
|
|
3
3
|
data: T;
|
|
4
4
|
message: string;
|
|
5
5
|
}
|
|
6
|
+
/** 单次请求配置,优先级高于 `requestData` 全局默认值 */
|
|
6
7
|
export interface IRequestConfig {
|
|
7
8
|
baseURL?: string;
|
|
8
9
|
controller?: AbortController;
|
|
9
10
|
credentials?: 'include' | 'omit' | 'same-origin';
|
|
11
|
+
/** 请求体;可传函数以便延迟求值(在 `prepareRequest` 中通过 `getValue` 解析) */
|
|
10
12
|
data?: (() => unknown) | unknown;
|
|
13
|
+
/** 请求头;可传函数以便延迟求值,便于动态注入(如 token) */
|
|
11
14
|
headers?: (() => Record<string, string>) | Record<string, string>;
|
|
12
15
|
method?: string;
|
|
13
16
|
mode?: 'cors' | 'no-cors' | 'same-origin';
|
|
@@ -75,8 +78,9 @@ export declare class FetchClient {
|
|
|
75
78
|
mode: "same-origin" | "cors" | "no-cors";
|
|
76
79
|
headers: Headers;
|
|
77
80
|
body: BodyInit;
|
|
78
|
-
|
|
81
|
+
signal: AbortSignal;
|
|
79
82
|
};
|
|
83
|
+
controller: AbortController;
|
|
80
84
|
};
|
|
81
85
|
put<T = unknown>(url: string, data?: unknown, config?: IRequestConfig): Promise<T>;
|
|
82
86
|
request<T = unknown>(config: IRequestConfig): Promise<T>;
|