@blueking/chat-helper 0.0.12-beta.29 → 0.0.12-beta.30
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/dist/agent/type.d.ts +3 -0
- package/dist/agent/use-agent.d.ts +4 -0
- package/dist/http/fetch/fetch.spec.d.ts +1 -0
- package/dist/http/fetch/fetch.ts.js +4 -0
- package/dist/http/index.d.ts +2 -3
- package/dist/http/module/index.d.ts +2 -3
- package/dist/http/module/session.d.ts +3 -4
- package/dist/http/module/session.ts.js +9 -1
- package/dist/http/transform/agent.ts.js +1 -0
- package/dist/http/transform/message.ts.js +2 -0
- package/dist/index.d.ts +20 -6
- package/dist/message/type.d.ts +2 -0
- package/dist/message/use-message.d.ts +4 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.ts.js +2 -1
- package/dist/session/pv-file-upload.d.ts +7 -0
- package/dist/session/pv-file-upload.spec.d.ts +1 -0
- package/dist/session/pv-file-upload.ts.js +67 -0
- package/dist/session/type.d.ts +24 -0
- package/dist/session/use-session.d.ts +11 -4
- package/dist/session/use-session.spec.d.ts +1 -0
- package/dist/session/use-session.ts.js +44 -4
- package/package.json +1 -1
package/dist/agent/type.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface IAgentInfo {
|
|
|
60
60
|
agentName?: string;
|
|
61
61
|
/** Agent 类型:single 为普通智能体,claw 为 Claw 智能体 */
|
|
62
62
|
agentType?: 'claw' | 'single' | string;
|
|
63
|
+
/** 后端 agent_sdk_version,如 2.2.2rc17;用于上传等接口兼容分流 */
|
|
64
|
+
agentSdkVersion?: string;
|
|
63
65
|
relatedSkills?: IRelatedSkill[];
|
|
64
66
|
resources?: IAgentResourceItem[];
|
|
65
67
|
saasUrl?: string;
|
|
@@ -83,6 +85,7 @@ export interface IAgentInfoApi {
|
|
|
83
85
|
agent_name: string;
|
|
84
86
|
/** Agent 类型:single 为普通智能体,claw 为 Claw 智能体 */
|
|
85
87
|
agent_type?: 'claw' | 'single' | string;
|
|
88
|
+
agent_sdk_version?: string;
|
|
86
89
|
related_skills?: IRelatedSkillApi[];
|
|
87
90
|
resources?: IAgentResourceItem[];
|
|
88
91
|
saas_url?: string;
|
|
@@ -13,6 +13,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
13
13
|
info: import("vue").Ref<{
|
|
14
14
|
agentName?: string;
|
|
15
15
|
agentType?: "claw" | "single" | string;
|
|
16
|
+
agentSdkVersion?: string;
|
|
16
17
|
relatedSkills?: {
|
|
17
18
|
description: string;
|
|
18
19
|
icon: string;
|
|
@@ -347,6 +348,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
347
348
|
filename?: string;
|
|
348
349
|
id?: string;
|
|
349
350
|
mimeType: string;
|
|
351
|
+
size?: number;
|
|
350
352
|
type: import("../message").MessageType.Binary;
|
|
351
353
|
url?: string;
|
|
352
354
|
} | {
|
|
@@ -1024,6 +1026,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1024
1026
|
}, IAgentInfo | {
|
|
1025
1027
|
agentName?: string;
|
|
1026
1028
|
agentType?: "claw" | "single" | string;
|
|
1029
|
+
agentSdkVersion?: string;
|
|
1027
1030
|
relatedSkills?: {
|
|
1028
1031
|
description: string;
|
|
1029
1032
|
icon: string;
|
|
@@ -1358,6 +1361,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1358
1361
|
filename?: string;
|
|
1359
1362
|
id?: string;
|
|
1360
1363
|
mimeType: string;
|
|
1364
|
+
size?: number;
|
|
1361
1365
|
type: import("../message").MessageType.Binary;
|
|
1362
1366
|
url?: string;
|
|
1363
1367
|
} | {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -240,6 +240,10 @@ export class FetchClient {
|
|
|
240
240
|
if (isStream && !headers.has('Accept')) {
|
|
241
241
|
headers.set('Accept', 'text/event-stream');
|
|
242
242
|
}
|
|
243
|
+
// multipart 必须由浏览器带 boundary;默认 application/json 会破坏 FormData
|
|
244
|
+
if (body instanceof FormData) {
|
|
245
|
+
headers.delete('Content-Type');
|
|
246
|
+
}
|
|
243
247
|
if (body !== undefined && body !== null) {
|
|
244
248
|
var _headers_get;
|
|
245
249
|
if (requestConfig.transformRequest) {
|
package/dist/http/index.d.ts
CHANGED
|
@@ -36,9 +36,8 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
36
36
|
}>;
|
|
37
37
|
getSessionFeedbackReasons: (rate: number, config?: import("./fetch").IRequestConfig) => Promise<string[]>;
|
|
38
38
|
renameSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").ISession<unknown, unknown>>;
|
|
39
|
-
uploadFile: (sessionCode: string, file: File, config?: import("./fetch").IRequestConfig) => Promise<
|
|
40
|
-
|
|
41
|
-
}>;
|
|
39
|
+
uploadFile: (sessionCode: string, file: File, config?: import("./fetch").IRequestConfig) => Promise<import("..").ILegacyUploadFileResult>;
|
|
40
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: import("./fetch").IRequestConfig) => Promise<import("..").IPvFileUploadResult>;
|
|
42
41
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("..").GetPvFileDownloadUrlOptions, config?: import("./fetch").IRequestConfig) => Promise<import("..").IPvFileDownloadUrlResult>;
|
|
43
42
|
isResumeSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<boolean>;
|
|
44
43
|
};
|
|
@@ -31,9 +31,8 @@ export declare const useModule: (fetchClient: FetchClient) => {
|
|
|
31
31
|
}>;
|
|
32
32
|
getSessionFeedbackReasons: (rate: number, config?: import("../fetch").IRequestConfig) => Promise<string[]>;
|
|
33
33
|
renameSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ISession<unknown, unknown>>;
|
|
34
|
-
uploadFile: (sessionCode: string, file: File, config?: import("../fetch").IRequestConfig) => Promise<
|
|
35
|
-
|
|
36
|
-
}>;
|
|
34
|
+
uploadFile: (sessionCode: string, file: File, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ILegacyUploadFileResult>;
|
|
35
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: import("../fetch").IRequestConfig) => Promise<import("../..").IPvFileUploadResult>;
|
|
37
36
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("../..").GetPvFileDownloadUrlOptions, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IPvFileDownloadUrlResult>;
|
|
38
37
|
isResumeSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<boolean>;
|
|
39
38
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetPvFileDownloadUrlOptions, IPvFileDownloadUrlResult, ISession, ISessionFeedback, ISessionListParams } from '../../session/type';
|
|
1
|
+
import type { GetPvFileDownloadUrlOptions, ILegacyUploadFileResult, IPvFileDownloadUrlResult, IPvFileUploadResult, ISession, ISessionFeedback, ISessionListParams } from '../../session/type';
|
|
2
2
|
import type { FetchClient, IRequestConfig } from '../fetch';
|
|
3
3
|
/**
|
|
4
4
|
* session 相关 http 接口
|
|
@@ -27,9 +27,8 @@ export declare const useSession: (fetchClient: FetchClient) => {
|
|
|
27
27
|
}>;
|
|
28
28
|
getSessionFeedbackReasons: (rate: number, config?: IRequestConfig) => Promise<string[]>;
|
|
29
29
|
renameSession: (sessionCode: string, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
30
|
-
uploadFile: (sessionCode: string, file: File, config?: IRequestConfig) => Promise<
|
|
31
|
-
|
|
32
|
-
}>;
|
|
30
|
+
uploadFile: (sessionCode: string, file: File, config?: IRequestConfig) => Promise<ILegacyUploadFileResult>;
|
|
31
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: IRequestConfig) => Promise<IPvFileUploadResult>;
|
|
33
32
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: GetPvFileDownloadUrlOptions, config?: IRequestConfig) => Promise<IPvFileDownloadUrlResult>;
|
|
34
33
|
isResumeSession: (sessionCode: string, config?: IRequestConfig) => Promise<boolean>;
|
|
35
34
|
};
|
|
@@ -157,7 +157,7 @@ const DEFAULT_PV_FILE_DOWNLOAD_TIMEOUT = 20000;
|
|
|
157
157
|
}, config);
|
|
158
158
|
// 会话重命名
|
|
159
159
|
const renameSession = (sessionCode, config)=>fetchClient.post(`session/${sessionCode}/ai_rename/`, undefined, config).then((res)=>transferSessionApi2Session(res));
|
|
160
|
-
//
|
|
160
|
+
// 旧版上传:session/{code}/upload/{asciiFileName}/(agent_sdk_version < 2.2.2rc25)
|
|
161
161
|
const uploadFile = (sessionCode, file, config)=>{
|
|
162
162
|
const safeFileName = buildSafeUploadFileName(file);
|
|
163
163
|
const fileName = encodeURIComponent(safeFileName);
|
|
@@ -169,6 +169,13 @@ const DEFAULT_PV_FILE_DOWNLOAD_TIMEOUT = 20000;
|
|
|
169
169
|
})
|
|
170
170
|
})));
|
|
171
171
|
};
|
|
172
|
+
/** 新版批量上传:session/{code}/pv_files/upload/(agent_sdk_version ≥ 2.2.2rc25) */ const uploadPvFiles = (sessionCode, files, config)=>{
|
|
173
|
+
const formData = new FormData();
|
|
174
|
+
for (const file of files){
|
|
175
|
+
formData.append('files', file);
|
|
176
|
+
}
|
|
177
|
+
return fetchClient.post(`session/${sessionCode}/pv_files/upload/`, formData, config);
|
|
178
|
+
};
|
|
172
179
|
/**
|
|
173
180
|
* 签发会话 PV 文件的临时 download_url / preview_url。
|
|
174
181
|
* path 为文件相对路径(artifacts 的 outputId);URLSearchParams 会自动编码,勿二次 encode。
|
|
@@ -199,6 +206,7 @@ const DEFAULT_PV_FILE_DOWNLOAD_TIMEOUT = 20000;
|
|
|
199
206
|
getSessionFeedbackReasons,
|
|
200
207
|
renameSession,
|
|
201
208
|
uploadFile,
|
|
209
|
+
uploadPvFiles,
|
|
202
210
|
getPvFileDownloadUrl,
|
|
203
211
|
isResumeSession
|
|
204
212
|
};
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
} : undefined,
|
|
65
65
|
agentName: data === null || data === void 0 ? void 0 : data.agent_name,
|
|
66
66
|
agentType: data === null || data === void 0 ? void 0 : data.agent_type,
|
|
67
|
+
agentSdkVersion: data === null || data === void 0 ? void 0 : data.agent_sdk_version,
|
|
67
68
|
relatedSkills: data === null || data === void 0 ? void 0 : (_data_related_skills = data.related_skills) === null || _data_related_skills === void 0 ? void 0 : _data_related_skills.map((skill)=>({
|
|
68
69
|
id: skill.id,
|
|
69
70
|
skill_name: skill.skill_name,
|
|
@@ -331,6 +331,7 @@ import { ActivityType, MessageRole, MessageType, resolveMessageCreatedAt } from
|
|
|
331
331
|
filename: binaryItem.filename,
|
|
332
332
|
id: binaryItem.id,
|
|
333
333
|
mimeType: binaryItem.mime_type,
|
|
334
|
+
size: binaryItem.size,
|
|
334
335
|
type: binaryItem.type,
|
|
335
336
|
url: binaryItem.url
|
|
336
337
|
};
|
|
@@ -605,6 +606,7 @@ import { ActivityType, MessageRole, MessageType, resolveMessageCreatedAt } from
|
|
|
605
606
|
filename: binaryItem.filename,
|
|
606
607
|
id: binaryItem.id,
|
|
607
608
|
mime_type: binaryItem.mimeType,
|
|
609
|
+
size: binaryItem.size,
|
|
608
610
|
type: binaryItem.type,
|
|
609
611
|
url: binaryItem.url
|
|
610
612
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
15
15
|
info: import("vue").Ref<{
|
|
16
16
|
agentName?: string;
|
|
17
17
|
agentType?: "claw" | "single" | string;
|
|
18
|
+
agentSdkVersion?: string;
|
|
18
19
|
relatedSkills?: {
|
|
19
20
|
description: string;
|
|
20
21
|
icon: string;
|
|
@@ -349,6 +350,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
349
350
|
filename?: string;
|
|
350
351
|
id?: string;
|
|
351
352
|
mimeType: string;
|
|
353
|
+
size?: number;
|
|
352
354
|
type: import("./message").MessageType.Binary;
|
|
353
355
|
url?: string;
|
|
354
356
|
} | {
|
|
@@ -1026,6 +1028,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1026
1028
|
}, import("./agent").IAgentInfo | {
|
|
1027
1029
|
agentName?: string;
|
|
1028
1030
|
agentType?: "claw" | "single" | string;
|
|
1031
|
+
agentSdkVersion?: string;
|
|
1029
1032
|
relatedSkills?: {
|
|
1030
1033
|
description: string;
|
|
1031
1034
|
icon: string;
|
|
@@ -1360,6 +1363,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1360
1363
|
filename?: string;
|
|
1361
1364
|
id?: string;
|
|
1362
1365
|
mimeType: string;
|
|
1366
|
+
size?: number;
|
|
1363
1367
|
type: import("./message").MessageType.Binary;
|
|
1364
1368
|
url?: string;
|
|
1365
1369
|
} | {
|
|
@@ -2409,6 +2413,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
2409
2413
|
filename?: string;
|
|
2410
2414
|
id?: string;
|
|
2411
2415
|
mimeType: string;
|
|
2416
|
+
size?: number;
|
|
2412
2417
|
type: import("./message").MessageType.Binary;
|
|
2413
2418
|
url?: string;
|
|
2414
2419
|
} | {
|
|
@@ -3360,6 +3365,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
3360
3365
|
filename?: string;
|
|
3361
3366
|
id?: string;
|
|
3362
3367
|
mimeType: string;
|
|
3368
|
+
size?: number;
|
|
3363
3369
|
type: import("./message").MessageType.Binary;
|
|
3364
3370
|
url?: string;
|
|
3365
3371
|
} | {
|
|
@@ -4332,6 +4338,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
4332
4338
|
filename?: string;
|
|
4333
4339
|
id?: string;
|
|
4334
4340
|
mimeType: string;
|
|
4341
|
+
size?: number;
|
|
4335
4342
|
type: import("./message").MessageType.Binary;
|
|
4336
4343
|
url?: string;
|
|
4337
4344
|
} | {
|
|
@@ -5283,6 +5290,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
5283
5290
|
filename?: string;
|
|
5284
5291
|
id?: string;
|
|
5285
5292
|
mimeType: string;
|
|
5293
|
+
size?: number;
|
|
5286
5294
|
type: import("./message").MessageType.Binary;
|
|
5287
5295
|
url?: string;
|
|
5288
5296
|
} | {
|
|
@@ -6256,6 +6264,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
6256
6264
|
filename?: string;
|
|
6257
6265
|
id?: string;
|
|
6258
6266
|
mimeType: string;
|
|
6267
|
+
size?: number;
|
|
6259
6268
|
type: import("./message").MessageType.Binary;
|
|
6260
6269
|
url?: string;
|
|
6261
6270
|
} | {
|
|
@@ -7207,6 +7216,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
7207
7216
|
filename?: string;
|
|
7208
7217
|
id?: string;
|
|
7209
7218
|
mimeType: string;
|
|
7219
|
+
size?: number;
|
|
7210
7220
|
type: import("./message").MessageType.Binary;
|
|
7211
7221
|
url?: string;
|
|
7212
7222
|
} | {
|
|
@@ -8179,6 +8189,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
8179
8189
|
filename?: string;
|
|
8180
8190
|
id?: string;
|
|
8181
8191
|
mimeType: string;
|
|
8192
|
+
size?: number;
|
|
8182
8193
|
type: import("./message").MessageType.Binary;
|
|
8183
8194
|
url?: string;
|
|
8184
8195
|
} | {
|
|
@@ -9130,6 +9141,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
9130
9141
|
filename?: string;
|
|
9131
9142
|
id?: string;
|
|
9132
9143
|
mimeType: string;
|
|
9144
|
+
size?: number;
|
|
9133
9145
|
type: import("./message").MessageType.Binary;
|
|
9134
9146
|
url?: string;
|
|
9135
9147
|
} | {
|
|
@@ -9840,9 +9852,8 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
9840
9852
|
}>;
|
|
9841
9853
|
getSessionFeedbackReasons: (rate: number) => Promise<string[]>;
|
|
9842
9854
|
renameSession: (sessionCode: string) => Promise<import("./session").ISession<unknown, unknown>>;
|
|
9843
|
-
uploadFile: (sessionCode: string, file: File) => Promise<
|
|
9844
|
-
|
|
9845
|
-
}>;
|
|
9855
|
+
uploadFile: (sessionCode: string, file: File) => Promise<import("./session").IUploadFileResult | undefined>;
|
|
9856
|
+
uploadFiles: (sessionCode: string, files: File[]) => Promise<import("./session").IUploadFileResult[]>;
|
|
9846
9857
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("./session").GetPvFileDownloadUrlOptions) => Promise<import("./session").IPvFileDownloadUrlResult>;
|
|
9847
9858
|
reset: () => void;
|
|
9848
9859
|
};
|
|
@@ -10126,6 +10137,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
10126
10137
|
filename?: string;
|
|
10127
10138
|
id?: string;
|
|
10128
10139
|
mimeType: string;
|
|
10140
|
+
size?: number;
|
|
10129
10141
|
type: import("./message").MessageType.Binary;
|
|
10130
10142
|
url?: string;
|
|
10131
10143
|
} | {
|
|
@@ -11074,6 +11086,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
11074
11086
|
filename?: string;
|
|
11075
11087
|
id?: string;
|
|
11076
11088
|
mimeType: string;
|
|
11089
|
+
size?: number;
|
|
11077
11090
|
type: import("./message").MessageType.Binary;
|
|
11078
11091
|
url?: string;
|
|
11079
11092
|
} | {
|
|
@@ -12027,6 +12040,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
12027
12040
|
filename?: string;
|
|
12028
12041
|
id?: string;
|
|
12029
12042
|
mimeType: string;
|
|
12043
|
+
size?: number;
|
|
12030
12044
|
type: import("./message").MessageType.Binary;
|
|
12031
12045
|
url?: string;
|
|
12032
12046
|
} | {
|
|
@@ -12976,6 +12990,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
12976
12990
|
filename?: string;
|
|
12977
12991
|
id?: string;
|
|
12978
12992
|
mimeType: string;
|
|
12993
|
+
size?: number;
|
|
12979
12994
|
type: import("./message").MessageType.Binary;
|
|
12980
12995
|
url?: string;
|
|
12981
12996
|
} | {
|
|
@@ -13684,9 +13699,8 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
13684
13699
|
}>;
|
|
13685
13700
|
getSessionFeedbackReasons: (rate: number, config?: import("./http").IRequestConfig) => Promise<string[]>;
|
|
13686
13701
|
renameSession: (sessionCode: string, config?: import("./http").IRequestConfig) => Promise<import("./session").ISession<unknown, unknown>>;
|
|
13687
|
-
uploadFile: (sessionCode: string, file: File, config?: import("./http").IRequestConfig) => Promise<
|
|
13688
|
-
|
|
13689
|
-
}>;
|
|
13702
|
+
uploadFile: (sessionCode: string, file: File, config?: import("./http").IRequestConfig) => Promise<import("./session").ILegacyUploadFileResult>;
|
|
13703
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: import("./http").IRequestConfig) => Promise<import("./session").IPvFileUploadResult>;
|
|
13690
13704
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("./session").GetPvFileDownloadUrlOptions, config?: import("./http").IRequestConfig) => Promise<import("./session").IPvFileDownloadUrlResult>;
|
|
13691
13705
|
isResumeSession: (sessionCode: string, config?: import("./http").IRequestConfig) => Promise<boolean>;
|
|
13692
13706
|
};
|
package/dist/message/type.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ export interface IBinaryInputContent {
|
|
|
109
109
|
filename?: string;
|
|
110
110
|
id?: string;
|
|
111
111
|
mimeType: string;
|
|
112
|
+
size?: number;
|
|
112
113
|
type: MessageType.Binary;
|
|
113
114
|
url?: string;
|
|
114
115
|
}
|
|
@@ -117,6 +118,7 @@ export interface IBinaryInputContentApi {
|
|
|
117
118
|
filename?: string;
|
|
118
119
|
id?: string;
|
|
119
120
|
mime_type: string;
|
|
121
|
+
size?: number;
|
|
120
122
|
type: MessageType.Binary;
|
|
121
123
|
url?: string;
|
|
122
124
|
}
|
|
@@ -285,6 +285,7 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
285
285
|
filename?: string;
|
|
286
286
|
id?: string;
|
|
287
287
|
mimeType: string;
|
|
288
|
+
size?: number;
|
|
288
289
|
type: import("./type").MessageType.Binary;
|
|
289
290
|
url?: string;
|
|
290
291
|
} | {
|
|
@@ -1233,6 +1234,7 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
1233
1234
|
filename?: string;
|
|
1234
1235
|
id?: string;
|
|
1235
1236
|
mimeType: string;
|
|
1237
|
+
size?: number;
|
|
1236
1238
|
type: import("./type").MessageType.Binary;
|
|
1237
1239
|
url?: string;
|
|
1238
1240
|
} | {
|
|
@@ -2186,6 +2188,7 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
2186
2188
|
filename?: string;
|
|
2187
2189
|
id?: string;
|
|
2188
2190
|
mimeType: string;
|
|
2191
|
+
size?: number;
|
|
2189
2192
|
type: import("./type").MessageType.Binary;
|
|
2190
2193
|
url?: string;
|
|
2191
2194
|
} | {
|
|
@@ -3135,6 +3138,7 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
3135
3138
|
filename?: string;
|
|
3136
3139
|
id?: string;
|
|
3137
3140
|
mimeType: string;
|
|
3141
|
+
size?: number;
|
|
3138
3142
|
type: import("./type").MessageType.Binary;
|
|
3139
3143
|
url?: string;
|
|
3140
3144
|
} | {
|
package/dist/session/index.d.ts
CHANGED
package/dist/session/index.ts.js
CHANGED
|
@@ -22,5 +22,6 @@
|
|
|
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 * from './
|
|
25
|
+
*/ export * from './pv-file-upload.ts.js';
|
|
26
|
+
export * from './type.ts.js';
|
|
26
27
|
export * from './use-session.ts.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** 含此版本起走 pv_files/upload;更早版本继续走旧 upload/{fileName}/ */
|
|
2
|
+
export declare const PV_FILE_UPLOAD_MIN_SDK_VERSION = "2.2.2rc25";
|
|
3
|
+
/**
|
|
4
|
+
* agent_sdk_version ≥ 2.2.2rc25 才支持 pv_files/upload。
|
|
5
|
+
* 缺省或无法解析时走旧接口,避免旧后端被打到不存在的新路径。
|
|
6
|
+
*/
|
|
7
|
+
export declare const isPvFileUploadSupported: (version?: null | string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making
|
|
3
|
+
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
|
|
8
|
+
*/ /** 含此版本起走 pv_files/upload;更早版本继续走旧 upload/{fileName}/ */ export const PV_FILE_UPLOAD_MIN_SDK_VERSION = '2.2.2rc25';
|
|
9
|
+
const PRE_RANK = {
|
|
10
|
+
a: 0,
|
|
11
|
+
b: 1,
|
|
12
|
+
rc: 2,
|
|
13
|
+
final: 3
|
|
14
|
+
};
|
|
15
|
+
const PRE_ALIAS = {
|
|
16
|
+
a: 'a',
|
|
17
|
+
alpha: 'a',
|
|
18
|
+
b: 'b',
|
|
19
|
+
beta: 'b',
|
|
20
|
+
c: 'rc',
|
|
21
|
+
pre: 'rc',
|
|
22
|
+
rc: 'rc'
|
|
23
|
+
};
|
|
24
|
+
const SDK_VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:[-.]?(a|alpha|b|beta|c|pre|rc)[.-]?(\d+))?$/i;
|
|
25
|
+
const parseSdkVersion = (raw)=>{
|
|
26
|
+
const matched = raw.trim().match(SDK_VERSION_RE);
|
|
27
|
+
if (!matched) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const pre = matched[4] ? PRE_ALIAS[matched[4].toLowerCase()] : 'final';
|
|
31
|
+
return {
|
|
32
|
+
major: Number(matched[1]),
|
|
33
|
+
minor: Number(matched[2]),
|
|
34
|
+
patch: Number(matched[3]),
|
|
35
|
+
pre,
|
|
36
|
+
preNum: matched[5] ? Number(matched[5]) : 0
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const compareSdkVersion = (left, right)=>{
|
|
40
|
+
if (left.major !== right.major) {
|
|
41
|
+
return left.major - right.major;
|
|
42
|
+
}
|
|
43
|
+
if (left.minor !== right.minor) {
|
|
44
|
+
return left.minor - right.minor;
|
|
45
|
+
}
|
|
46
|
+
if (left.patch !== right.patch) {
|
|
47
|
+
return left.patch - right.patch;
|
|
48
|
+
}
|
|
49
|
+
if (PRE_RANK[left.pre] !== PRE_RANK[right.pre]) {
|
|
50
|
+
return PRE_RANK[left.pre] - PRE_RANK[right.pre];
|
|
51
|
+
}
|
|
52
|
+
return left.preNum - right.preNum;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* agent_sdk_version ≥ 2.2.2rc25 才支持 pv_files/upload。
|
|
56
|
+
* 缺省或无法解析时走旧接口,避免旧后端被打到不存在的新路径。
|
|
57
|
+
*/ export const isPvFileUploadSupported = (version)=>{
|
|
58
|
+
if (!version) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const parsed = parseSdkVersion(version);
|
|
62
|
+
const min = parseSdkVersion(PV_FILE_UPLOAD_MIN_SDK_VERSION);
|
|
63
|
+
if (!parsed || !min) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return compareSdkVersion(parsed, min) >= 0;
|
|
67
|
+
};
|
package/dist/session/type.d.ts
CHANGED
|
@@ -110,3 +110,27 @@ export interface GetPvFileDownloadUrlOptions {
|
|
|
110
110
|
/** 请求超时毫秒,默认 20000 */
|
|
111
111
|
timeout?: number;
|
|
112
112
|
}
|
|
113
|
+
/** 旧版 session/{code}/upload/{fileName}/ 响应 */
|
|
114
|
+
export interface ILegacyUploadFileResult {
|
|
115
|
+
download_url?: string;
|
|
116
|
+
}
|
|
117
|
+
/** pv_files/upload 单条结果(保持后端 snake_case) */
|
|
118
|
+
export interface IPvFileUploadItem {
|
|
119
|
+
type: 'file';
|
|
120
|
+
id: string;
|
|
121
|
+
path: string;
|
|
122
|
+
name: string;
|
|
123
|
+
mime_type: string;
|
|
124
|
+
size: number;
|
|
125
|
+
status: 'failed' | 'success';
|
|
126
|
+
error?: string;
|
|
127
|
+
download_url?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface IPvFileUploadResult {
|
|
130
|
+
count: number;
|
|
131
|
+
succeeded: number;
|
|
132
|
+
failed: number;
|
|
133
|
+
results: IPvFileUploadItem[];
|
|
134
|
+
}
|
|
135
|
+
/** session.uploadFile 对外返回:新接口为单条 result,旧接口仅 download_url */
|
|
136
|
+
export type IUploadFileResult = ILegacyUploadFileResult | IPvFileUploadItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMediatorModule } from '../mediator';
|
|
2
|
-
import type { GetPvFileDownloadUrlOptions, ISession, ISessionFeedback, ISessionListParams } from './type';
|
|
2
|
+
import type { GetPvFileDownloadUrlOptions, ISession, ISessionFeedback, ISessionListParams, IUploadFileResult } from './type';
|
|
3
3
|
/**
|
|
4
4
|
* 使用会话模块,主要做业务的组合
|
|
5
5
|
* @param mediator - 中介者模块,用于获取其他模块的引用
|
|
@@ -301,6 +301,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
301
301
|
filename?: string;
|
|
302
302
|
id?: string;
|
|
303
303
|
mimeType: string;
|
|
304
|
+
size?: number;
|
|
304
305
|
type: import("..").MessageType.Binary;
|
|
305
306
|
url?: string;
|
|
306
307
|
} | {
|
|
@@ -1252,6 +1253,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
1252
1253
|
filename?: string;
|
|
1253
1254
|
id?: string;
|
|
1254
1255
|
mimeType: string;
|
|
1256
|
+
size?: number;
|
|
1255
1257
|
type: import("..").MessageType.Binary;
|
|
1256
1258
|
url?: string;
|
|
1257
1259
|
} | {
|
|
@@ -2224,6 +2226,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
2224
2226
|
filename?: string;
|
|
2225
2227
|
id?: string;
|
|
2226
2228
|
mimeType: string;
|
|
2229
|
+
size?: number;
|
|
2227
2230
|
type: import("..").MessageType.Binary;
|
|
2228
2231
|
url?: string;
|
|
2229
2232
|
} | {
|
|
@@ -3175,6 +3178,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
3175
3178
|
filename?: string;
|
|
3176
3179
|
id?: string;
|
|
3177
3180
|
mimeType: string;
|
|
3181
|
+
size?: number;
|
|
3178
3182
|
type: import("..").MessageType.Binary;
|
|
3179
3183
|
url?: string;
|
|
3180
3184
|
} | {
|
|
@@ -4148,6 +4152,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
4148
4152
|
filename?: string;
|
|
4149
4153
|
id?: string;
|
|
4150
4154
|
mimeType: string;
|
|
4155
|
+
size?: number;
|
|
4151
4156
|
type: import("..").MessageType.Binary;
|
|
4152
4157
|
url?: string;
|
|
4153
4158
|
} | {
|
|
@@ -5099,6 +5104,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
5099
5104
|
filename?: string;
|
|
5100
5105
|
id?: string;
|
|
5101
5106
|
mimeType: string;
|
|
5107
|
+
size?: number;
|
|
5102
5108
|
type: import("..").MessageType.Binary;
|
|
5103
5109
|
url?: string;
|
|
5104
5110
|
} | {
|
|
@@ -6071,6 +6077,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
6071
6077
|
filename?: string;
|
|
6072
6078
|
id?: string;
|
|
6073
6079
|
mimeType: string;
|
|
6080
|
+
size?: number;
|
|
6074
6081
|
type: import("..").MessageType.Binary;
|
|
6075
6082
|
url?: string;
|
|
6076
6083
|
} | {
|
|
@@ -7022,6 +7029,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
7022
7029
|
filename?: string;
|
|
7023
7030
|
id?: string;
|
|
7024
7031
|
mimeType: string;
|
|
7032
|
+
size?: number;
|
|
7025
7033
|
type: import("..").MessageType.Binary;
|
|
7026
7034
|
url?: string;
|
|
7027
7035
|
} | {
|
|
@@ -7732,9 +7740,8 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
7732
7740
|
}>;
|
|
7733
7741
|
getSessionFeedbackReasons: (rate: number) => Promise<string[]>;
|
|
7734
7742
|
renameSession: (sessionCode: string) => Promise<ISession<unknown, unknown>>;
|
|
7735
|
-
uploadFile: (sessionCode: string, file: File) => Promise<
|
|
7736
|
-
|
|
7737
|
-
}>;
|
|
7743
|
+
uploadFile: (sessionCode: string, file: File) => Promise<IUploadFileResult | undefined>;
|
|
7744
|
+
uploadFiles: (sessionCode: string, files: File[]) => Promise<IUploadFileResult[]>;
|
|
7738
7745
|
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: GetPvFileDownloadUrlOptions) => Promise<import("./type").IPvFileDownloadUrlResult>;
|
|
7739
7746
|
reset: () => void;
|
|
7740
7747
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -80,6 +80,7 @@ function _object_spread(target) {
|
|
|
80
80
|
return target;
|
|
81
81
|
}
|
|
82
82
|
import { computed, ref } from 'vue';
|
|
83
|
+
import { isPvFileUploadSupported } from './pv-file-upload.ts.js';
|
|
83
84
|
/** 会话列表默认每页条数 */ const DEFAULT_PAGE_SIZE = 20;
|
|
84
85
|
/**
|
|
85
86
|
* 使用会话模块,主要做业务的组合
|
|
@@ -326,11 +327,49 @@ import { computed, ref } from 'vue';
|
|
|
326
327
|
isRenameLoading.value = false;
|
|
327
328
|
});
|
|
328
329
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
const resolvePvUploadItem = (item)=>{
|
|
331
|
+
if (!item) {
|
|
332
|
+
throw new Error('Upload failed: empty results');
|
|
333
|
+
}
|
|
334
|
+
return item;
|
|
333
335
|
};
|
|
336
|
+
/**
|
|
337
|
+
* 上传文件到会话。
|
|
338
|
+
* agent_sdk_version ≥ 2.2.2rc25 走 pv_files/upload;更早或缺失版本走旧 upload/{fileName}/。
|
|
339
|
+
*/ const uploadFile = (sessionCode, file)=>{
|
|
340
|
+
var _mediator_agent_info_value, _mediator_agent, _mediator_http;
|
|
341
|
+
const sdkVersion = (_mediator_agent = mediator.agent) === null || _mediator_agent === void 0 ? void 0 : (_mediator_agent_info_value = _mediator_agent.info.value) === null || _mediator_agent_info_value === void 0 ? void 0 : _mediator_agent_info_value.agentSdkVersion;
|
|
342
|
+
if (isPvFileUploadSupported(sdkVersion)) {
|
|
343
|
+
var _mediator_http1;
|
|
344
|
+
return Promise.resolve((_mediator_http1 = mediator.http) === null || _mediator_http1 === void 0 ? void 0 : _mediator_http1.session.uploadPvFiles(sessionCode, [
|
|
345
|
+
file
|
|
346
|
+
])).then((res)=>{
|
|
347
|
+
var _res_results;
|
|
348
|
+
return resolvePvUploadItem(res === null || res === void 0 ? void 0 : (_res_results = res.results) === null || _res_results === void 0 ? void 0 : _res_results[0]);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return Promise.resolve((_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.session.uploadFile(sessionCode, file));
|
|
352
|
+
};
|
|
353
|
+
const uploadFiles = function() {
|
|
354
|
+
var _ref = _async_to_generator(function*(sessionCode, files) {
|
|
355
|
+
var _mediator_agent_info_value, _mediator_agent;
|
|
356
|
+
const sdkVersion = (_mediator_agent = mediator.agent) === null || _mediator_agent === void 0 ? void 0 : (_mediator_agent_info_value = _mediator_agent.info.value) === null || _mediator_agent_info_value === void 0 ? void 0 : _mediator_agent_info_value.agentSdkVersion;
|
|
357
|
+
if (isPvFileUploadSupported(sdkVersion)) {
|
|
358
|
+
var _mediator_http;
|
|
359
|
+
const res = yield (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.session.uploadPvFiles(sessionCode, files);
|
|
360
|
+
var _res_results;
|
|
361
|
+
return (_res_results = res === null || res === void 0 ? void 0 : res.results) !== null && _res_results !== void 0 ? _res_results : [];
|
|
362
|
+
}
|
|
363
|
+
const results = yield Promise.all(files.map((file)=>{
|
|
364
|
+
var _mediator_http;
|
|
365
|
+
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.session.uploadFile(sessionCode, file);
|
|
366
|
+
}));
|
|
367
|
+
return results.filter((item)=>!!item);
|
|
368
|
+
});
|
|
369
|
+
return function uploadFiles(sessionCode, files) {
|
|
370
|
+
return _ref.apply(this, arguments);
|
|
371
|
+
};
|
|
372
|
+
}();
|
|
334
373
|
const getPvFileDownloadUrl = (sessionCode, path, options)=>{
|
|
335
374
|
var _mediator_http;
|
|
336
375
|
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.session.getPvFileDownloadUrl(sessionCode, path, options);
|
|
@@ -378,6 +417,7 @@ import { computed, ref } from 'vue';
|
|
|
378
417
|
getSessionFeedbackReasons,
|
|
379
418
|
renameSession,
|
|
380
419
|
uploadFile,
|
|
420
|
+
uploadFiles,
|
|
381
421
|
getPvFileDownloadUrl,
|
|
382
422
|
reset
|
|
383
423
|
};
|