@blueking/chat-helper 0.0.12-beta.9 → 0.0.13-dev.1

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 (38) hide show
  1. package/README.md +21 -7
  2. package/dist/agent/type.d.ts +82 -0
  3. package/dist/agent/type.ts.js +5 -1
  4. package/dist/agent/use-agent.d.ts +229 -10
  5. package/dist/agent/use-agent.ts.js +365 -25
  6. package/dist/event/ag-ui.d.ts +4 -1
  7. package/dist/event/ag-ui.ts.js +76 -6
  8. package/dist/event/type.d.ts +14 -2
  9. package/dist/event/type.ts.js +2 -0
  10. package/dist/http/fetch/fetch.spec.d.ts +1 -0
  11. package/dist/http/fetch/fetch.ts.js +106 -22
  12. package/dist/http/index.d.ts +11 -5
  13. package/dist/http/module/agent.d.ts +2 -0
  14. package/dist/http/module/agent.ts.js +19 -2
  15. package/dist/http/module/index.d.ts +11 -5
  16. package/dist/http/module/message.d.ts +1 -1
  17. package/dist/http/module/message.ts.js +4 -3
  18. package/dist/http/module/session.d.ts +10 -5
  19. package/dist/http/module/session.ts.js +60 -3
  20. package/dist/http/transform/agent.d.ts +9 -1
  21. package/dist/http/transform/agent.spec.d.ts +1 -0
  22. package/dist/http/transform/agent.ts.js +29 -0
  23. package/dist/http/transform/message.spec.d.ts +1 -0
  24. package/dist/http/transform/message.ts.js +19 -5
  25. package/dist/index.d.ts +1194 -16
  26. package/dist/message/type.d.ts +35 -3
  27. package/dist/message/type.ts.js +16 -0
  28. package/dist/message/use-message.d.ts +316 -0
  29. package/dist/session/index.d.ts +1 -0
  30. package/dist/session/index.ts.js +2 -1
  31. package/dist/session/pv-file-upload.d.ts +7 -0
  32. package/dist/session/pv-file-upload.spec.d.ts +1 -0
  33. package/dist/session/pv-file-upload.ts.js +64 -0
  34. package/dist/session/type.d.ts +57 -0
  35. package/dist/session/use-session.d.ts +644 -6
  36. package/dist/session/use-session.spec.d.ts +1 -0
  37. package/dist/session/use-session.ts.js +117 -10
  38. package/package.json +4 -2
@@ -1,2 +1,3 @@
1
+ export * from './pv-file-upload';
1
2
  export * from './type';
2
3
  export * from './use-session';
@@ -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 './type.ts.js';
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
+ * 仅当能解析出版本且低于 2.2.2rc25 时走旧 upload/{fileName}/。
5
+ * 空字符串、缺省或无法解析一律走 pv_files/upload。
6
+ */
7
+ export declare const isPvFileUploadSupported: (version?: null | string) => boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
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
+ * 仅当能解析出版本且低于 2.2.2rc25 时走旧 upload/{fileName}/。
56
+ * 空字符串、缺省或无法解析一律走 pv_files/upload。
57
+ */ export const isPvFileUploadSupported = (version)=>{
58
+ const parsed = version ? parseSdkVersion(version) : null;
59
+ const min = parseSdkVersion(PV_FILE_UPLOAD_MIN_SDK_VERSION);
60
+ if (!parsed || !min) {
61
+ return true;
62
+ }
63
+ return compareSdkVersion(parsed, min) >= 0;
64
+ };
@@ -63,6 +63,25 @@ export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unkno
63
63
  labels?: string[];
64
64
  };
65
65
  }
66
+ /** 会话列表分页请求参数 */
67
+ export interface ISessionListParams {
68
+ page?: number;
69
+ page_size?: number;
70
+ }
71
+ /** 会话列表分页 API 响应(snake_case) */
72
+ export interface ISessionListApi {
73
+ page: number;
74
+ num_pages: number;
75
+ count: number;
76
+ results: ISessionApi[];
77
+ }
78
+ /** 会话列表分页结果(camelCase) */
79
+ export interface ISessionListResult {
80
+ page: number;
81
+ numPages: number;
82
+ count: number;
83
+ results: ISession[];
84
+ }
66
85
  export interface ISessionFeedback {
67
86
  comment: string;
68
87
  labels: string[];
@@ -77,3 +96,41 @@ export interface ISessionFeedbackApi {
77
96
  session_code: string;
78
97
  session_content_ids: number[];
79
98
  }
99
+ /** pv_files/download_url 响应(保持后端 snake_case) */
100
+ export interface IPvFileDownloadUrlResult {
101
+ download_url: string;
102
+ expires_at: string;
103
+ preview_url: string;
104
+ sha256: string;
105
+ size: number;
106
+ }
107
+ export interface GetPvFileDownloadUrlOptions {
108
+ /** 有效期秒数,默认 600,最大 3600 */
109
+ expiresIn?: number;
110
+ /** 请求超时毫秒,默认 20000 */
111
+ timeout?: number;
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;