@iflyrpa/actions 4.0.8 → 4.0.9-beta.0

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.
@@ -48,9 +48,9 @@ export declare const FetchArticlesParamsSchema: z.ZodObject<{
48
48
  status: z.ZodOptional<z.ZodNumber>;
49
49
  includeAccount: z.ZodOptional<z.ZodBoolean>;
50
50
  postType: z.ZodOptional<z.ZodEnum<{
51
+ all: "all";
51
52
  article: "article";
52
53
  video: "video";
53
- all: "all";
54
54
  }>>;
55
55
  }, z.core.$strip>;
56
56
  export type FetchArticlesParams = z.infer<typeof FetchArticlesParamsSchema>;
package/dist/bundle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
2
 
3
- !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]="5ecc4d57-e612-5298-a097-3acb08559a65")}catch(e){}}();
3
+ !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]="c3fbb52e-5d33-5353-8489-fe175df23e81")}catch(e){}}();
4
4
  var __webpack_modules__ = {
5
5
  "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
6
6
  "use strict";
@@ -12492,9 +12492,7 @@ var __webpack_exports__ = {};
12492
12492
  var package_namespaceObject = {
12493
12493
  i8: "0.1.2"
12494
12494
  };
12495
- var package_namespaceObject_0 = {
12496
- i8: "4.0.8"
12497
- };
12495
+ var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.9-beta.0"}');
12498
12496
  const external_node_fs_namespaceObject = require("node:fs");
12499
12497
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
12500
12498
  const external_node_http_namespaceObject = require("node:http");
@@ -12940,7 +12938,7 @@ var __webpack_exports__ = {};
12940
12938
  Number.MAX_VALUE
12941
12939
  ]
12942
12940
  };
