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.
package/dist/index.umd.js CHANGED
@@ -29580,6 +29580,7 @@ __webpack_require__.d(__webpack_exports__, {
29580
29580
  getChildrenOfficeInfosByID: function() { return /* reexport */ getChildrenOfficeInfosByID; },
29581
29581
  getCurrentUserPortalPageID: function() { return /* reexport */ getCurrentUserPortalPageID; },
29582
29582
  getDifyFileType: function() { return /* reexport */ getDifyFileType; },
29583
+ getFileSize: function() { return /* reexport */ getFileSize; },
29583
29584
  getGroupMappingsByAccount: function() { return /* reexport */ getGroupMappingsByAccount; },
29584
29585
  getIMHanlder: function() { return /* reexport */ getIMHanlder; },
29585
29586
  getIntegrateAppInfoByID: function() { return /* reexport */ getIntegrateAppInfoByID; },
@@ -29595,7 +29596,7 @@ __webpack_require__.d(__webpack_exports__, {
29595
29596
  getPoratlAppID: function() { return /* reexport */ getPoratlAppID; },
29596
29597
  getPortalAccessToken: function() { return /* reexport */ getPortalAccessToken; },
29597
29598
  getPortalAppCustomConfig: function() { return /* reexport */ getPortalAppCustomConfig; },
29598
- getPortalDocmentUrl: function() { return /* reexport */ getPortalDocmentUrl; },
29599
+ getPortalDocmentInfo: function() { return /* reexport */ getPortalDocmentInfo; },
29599
29600
  getPortalPageConfig: function() { return /* reexport */ getPortalPageConfig; },
29600
29601
  getPortalPageMenuID: function() { return /* reexport */ getPortalPageMenuID; },
29601
29602
  getPortalUserInfo: function() { return /* reexport */ getPortalUserInfo; },
@@ -29978,15 +29979,15 @@ const getRoleIDsByUserAndGroupID = async (user_id, app_id, group_id) => {
29978
29979
  * @param {*} kb_doc_id
29979
29980
  * @returns
29980
29981
  */
29981
- const getPortalDocmentUrl = async kb_doc_id => {
29982
+ const getPortalDocmentInfo = async kb_doc_id => {
29982
29983
  let queryData = {
29983
29984
  "param": {
29984
29985
  "kb_doc_id": kb_doc_id
29985
29986
  }
29986
29987
  };
29987
- let result = await request.post(`/dataservice/rest/orchestration/getPortalDocmentUrlByKBID`, queryData);
29988
- let doc_url = result.data.doc_url;
29989
- return doc_url;
29988
+ let result = await request.post(`/dataservice/rest/orchestration/getPortalDocmentInfoByKBID`, queryData);
29989
+ let docInfo = result.data.docInfo;
29990
+ return docInfo;
29990
29991
  };
29991
29992
 
29992
29993
  /**
@@ -30948,6 +30949,30 @@ const extractFilenameFromUrl = url => {
30948
30949
  return "downloaded_file"; // URL 解析失败时的默认文件名
30949
30950
  }
30950
30951
  };
30952
+
30953
+ /**
30954
+ * 获取远程文件大小(单位:字节)
30955
+ * @param {string} url - 文件的URL地址
30956
+ * @returns {Promise<number>} 文件大小(字节),失败时返回-1
30957
+ */
30958
+ const getFileSize = async url => {
30959
+ try {
30960
+ // 发送HEAD请求(不下载文件内容)
30961
+ const response = await fetch(url, {
30962
+ method: 'GET',
30963
+ headers: {
30964
+ 'Range': 'bytes=0-0'
30965
+ } // 仅请求第 1 个字节
30966
+ });
30967
+ if (response.status !== 206) throw new Error('不支持 Range 请求');
30968
+ const contentRange = response.headers.get('Content-Range');
30969
+ const totalSize = contentRange?.match(/\/(\d+)$/)?.[1]; // 解析总大小(如 "bytes 0-0/1000" → 1000)
30970
+ return totalSize ? parseInt(totalSize, 10) : -1;
30971
+ } catch (error) {
30972
+ console.error('获取文件大小失败:', error);
30973
+ return -1; // 返回-1表示失败
30974
+ }
30975
+ };
30951
30976
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.some.js
30952
30977
  var es_iterator_some = __webpack_require__(3579);
30953
30978
  ;// ./src/api/iframe.js
@@ -31108,8 +31133,8 @@ class ChatClientMgr {
31108
31133
  this.handler.addChatListener(this.makeKey(`sdata_close_frame_window`), async (data, event) => {
31109
31134
  return this.handler.closeWindow();
31110
31135
  });
31111
- this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_url`), async (data, event) => {
31112
- return this.handler.getPortalDocmentUrl(data);
31136
+ this.handler.addChatListener(this.makeKey(`sdata_get_portal_doc_info`), async (data, event) => {
31137
+ return this.handler.getPortalDocmentInfo(data);
31113
31138
  });
31114
31139
  this.handler.addChatListener(this.makeKey(`sdata_chat_aiAgent_event`), async (data, event) => {
31115
31140
  return this.handler.onAIAgentEvent(data, event);
@@ -31340,6 +31365,7 @@ class ChatClientMgr {
31340
31365
 
31341
31366
 
31342
31367
 
31368
+
31343
31369
  const getRobotInfoByID = async (robotID, groupID) => {
31344
31370
  let queryData = {
31345
31371
  "param": {
@@ -31414,19 +31440,21 @@ const getIMHanlder = customerHanlder => {
31414
31440
  onAIAgentEvent: async (data, event) => {
31415
31441
  // this.onAIAgentEvent(data,event);
31416
31442
  },
31417
- getPortalDocmentUrl: async data => {
31443
+ getPortalDocmentInfo: async data => {
31418
31444
  let kb_doc_id = data.kb_doc_id;
31419
- let urlStr = await getPortalDocmentUrl(kb_doc_id);
31445
+ let doc_info = await getPortalDocmentInfo(kb_doc_id);
31446
+ let urlStr = doc_info?.summary;
31420
31447
  if (urlStr) {
31421
31448
  let urlObj = JSON.parse(urlStr);
31422
- if (urlObj && urlObj.url) {
31449
+ if (urlObj) {
31423
31450
  let url = urlObj[0].url;
31424
31451
  let home_page = window.smardaten_api_context_path;
31425
31452
  let finalUrl = `${home_page}/storage_area/public${url}`;
31426
- return finalUrl;
31453
+ let fileSize = await getFileSize(finalUrl);
31454
+ doc_info.fileSize = fileSize;
31427
31455
  }
31428
31456
  }
31429
- return "";
31457
+ return doc_info;
31430
31458
  }
31431
31459
  };
31432
31460
  handler = {