isdata-customer-sdk 0.1.77 → 0.1.79

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.
@@ -29570,6 +29570,7 @@ __webpack_require__.d(__webpack_exports__, {
29570
29570
  getChildrenOfficeInfosByID: function() { return /* reexport */ getChildrenOfficeInfosByID; },
29571
29571
  getCurrentUserPortalPageID: function() { return /* reexport */ getCurrentUserPortalPageID; },
29572
29572
  getDifyFileType: function() { return /* reexport */ getDifyFileType; },
29573
+ getFileSize: function() { return /* reexport */ getFileSize; },
29573
29574
  getGroupMappingsByAccount: function() { return /* reexport */ getGroupMappingsByAccount; },
29574
29575
  getIMHanlder: function() { return /* reexport */ getIMHanlder; },
29575
29576
  getIntegrateAppInfoByID: function() { return /* reexport */ getIntegrateAppInfoByID; },
@@ -29585,7 +29586,7 @@ __webpack_require__.d(__webpack_exports__, {
29585
29586
  getPoratlAppID: function() { return /* reexport */ getPoratlAppID; },
29586
29587
  getPortalAccessToken: function() { return /* reexport */ getPortalAccessToken; },
29587
29588
  getPortalAppCustomConfig: function() { return /* reexport */ getPortalAppCustomConfig; },
29588
- getPortalDocmentUrl: function() { return /* reexport */ getPortalDocmentUrl; },
29589
+ getPortalDocmentInfo: function() { return /* reexport */ getPortalDocmentInfo; },
29589
29590
  getPortalPageConfig: function() { return /* reexport */ getPortalPageConfig; },
29590
29591
  getPortalPageMenuID: function() { return /* reexport */ getPortalPageMenuID; },
29591
29592
  getPortalUserInfo: function() { return /* reexport */ getPortalUserInfo; },
@@ -29968,15 +29969,15 @@ const getRoleIDsByUserAndGroupID = async (user_id, app_id, group_id) => {
29968
29969
  * @param {*} kb_doc_id
29969
29970
  * @returns
29970
29971
  */
29971
- const getPortalDocmentUrl = async kb_doc_id => {
29972
+ const getPortalDocmentInfo = async kb_doc_id => {
29972
29973
  let queryData = {
29973
29974
  "param": {
29974
29975
  "kb_doc_id": kb_doc_id
29975
29976
  }
29976
29977
  };
29977
- let result = await request.post(`/dataservice/rest/orchestration/getPortalDocmentUrlByKBID`, queryData);
29978
- let doc_url = result.data.doc_url;
29979
- return doc_url;
29978
+ let result = await request.post(`/dataservice/rest/orchestration/getPortalDocmentInfoByKBID`, queryData);
29979
+ let docInfo = result.data.docInfo;
29980
+ return docInfo;
29980
29981
  };
29981
29982
 
29982
29983
  /**
@@ -30938,6 +30939,30 @@ const extractFilenameFromUrl = url => {
30938
30939
  return "downloaded_file"; // URL 解析失败时的默认文件名
30939
30940
  }
30940
30941
  };
30942
+
30943
+ /**
30944
+ * 获取远程文件大小(单位:字节)
30945
+ * @param {string} url - 文件的URL地址
30946
+ * @returns {Promise<number>} 文件大小(字节),失败时返回-1
30947
+ */
30948
+ const getFileSize = async url => {
30949
+ try {
30950
+ // 发送HEAD请求(不下载文件内容)
30951
+ const response = await fetch(url, {
30952
+ method: 'GET',
30953
+ headers: {
30954
+ 'Range': 'bytes=0-0'
30955
+ } // 仅请求第 1 个字节
30956
+ });
30957
+ if (response.status !== 206) throw new Error('不支持 Range 请求');
30958
+ const contentRange = response.headers.get('Content-Range');
30959
+ const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
30960
+ return totalSize ? parseInt(totalSize, 10) : -1;
30961
+ } catch (error) {
30962
+ console.error('获取文件大小失败:', error);
30963
+ return -1; // 返回-1表示失败
30964
+ }
30965
+ };
30941
30966
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
30942
30967
  var es_iterator_some = __webpack_require__(3579);
30943
30968
  ;// ./src/api/iframe.js
@@ -31098,8 +31123,8 @@ class ChatClientMgr {
31098
31123
  this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
31099
31124
  return this.handler.closeWindow();
31100
31125
  });
31101
- this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_url`), async (data, event) => {
31102
- return this.handler.getPortalDocmentUrl(data);
31126
+ this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
31127
+ return this.handler.getPortalDocmentInfo(data);
31103
31128
  });
31104
31129
  this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
31105
31130
  return this.handler.onAIAgentEvent(data, event);
@@ -31330,6 +31355,7 @@ class ChatClientMgr {
31330
31355
 
31331
31356
 
31332
31357
 
31358
+
31333
31359
  const getRobotInfoByID = async (robotID, groupID) => {
31334
31360
  let queryData = {
31335
31361
  "param": {
@@ -31404,19 +31430,21 @@ const getIMHanlder = customerHanlder => {
31404
31430
  onAIAgentEvent: async (data, event) => {
31405
31431
  // this.onAIAgentEvent(data,event);
31406
31432
  },
31407
- getPortalDocmentUrl: async data => {
31433
+ getPortalDocmentInfo: async data => {
31408
31434
  let kb_doc_id = data.kb_doc_id;
31409
- let urlStr = await getPortalDocmentUrl(kb_doc_id);
31435
+ let doc_info = await getPortalDocmentInfo(kb_doc_id);
31436
+ let urlStr = doc_info?.summary;
31410
31437
  if (urlStr) {
31411
31438
  let urlObj = JSON.parse(urlStr);
31412
- if (urlObj && urlObj.url) {
31439
+ if (urlObj) {
31413
31440
  let url = urlObj[0].url;
31414
31441
  let home_page = window.smardaten_api_context_path;
31415
31442
  let finalUrl = `${home_page}/storage_area/public${url}`;
31416
- return finalUrl;
31443
+ let fileSize = await getFileSize(finalUrl);
31444
+ doc_info.fileSize = fileSize;
31417
31445
  }
31418
31446
  }
31419
- return "";
31447
+ return doc_info;
31420
31448
  }
31421
31449
  };
31422
31450
  handler = {