@iflyrpa/actions 4.0.9-beta.0 → 4.0.9-beta.2

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
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4801cf8d-6f2d-5cdd-9a97-97673fa7dfff")}catch(e){}}();
3
1
  import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
4
2
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
5
3
  import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_package_json_58ae5f06__ from "@iflyrpa/share/package.json";
@@ -4352,7 +4350,37 @@ function __webpack_require__(moduleId) {
4352
4350
  return module;
4353
4351
  };
4354
4352
  })();
4355
- var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.0"}');
4353
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.2"}');
4354
+ const USER_MESSAGE = {
4355
+ PROXY_UNAVAILABLE: "代理暂时不可用,请稍后重试或使用本地IP",
4356
+ NETWORK_ERROR: "网络异常,请稍后重试",
4357
+ SYSTEM_ERROR: "系统异常,请稍后重试或联系客服",
4358
+ PUBLISH_NETWORK: "发布失败,网络不稳定,请稍后重试",
4359
+ DOUYIN_ACCOUNT_FETCH_FAILED: "抖音数据获取失败,请稍后重试",
4360
+ SHIPINHAO_ACCOUNT_FETCH_FAILED: "视频号数据获取失败,请稍后重试",
4361
+ DOUYIN_POST_FETCH_FAILED: "抖音作品数据获取失败,请稍后重试",
4362
+ SHIPINHAO_POST_FETCH_FAILED: "视频号作品数据获取失败,请稍后重试",
4363
+ BJH_POST_FETCH_FAILED: "百家号作品数据获取失败,请稍后重试",
4364
+ TT_POST_FETCH_FAILED: "头条号作品数据获取失败,请稍后重试",
4365
+ QRCODE_FETCH_FAILED: "认证二维码获取失败,请稍后重试",
4366
+ IMAGE_UPLOAD_FAILED: "图片上传失败,请稍后重试或联系客服"
4367
+ };
4368
+ const NETWORK_CODES = [
4369
+ 500,
4370
+ 502,
4371
+ 503,
4372
+ 504
4373
+ ];
4374
+ function classifyPublishError(handledError) {
4375
+ const { code } = handledError;
4376
+ const isProxyRequest = handledError.extra?.isProxyRequest === true;
4377
+ if (!NETWORK_CODES.includes(code) && 599 !== code) return null;
4378
+ const category = 599 === code || isProxyRequest ? "代理错误" : "网络错误";
4379
+ return {
4380
+ category,
4381
+ userMessage: USER_MESSAGE.PUBLISH_NETWORK
4382
+ };
4383
+ }
4356
4384
  const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
4357
4385
  const ALARM_THROTTLE_MS = 60000;
4358
4386
  const lastSentAt = new Map();
@@ -4555,7 +4583,7 @@ async function ProxyAgent(task, addr, accountId, refresh) {
4555
4583
  });
4556
4584
  throw {
4557
4585
  code: 414,
4558
- message: `请求代理失败:${err.message}`,
4586
+ message: USER_MESSAGE.PROXY_UNAVAILABLE,
4559
4587
  data: {}
4560
4588
  };
4561
4589
  });
@@ -4621,7 +4649,7 @@ class Http {
4621
4649
  if (error && "object" == typeof error && "code" in error && "message" in error) return error;
4622
4650
  return {
4623
4651
  code: 500,
4624
- message: error instanceof Error ? error.message : "未知错误",
4652
+ message: USER_MESSAGE.SYSTEM_ERROR,
4625
4653
  data: error
4626
4654
  };
4627
4655
  }
@@ -4744,7 +4772,7 @@ class Http {
4744
4772
  errorString: stringifyError(error)
4745
4773
  });
4746
4774
  const status = error.response?.status;
4747
- _message = status && HTTP_STATUS_MESSAGE[status] || `网络错误: ${error.message} ${status}`;
4775
+ _message = status && HTTP_STATUS_MESSAGE[status] || USER_MESSAGE.NETWORK_ERROR;
4748
4776
  break;
4749
4777
  }
4750
4778
  }
@@ -12505,7 +12533,7 @@ const douyinGetVerifyQrCode = async (task, params)=>{
12505
12533
  });
12506
12534
  const qrData = qrCodeResponse?.data;
12507
12535
  task.logger.info(`获取二维码响应: error_code=${qrData?.error_code}, message=${qrCodeResponse?.message}`);
