@iflyrpa/actions 1.2.16-beta.3 → 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/index.mjs CHANGED
@@ -1124,12 +1124,7 @@ class Http {
1124
1124
  }
1125
1125
  constructor(config){
1126
1126
  this.apiClient = __WEBPACK_EXTERNAL_MODULE_axios__["default"].create({
1127
- ...config,
1128
- proxy: {
1129
- host: "localhost",
1130
- port: 9000,
1131
- protocol: "http"
1132
- }
1127
+ ...config
1133
1128
  });
1134
1129
  }
1135
1130
  addResponseInterceptor(findError) {
@@ -2968,7 +2963,7 @@ async function handleToutiaoData(params) {
2968
2963
  articleCell,
2969
2964
  ...onlySuccess ? {
2970
2965
  pagination: {
2971
- total: api_base_info_json.total_count || -1,
2966
+ total: api_base_info_json.total_count,
2972
2967
  pageNum,
2973
2968
  pageSize
2974
2969
  }
@@ -4912,33 +4907,40 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
4912
4907
  }
4913
4908
  });
4914
4909
  let uploadInfos = [];
4915
- coverIdInfo.data.uploadTempPermits.map((item)=>{
4916
- uploadInfos.push({
4917
- bucket: "",
4918
- uploadAddr: item.uploadAddr,
4919
- fileIds: item.fileIds,
4920
- token: item.token
4910
+ coverIdInfo.data.uploadTempPermits.forEach((item)=>{
4911
+ item.fileIds.forEach((fileId)=>{
4912
+ uploadInfos.push({
4913
+ bucket: item.bucket || "",
4914
+ uploadAddr: item.uploadAddr || "",
4915
+ fileIds: fileId,
4916
+ token: item.token || ""
4917
+ });
4921
4918
  });
4922
4919
  });
4920
+ if (uploadInfos.length < params.banners.length) return {
4921
+ code: 200,
4922
+ message: "可用 OSS bucket 数量不足,无法上传所有图片!",
4923
+ data: ""
4924
+ };
4923
4925
  if (0 === uploadInfos.length) return {
4924
4926
  code: 200,
4925
4927
  message: "图片上传失败,请稍后重试!",
4926
4928
  data: ""
4927
4929
  };
4928
- const uploadFile = async (url, index, infoIndex = 0)=>{
4930
+ const availableBuckets = Array.from({
4931
+ length: uploadInfos.length
4932
+ }, (_, i)=>i);
4933
+ const uploadFile = async (url, index)=>{
4929
4934
  const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
4930
4935
  const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
4931
4936
  const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
4932
- const tryUpload = async (uploadIndex)=>{
4933
- if (uploadIndex >= uploadInfos.length) {
4934
- __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].unlinkSync(localUrl);
4935
- return {
4936
- ossFileId: "",
4937
- ossToken: ""
4938
- };
4939
- }
4940
- const currentInfo = uploadInfos[uploadIndex];
4941
- const ossFileId = currentInfo.fileIds[0];
4937
+ const MAX_RETRIES = uploadInfos.length;
4938
+ let attempt = 0;
4939
+ while(attempt < MAX_RETRIES){
4940
+ const ossBucketIndex = availableBuckets.shift();
4941
+ if (void 0 === ossBucketIndex) break;
4942
+ const currentInfo = uploadInfos[ossBucketIndex];
4943
+ const ossFileId = currentInfo.fileIds;
4942
4944
  const ossToken = currentInfo.token;
4943
4945
  const ossDomain = currentInfo.uploadAddr;
4944
4946
  try {
@@ -4956,10 +4958,13 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
4956
4958
  ossToken
4957
4959
  };
4958
4960
  } catch (error) {
4959
- return tryUpload(uploadIndex + 1);
4961
+ attempt++;
4960
4962
  }
4963
+ }
4964
+ return {
4965
+ ossFileId: "",
4966
+ ossToken: ""
4961
4967
  };
4962
- return tryUpload(infoIndex);
4963
4968
  };
4964
4969
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
4965
4970
  const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
@@ -5304,7 +5309,7 @@ const xiaohongshuPublish = async (task, params)=>{
5304
5309
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
5305
5310
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5306
5311
  };
5307
- var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.2"}');
5312
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.4"}');
5308
5313
  class Action {
5309
5314
  constructor(task){
5310
5315
  this.task = task;