@iflyrpa/actions 1.2.18 → 1.2.20-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.
package/dist/index.mjs CHANGED
@@ -2047,7 +2047,8 @@ const errnoMap = {
2047
2047
  20040034: "封面图片推荐jpg、png格式,不支持gif格式。",
2048
2048
  20040124: "服务器异常,请稍后重试!",
2049
2049
  20040001: "当前用户未登录,请登陆后重试!",
2050
- 401100025: "该应用不支持此媒资类型"
2050
+ 401100025: "该应用不支持此媒资类型",
2051
+ 401100033: "图片宽高不满足要求"
2051
2052
  };
2052
2053
  const mockAction = async (task, params)=>{
2053
2054
  const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
@@ -2172,6 +2173,7 @@ const mockAction = async (task, params)=>{
2172
2173
  };
2173
2174
  const isDraft = "draft" === params.saveType;
2174
2175
  const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
2176
+ task._timerRecord['PrePublish'] = Date.now();
2175
2177
  const res = await http.api({
2176
2178
  method: "post",
2177
2179
  url: saveUrl,
@@ -2309,6 +2311,7 @@ const rpaAction = async (task, params)=>{
2309
2311
  }
2310
2312
  };
2311
2313
  page.on("response", handleResponse);
2314
+ task._timerRecord['PrePublish'] = Date.now();
2312
2315
  const operatorContainer = page.locator(".editor-component-operator");
2313
2316
  if ("draft" === params.saveType) await operatorContainer.locator(".op-btn-outter-content").filter({
2314
2317
  hasText: "存草稿"
@@ -2871,6 +2874,7 @@ const mock_mockAction = async (task, params)=>{
2871
2874
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
2872
2875
  claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
2873
2876
  };
2877
+ task._timerRecord['PrePublish'] = Date.now();
2874
2878
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
2875
2879
  let publishOption = {};
2876
2880
  if (msToken) {
@@ -3115,6 +3119,7 @@ const rpa_rpaAction = async (task, params)=>{
3115
3119
  const confirmBtn = page.locator('div.byte-modal-footer button.byte-btn-primary:has-text("确定")');
3116
3120
  if (await confirmBtn.isVisible()) await confirmBtn.click();
3117
3121
  }
3122
+ task._timerRecord['PrePublish'] = Date.now();
3118
3123
  if ("publish" === params.saveType) {
3119
3124
  await page.locator(".publish-footer button").filter({
3120
3125
  hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
@@ -4161,6 +4166,7 @@ const weixinPublish_mock_errnoMap = {
4161
4166
  64703: "摘要超出120字长度限制,请修改摘要后重试。",
4162
4167
  "-4": "不支持发布审核中或转码中的视频",
4163
4168
  "-2": "不支持发布审核中或转码中的视频",
4169
+ "-1": "系统错误,请注意备份内容后重试",
4164
4170
  770001: "不支持发布审核中或转码中的视频",
4165
4171
  200074: "系统繁忙,请稍后重试!",
4166
4172
  64702: "标题超出64字长度限制,请修改标题后重试。"
@@ -4243,7 +4249,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
4243
4249
  const uploadImages = async (images)=>{
4244
4250
  const cloudImages = [];
4245
4251
  const localImages = await Promise.all(images.map((url)=>{
4246
- const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
4252
+ let fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
4253
+ let ext = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(fileName);
4254
+ fileName = ext ? fileName : `${fileName}.png`;
4247
4255
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
4248
4256
  }));
4249
4257
  for(let index = 0; index < images.length; index++){
@@ -4544,6 +4552,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
4544
4552
  masssend_check: 1,
4545
4553
  is_masssend: 1
4546
4554
  };
4555
+ task._timerRecord['PrePublish'] = Date.now();
4547
4556
  const { appMsgId } = await http.api({
4548
4557
  method: "post",
4549
4558
  url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
@@ -5016,7 +5025,9 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
5016
5025
  await titleInstance.fill(params.settingInfo.wxAbstract);
5017
5026
  }
5018
5027
  if (params.settingInfo.wxCover) {
5019
- const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(params.settingInfo.wxCover);
5028
+ let fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(params.settingInfo.wxCover);
5029
+ let ext = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(fileName);
5030
+ fileName = ext ? fileName : `${fileName}.png`;
5020
5031
  const cover = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(params.settingInfo.wxCover, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
5021
5032
  await page.locator("#article_setting_area #js_cover_area .select-cover__btn").hover();
5022
5033
  await page.locator("#article_setting_area #js_cover_area .pop-opr__group-select-cover .pop-opr__list .pop-opr__item").filter({
@@ -5200,6 +5211,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
5200
5211
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
5201
5212
  }
5202
5213
  await page.waitForTimeout(1000);
5214
+ task._timerRecord['PrePublish'] = Date.now();
5203
5215
  const articleId = await new Promise(async (resolve)=>{
5204
5216
  const handleResponse = async (response)=>{
5205
5217
  const url = response.url();
@@ -5731,6 +5743,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5731
5743
  };
5732
5744
  }
5733
5745
  }
5746
+ task._timerRecord['PrePublish'] = Date.now();
5734
5747
  const business_binds = {
5735
5748
  version: 1,
5736
5749
  bizType: "",
@@ -5958,6 +5971,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5958
5971
  hasText: "仅自己可见"
5959
5972
  }).click();
5960
5973
  }
5974
+ task._timerRecord['PrePublish'] = Date.now();
5961
5975
  const releaseTimeInstance = page.locator("label").filter({
5962
5976
  hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
5963
5977
  });
@@ -5983,21 +5997,32 @@ const xiaohongshuPublish = async (task, params)=>{
5983
5997
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5984
5998
  };
5985
5999
  var package_namespaceObject = {
5986
- i8: "1.2.17"
6000
+ i8: "1.2.19"
5987
6001
  };
6002
+ const BetaFlag = "HuiwenCanary";
5988
6003
  class Action {
5989
6004
  constructor(task){
5990
6005
  this.task = task;
5991
6006
  }
5992
6007
  async bindTask(func, params) {
5993
6008
  let responseData;
6009
+ this.task._timerRecord = {
6010
+ ActionStart: Date.now()
6011
+ };
6012
+ this.task.isBeta = this.task.isFeatOn(BetaFlag);
6013
+ console.log(`当前用户: ${this.task.isBeta ? "测试用户" : "非测试用户"}`);
5994
6014
  if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
5995
- if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
6015
+ if (this.task.setSaveType) this.task.setSaveType(params.saveType ?? "");
6016
+ if (void 0 !== this.task.isInitializedGB) this.task.setGbInitType(this.task.isInitializedGB);
6017
+ if ("object" == typeof params) params.cookies = params?.cookies ?? [];
5996
6018
  try {
5997
6019
  responseData = await func(this.task, params);
5998
6020
  } catch (error) {
5999
6021
  responseData = Http.handleApiError(error);
6022
+ } finally{
6023
+ this.task._timerRecord['ActionEnd'] = Date.now();
6000
6024
  }
6025
+ if (this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
6001
6026
  if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
6002
6027
  else if (0 !== responseData.code) {
6003
6028
  this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
@@ -6082,6 +6107,6 @@ class Action {
6082
6107
  }
6083
6108
  }
6084
6109
  var __webpack_exports__version = package_namespaceObject.i8;
6085
- export { Action, __webpack_exports__version as version };
6110
+ export { Action, BetaFlag, __webpack_exports__version as version };
6086
6111
 
6087
6112
  //# sourceMappingURL=index.mjs.map