12508
- if (qrData?.error_code !== 0) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, `获取二维码失败: error_code=${qrData?.error_code}`, "");
12536
+ if (qrData?.error_code !== 0) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, USER_MESSAGE.QRCODE_FETCH_FAILED, "");
12509
12537
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "获取二维码成功", {
12510
12538
  qrcode: qrData.qrcode,
12511
12539
  token: qrData.token,
@@ -12520,7 +12548,7 @@ const douyinGetVerifyQrCode = async (task, params)=>{
12520
12548
  } catch (err) {
12521
12549
  const msg = err instanceof Error ? err.message : String(err);
12522
12550
  task.logger.warn(`[douyinGetVerifyQrCode] 获取二维码失败: ${msg}`);
12523
- return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, `获取二维码失败: ${msg}`, "");
12551
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(500, USER_MESSAGE.QRCODE_FETCH_FAILED, "");
12524
12552
  }
12525
12553
  };
12526
12554
  const DouyinGetWorkListParamsSchema = ActionCommonParamsSchema.extend({
@@ -13835,18 +13863,10 @@ const mock_mockAction = async (task, params)=>{
13835
13863
  });
13836
13864
  } catch (error) {
13837
13865
  const handledError = Http.handleApiError(error);
13838
- const isProxyOrNetworkError = [
13839
- 599,
13840
- 500,
13841
- 502,
13842
- 503,
13843
- 504
13844
- ].includes(handledError.code);
13845
- if (isProxyOrNetworkError) {
13846
- const isProxyRequest = handledError.extra?.isProxyRequest === true;
13847
- const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
13848
- const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
13849
- task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
13866
+ const classified = classifyPublishError(handledError);
13867
+ if (classified) {
13868
+ const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
13869
+ task.logger.error(`[douyinPublish] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
13850
13870
  await updateTaskState?.({
13851
13871
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
13852
13872
  error: message
@@ -15564,7 +15584,7 @@ async function getDouyinData(_task, params) {
15564
15584
  }
15565
15585
  const errMsg = error instanceof Error ? error.message : String(error);
15566
15586
  _task.logger.error(`抖音账号数据获取失败: ${errMsg}`);
15567
- return types_errorResponse(errMsg || "抖音账号数据获取失败");
15587
+ return types_errorResponse(USER_MESSAGE.DOUYIN_ACCOUNT_FETCH_FAILED);
15568
15588
  }
15569
15589
  }
15570
15590
  async function getShipinhaoData(_task, params) {
@@ -15695,7 +15715,7 @@ async function getShipinhaoData(_task, params) {
15695
15715
  }
15696
15716
  const errMsg = error instanceof Error ? error.message : String(error);
15697
15717
  _task.logger.error(`视频号账号数据获取失败: ${errMsg}`);
15698
- return types_errorResponse(errMsg || "视频号账号数据获取失败");
15718
+ return types_errorResponse(USER_MESSAGE.SHIPINHAO_ACCOUNT_FETCH_FAILED);
15699
15719
  }
15700
15720
  }
15701
15721
  async function getToutiaoData(_task, params) {
@@ -16134,7 +16154,9 @@ async function handleBaijiahaoData(_task, params) {
16134
16154
  } : null
16135
16155
  }, "百家号文章数据获取成功");
16136
16156
  } catch (error) {
16137
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
16157
+ const errMsg = error instanceof Error ? error.message : String(error);
16158
+ _task.logger.error(`百家号文章数据获取失败: ${errMsg}`);
16159
+ return searchPublishInfo_types_errorResponse(USER_MESSAGE.BJH_POST_FETCH_FAILED);
16138
16160
  }
16139
16161
  }
16140
16162
  async function handleDouyinData(_task, params) {
@@ -16229,7 +16251,9 @@ async function handleDouyinData(_task, params) {
16229
16251
  } : null
16230
16252
  }, "抖音数据获取成功");
16231
16253
  } catch (error) {
16232
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
16254
+ const errMsg = error instanceof Error ? error.message : String(error);
16255
+ _task.logger.error(`抖音作品数据获取失败: ${errMsg}`);
16256
+ return searchPublishInfo_types_errorResponse(USER_MESSAGE.DOUYIN_POST_FETCH_FAILED);
16233
16257
  }
16234
16258
  }
16235
16259
  async function handleShipinhaoData(_task, params) {
@@ -16394,8 +16418,9 @@ async function handleShipinhaoData(_task, params) {
16394
16418
  }, "视频号数据获取成功");
16395
16419
  } catch (error) {
16396
16420
  const errMsg = error instanceof Error ? error.message : String(error);
16421
+ _task.logger.error(`视频号作品数据获取失败: ${errMsg}`);
16397
16422
  if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
16398
- return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
16423
+ return searchPublishInfo_types_errorResponse(USER_MESSAGE.SHIPINHAO_POST_FETCH_FAILED);
16399
16424
  }
16400
16425
  }
16401
16426
  async function handleToutiaoData(_task, params) {
@@ -16480,7 +16505,9 @@ async function handleToutiaoData(_task, params) {
16480
16505
  } : null
16481
16506
  }, "头条号文章文章获取成功");
16482
16507
  } catch (error) {
16483
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
16508
+ const errMsg = error instanceof Error ? error.message : String(error);
16509
+ _task.logger.error(`头条号文章数据获取失败: ${errMsg}`);
16510
+ return searchPublishInfo_types_errorResponse(USER_MESSAGE.TT_POST_FETCH_FAILED);
16484
16511
  }
16485
16512
  }
16486
16513
  async function handleWeixinData(_task, params) {
@@ -18855,18 +18882,10 @@ const shipinhaoPublish_mock_mockAction = async (task, params)=>{
18855
18882
  });
18856
18883
  } catch (error) {
18857
18884
  const handledError = Http.handleApiError(error);
18858
- const isProxyOrNetworkError = [
18859
- 599,
18860
- 500,
18861
- 502,
18862
- 503,
18863
- 504
18864
- ].includes(handledError.code);
18865
- if (isProxyOrNetworkError) {
18866
- const isProxyRequest = handledError.extra?.isProxyRequest === true;
18867
- const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
18868
- const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
18869
- task.logger.error(`[shipinhaoPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
18885
+ const classified = classifyPublishError(handledError);
18886
+ if (classified) {
18887
+ const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
18888
+ task.logger.error(`[shipinhaoPublish] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
18870
18889
  await updateTaskState?.({
18871
18890
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
18872
18891
  error: message
@@ -19698,7 +19717,8 @@ const shipinhaoSendMsg = async (_task, params)=>{
19698
19717
  imageBuffer = Buffer.from(await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].promises.readFile(filePath));
19699
19718
  }
19700
19719
  } catch (err) {
19701
- return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, `读取图片失败: ${err instanceof Error ? err.message : String(err)}`, void 0);
19720
+ _task.logger.error(`读取图片失败: ${err instanceof Error ? err.message : String(err)}`);
19721
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, USER_MESSAGE.IMAGE_UPLOAD_FAILED, void 0);
19702
19722
  }
19703
19723
  const md5 = (0, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.createHash)("md5").update(imageBuffer).digest("hex");
19704
19724
  const timestamp = Date.now().toString();
@@ -22209,18 +22229,10 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
22209
22229
  });
22210
22230
  } catch (error) {
22211
22231
  const handledError = Http.handleApiError(error);
22212
- const isProxyOrNetworkError = [
22213
- 599,
22214
- 500,
22215
- 502,
22216
- 503,
22217
- 504
22218
- ].includes(handledError.code);
22219
- if (isProxyOrNetworkError) {
22220
- const isProxyRequest = handledError.extra?.isProxyRequest === true;
22221
- const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
22222
- const message = `文章发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
22223
- task.logger.error(`[weixinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
22232
+ const classified = classifyPublishError(handledError);
22233
+ if (classified) {
22234
+ const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
22235
+ task.logger.error(`[weixinPublish] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
22224
22236
  await updateTaskState?.({
22225
22237
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
22226
22238
  error: message
@@ -23704,18 +23716,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
23704
23716
  });
23705
23717
  } catch (error) {
23706
23718
  const handledError = Http.handleApiError(error);
23707
- const isProxyOrNetworkError = [
23708
- 599,
23709
- 500,
23710
- 502,
23711
- 503,
23712
- 504
23713
- ].includes(handledError.code);
23714
- if (isProxyOrNetworkError) {
23715
- const isProxyRequest = handledError.extra?.isProxyRequest === true;
23716
- const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
23717
- const message = `文章发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
23718
- task.logger.error(`[xiaohongshuPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
23719
+ const classified = classifyPublishError(handledError);
23720
+ if (classified) {
23721
+ const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
23722
+ task.logger.error(`[xiaohongshuPublish] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
23719
23723
  await updateTaskState?.({
23720
23724
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
23721
23725
  error: message
@@ -25689,5 +25693,4 @@ class Action {
25689
25693
  var __webpack_exports__version = package_namespaceObject.i8;
25690
25694
  export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, douyinConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, shipinhaoConfigDataSchema, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
25691
25695
 
25692
- //# sourceMappingURL=index.mjs.map
25693
- //# debugId=4801cf8d-6f2d-5cdd-9a97-97673fa7dfff
25696
+ //# sourceMappingURL=index.mjs.map