@iflyrpa/actions 1.2.16-beta.4 → 1.2.16-beta.5

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/bundle.js CHANGED
@@ -15889,7 +15889,7 @@ var __webpack_exports__ = {};
15889
15889
  articleCell,
15890
15890
  ...onlySuccess ? {
15891
15891
  pagination: {
15892
- total: api_base_info_json.total_count || -1,
15892
+ total: api_base_info_json.total_count,
15893
15893
  pageNum,
15894
15894
  pageSize
15895
15895
  }
@@ -17833,33 +17833,40 @@ var __webpack_exports__ = {};
17833
17833
  }
17834
17834
  });
17835
17835
  let uploadInfos = [];
17836
- coverIdInfo.data.uploadTempPermits.map((item)=>{
17837
- uploadInfos.push({
17838
- bucket: "",
17839
- uploadAddr: item.uploadAddr,
17840
- fileIds: item.fileIds,
17841
- token: item.token
17836
+ coverIdInfo.data.uploadTempPermits.forEach((item)=>{
17837
+ item.fileIds.forEach((fileId)=>{
17838
+ uploadInfos.push({
17839
+ bucket: item.bucket || "",
17840
+ uploadAddr: item.uploadAddr || "",
17841
+ fileIds: fileId,
17842
+ token: item.token || ""
17843
+ });
17842
17844
  });
17843
17845
  });
17846
+ if (uploadInfos.length < params.banners.length) return {
17847
+ code: 200,
17848
+ message: "可用 OSS bucket 数量不足,无法上传所有图片!",
17849
+ data: ""
17850
+ };
17844
17851
  if (0 === uploadInfos.length) return {
17845
17852
  code: 200,
17846
17853
  message: "图片上传失败,请稍后重试!",
17847
17854
  data: ""
17848
17855
  };
17849
- const uploadFile = async (url, index, infoIndex = 0)=>{
17856
+ const availableBuckets = Array.from({
17857
+ length: uploadInfos.length
17858
+ }, (_, i)=>i);
17859
+ const uploadFile = async (url, index)=>{
17850
17860
  const fileName = getFilenameFromUrl(url);
17851
17861
  const localUrl = await downloadImage(url, external_node_path_default().join(tmpCachePath, fileName));
17852
17862
  const fileBuffer = external_node_fs_default().readFileSync(localUrl);
17853
- const tryUpload = async (uploadIndex)=>{
17854
- if (uploadIndex >= uploadInfos.length) {
17855
- external_node_fs_default().unlinkSync(localUrl);
17856
- return {
17857
- ossFileId: "",
17858
- ossToken: ""
17859
- };
17860
- }
17861
- const currentInfo = uploadInfos[uploadIndex];
17862
- const ossFileId = currentInfo.fileIds[0];
17863
+ const MAX_RETRIES = uploadInfos.length;
17864
+ let attempt = 0;
17865
+ while(attempt < MAX_RETRIES){
17866
+ const ossBucketIndex = availableBuckets.shift();
17867
+ if (void 0 === ossBucketIndex) break;
17868
+ const currentInfo = uploadInfos[ossBucketIndex];
17869
+ const ossFileId = currentInfo.fileIds;
17863
17870
  const ossToken = currentInfo.token;
17864
17871
  const ossDomain = currentInfo.uploadAddr;
17865
17872
  try {
@@ -17877,10 +17884,13 @@ var __webpack_exports__ = {};
17877
17884
  ossToken
17878
17885
  };
17879
17886
  } catch (error) {
17880
- return tryUpload(uploadIndex + 1);
17887
+ attempt++;
17881
17888
  }
17889
+ }
17890
+ return {
17891
+ ossFileId: "",
17892
+ ossToken: ""
17882
17893
  };
17883
- return tryUpload(infoIndex);
17884
17894
  };
17885
17895
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
17886
17896
  const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
@@ -18225,7 +18235,7 @@ var __webpack_exports__ = {};
18225
18235
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
18226
18236
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
18227
18237
  };
18228
- var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.3"}');
18238
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.4"}');
18229
18239
  class Action {
18230
18240
  constructor(task){
18231
18241
  this.task = task;