12943
- function pick(schema, mask) {
12941
+ function dist_pick(schema, mask) {
12944
12942
  const currDef = schema._zod.def;
12945
12943
  const def = mergeDefs(schema._zod.def, {
12946
12944
  get shape () {
@@ -15794,7 +15792,7 @@ var __webpack_exports__ = {};
15794
15792
  inst.extend = (incoming)=>extend(inst, incoming);
15795
15793
  inst.safeExtend = (incoming)=>safeExtend(inst, incoming);
15796
15794
  inst.merge = (other)=>dist_merge(inst, other);
15797
- inst.pick = (mask)=>pick(inst, mask);
15795
+ inst.pick = (mask)=>dist_pick(inst, mask);
15798
15796
  inst.omit = (mask)=>omit(inst, mask);
15799
15797
  inst.partial = (...args)=>dist_partial(ZodOptional, inst, args[0]);
15800
15798
  inst.required = (...args)=>required(ZodNonOptional, inst, args[0]);
@@ -27041,6 +27039,94 @@ var __webpack_exports__ = {};
27041
27039
  axios.HttpStatusCode = helpers_HttpStatusCode;
27042
27040
  axios.default = axios;
27043
27041
  const lib_axios = axios;
27042
+ const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
27043
+ const ALARM_THROTTLE_MS = 60000;
27044
+ const lastSentAt = new Map();
27045
+ const postFeishuWebhook = (webhookUrl, payload)=>lib_axios.post(webhookUrl, payload, {
27046
+ headers: {
27047
+ "Content-Type": "application/json"
27048
+ },
27049
+ timeout: 10000
27050
+ });
27051
+ const buildFeishuPostMessage = (report)=>{
27052
+ const content = [
27053
+ [
27054
+ {
27055
+ tag: "text",
27056
+ text: `平台:${report.platform || "未知平台"}`
27057
+ }
27058
+ ],
27059
+ [
27060
+ {
27061
+ tag: "text",
27062
+ text: `错误信息:${report.msg || "未知错误信息"}`
27063
+ }
27064
+ ],
27065
+ [
27066
+ {
27067
+ tag: "text",
27068
+ text: `错误类型:${report.errorType || "未知错误类型"}`
27069
+ }
27070
+ ],
27071
+ [
27072
+ {
27073
+ tag: "text",
27074
+ text: `阶段:${report.stage || "未知阶段"}`
27075
+ }
27076
+ ],
27077
+ [
27078
+ {
27079
+ tag: "text",
27080
+ text: `等级:${report.level}`
27081
+ }
27082
+ ],
27083
+ [
27084
+ {
27085
+ tag: "text",
27086
+ text: `来源:${report.source}`
27087
+ }
27088
+ ]
27089
+ ];
27090
+ if (void 0 !== report.code && null !== report.code) content.push([
27091
+ {
27092
+ tag: "text",
27093
+ text: `接口错误码:${report.code}`
27094
+ }
27095
+ ]);
27096
+ if (report.url) content.push([
27097
+ {
27098
+ tag: "text",
27099
+ text: `地址:${report.url}`
27100
+ }
27101
+ ]);
27102
+ if ("alarm" === report.level) content.push([
27103
+ {
27104
+ tag: "at",
27105
+ user_id: "all"
27106
+ }
27107
+ ]);
27108
+ return {
27109
+ msg_type: "post",
27110
+ content: {
27111
+ post: {
27112
+ zh_cn: {
27113
+ title: report.title || "RPA异常",
27114
+ content
27115
+ }
27116
+ }
27117
+ }
27118
+ };
27119
+ };
27120
+ const reportFeishuAlarm = (report)=>{
27121
+ try {
27122
+ const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
27123
+ const now = Date.now();
27124
+ const last = lastSentAt.get(key);
27125
+ if (last && now - last < ALARM_THROTTLE_MS) return;
27126
+ lastSentAt.set(key, now);
27127
+ postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
27128
+ } catch {}
27129
+ };
27044
27130
  var dist = __webpack_require__("../../node_modules/.pnpm/socks-proxy-agent@8.0.4/node_modules/socks-proxy-agent/dist/index.js");
27045
27131
  const PROXY_CREDENTIALS = [
27046
27132
  {
@@ -27143,6 +27229,17 @@ var __webpack_exports__ = {};
27143
27229
  url: "https://fetdev.iflysec.com/ip-pool/pool/eip/proxy",
27144
27230
  data: params
27145
27231
  }).catch((err)=>{
27232
+ reportFeishuAlarm({
27233
+ level: "alarm",
27234
+ platform: "ip-pool",
27235
+ source: "proxy",
27236
+ stage: "POST /ip-pool/pool/eip/proxy",
27237
+ errorType: "PROXY_REQUEST_FAILED",
27238
+ code: err?.code,
27239
+ msg: `请求代理失败:${err.message},区域:${addr ?? "-"},AccountId:${accountId ?? "-"}`,
27240
+ url: "https://fetdev.iflysec.com/ip-pool/pool/eip/proxy",
27241
+ title: "代理异常"
27242
+ });
27146
27243
  throw {
27147
27244
  code: 414,
27148
27245
  message: `请求代理失败:${err.message}`,
@@ -27165,6 +27262,47 @@ var __webpack_exports__ = {};
27165
27262
  } : null;
27166
27263
  return proxyAgent;
27167
27264
  }
27265
+ const ALARM_STATUS = new Set([
27266
+ 401,
27267
+ 403,
27268
+ 429,
27269
+ 461,
27270
+ 471
27271
+ ]);
27272
+ const HTTP_STATUS_MESSAGE = {
27273
+ 400: "请求参数错误,请检查参数格式是否正确!",
27274
+ 401: "登录状态已失效,请重新登录后重试!",
27275
+ 403: "没有访问权限,账号可能受限或签名已失效!",
27276
+ 404: "请求的资源不存在,请检查接口地址!",
27277
+ 405: "请求方法不被允许,请检查接口调用方式!",
27278
+ 406: "服务端无法返回可接受的内容格式!",
27279
+ 407: "代理需要身份验证,请检查代理配置!",
27280
+ 408: "请求超时,请检查网络连接!",
27281
+ 409: "请求冲突,资源状态已变更,请刷新后重试!",
27282
+ 410: "请求的资源已被移除!",
27283
+ 412: "请求前置条件不满足,请刷新后重试!",
27284
+ 413: "提交内容过大,请压缩或分批后重试!",
27285
+ 414: "请求地址过长,请检查参数!",
27286
+ 415: "不支持的内容类型,请检查请求格式!",
27287
+ 422: "请求内容校验失败,请检查参数内容!",
27288
+ 423: "资源已被锁定,请稍后重试!",
27289
+ 429: "请求过于频繁,请稍后重试!",
27290
+ 431: "请求头过大,请清理 Cookie 后重试!",
27291
+ 451: "内容不合规或因法律原因被拒绝!",
27292
+ 461: "账号可能受限,请在网页上完成验证后重试!",
27293
+ 471: "账号可能受限,请在网页上完成验证后重试!",
27294
+ 500: "服务器内部错误,请稍后重试!",
27295
+ 501: "服务端不支持该请求,请稍后重试!",
27296
+ 502: "网关错误,请稍后重试!",
27297
+ 503: "服务暂时不可用,请稍后重试!",
27298
+ 504: "网关超时,请稍后重试!",
27299
+ 507: "服务端存储空间不足,请稍后重试!",
27300
+ 509: "服务带宽超限,请稍后重试!",
27301
+ 520: "服务端返回未知错误,请稍后重试!",
27302
+ 521: "源站拒绝连接,请稍后重试!",
27303
+ 522: "源站连接超时,请稍后重试!",
27304
+ 524: "源站响应超时,请稍后重试!"
27305
+ };
27168
27306
  class Http {
27169
27307
  static handleApiError(error) {
27170
27308
  if (error && "object" == typeof error && "code" in error && "message" in error) return error;
@@ -27225,6 +27363,18 @@ var __webpack_exports__ = {};
27225
27363
  const verifyDecision = error.response?.headers?.["x-tt-verify-passport-decision"];
27226
27364
  if (verifyDecision) this.logger?.warn(`[403 验证决策] x-tt-verify-passport-decision: ${verifyDecision}`);
27227
27365
  }
27366
+ if (error.response?.status === 461 || error.response?.status === 471) {
27367
+ const h = error.response?.headers ?? {};
27368
+ const pick = (name)=>h[name] ?? h[name.toLowerCase()];
27369
+ this.logger?.warn(`[${error.response.status} 风控验证] URL: ${error.config?.url} Verifytype: ${pick("Verifytype") ?? "-"} Verifyuuid: ${pick("Verifyuuid") ?? "-"} Verifybiz: ${pick("Verifybiz") ?? "-"}`);
27370
+ this.logger?.warn(`[${error.response.status} 响应头] ${JSON.stringify(h)}`);
27371
+ errorResponse.extra = {
27372
+ ...errorResponse.extra,
27373
+ verifyType: pick("Verifytype"),
27374
+ verifyUuid: pick("Verifyuuid"),
27375
+ verifyBiz: pick("Verifybiz")
27376
+ };
27377
+ }
27228
27378
  if (error.response?.data) {
27229
27379
  if ("object" == typeof error.response.data) {
27230
27380
  const serverError = error.response.data;
@@ -27255,11 +27405,17 @@ var __webpack_exports__ = {};
27255
27405
  _message = "DNS 查询超时,请稍后重试!";
27256
27406
  break;
27257
27407
  case "ERR_BAD_REQUEST":
27258
- _message = "请求出现错误,请检查请求参数!";
27259
- break;
27408
+ {
27409
+ const status = error.response?.status;
27410
+ _message = status && HTTP_STATUS_MESSAGE[status] || `请求失败,状态码${status ?? "unknown"}!`;
27411
+ break;
27412
+ }
27260
27413
  case "ERR_BAD_RESPONSE":
27261
- _message = `服务器响应异常 (${error.response?.status ?? "unknown"}),请稍后重试!`;
27262
- break;
27414
+ {
27415
+ const status = error.response?.status;
27416
+ _message = status && HTTP_STATUS_MESSAGE[status] || `服务器响应异常 (${status ?? "unknown"}),请稍后重试!`;
27417
+ break;
27418
+ }
27263
27419
  case "ERR_CANCELED":
27264
27420
  errorResponse.code = 414;
27265
27421
  _message = "请求连接超时,请稍候重试!";
@@ -27270,11 +27426,14 @@ var __webpack_exports__ = {};
27270
27426
  }
27271
27427
  break;
27272
27428
  default:
27273
- this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
27274
- errorString: stringifyError(error)
27275
- });
27276
- _message = `网络错误: ${error.message}`;
27277
- break;
27429
+ {
27430
+ this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
27431
+ errorString: stringifyError(error)
27432
+ });
27433
+ const status = error.response?.status;
27434
+ _message = status && HTTP_STATUS_MESSAGE[status] || `网络错误: ${error.message} ${status}`;
27435
+ break;
27436
+ }
27278
27437
  }
27279
27438
  }
27280
27439
  if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
@@ -27284,6 +27443,18 @@ var __webpack_exports__ = {};
27284
27443
  errorResponse.message = message;
27285
27444
  }
27286
27445
  if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
27446
+ const status = error.response?.status;
27447
+ reportFeishuAlarm({
27448
+ level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
27449
+ platform: this.platform || "unknown",
27450
+ source: "http",
27451
+ stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
27452
+ errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
27453
+ code: errorResponse.code,
27454
+ msg: errorResponse.message,
27455
+ url: error.config?.url,
27456
+ title: "RPA接口异常"
27457
+ });
27287
27458
  throw errorResponse;
27288
27459
  });
27289
27460
  }
@@ -48669,6 +48840,7 @@ var __webpack_exports__ = {};
48669
48840
  });
48670
48841
  return success(data, message);
48671
48842
  }
48843
+ task.logger.info(`[xiaohongshuPublish] publishData: ${JSON.stringify(publishData)} `);
48672
48844
  let publishResult;
48673
48845
  try {
48674
48846
  publishResult = await proxyHttp.api({
@@ -48679,8 +48851,8 @@ var __webpack_exports__ = {};
48679
48851
  defaultErrorMsg: "文章发布异常,请稍后重试。"
48680
48852
  }, {
48681
48853
  retries: 2,
48682
- retryDelay: 500,
48683
- timeout: 12000
48854
+ retryDelay: 3000,
48855
+ timeout: 30000
48684
48856
  });
48685
48857
  } catch (error) {
48686
48858
  const handledError = Http.handleApiError(error);
@@ -50674,4 +50846,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
50674
50846
  });
50675
50847
 
50676
50848
  //# sourceMappingURL=bundle.js.map
50677
- //# debugId=5ecc4d57-e612-5298-a097-3acb08559a65
50849
+ //# debugId=c3fbb52e-5d33-5353-8489-fe175df23e81