@iflyrpa/actions 1.2.19 → 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.d.ts CHANGED
@@ -19,6 +19,7 @@ import { type WeixinPublishParams } from "./actions/weixinPublish";
19
19
  import { type WeixinmpPublishParams } from "./actions/weixinmpPublish";
20
20
  import { type XiaohongshuPublishParams } from "./actions/xiaohongshuPublish";
21
21
  import type { ActiomCommonParams } from "./types";
22
+ export declare const BetaFlag = "HuiwenCanary";
22
23
  export declare class Action {
23
24
  private task;
24
25
  constructor(task: AutomateTask);
package/dist/index.js CHANGED
@@ -1810,6 +1810,7 @@ var __webpack_exports__ = {};
1810
1810
  __webpack_require__.r(__webpack_exports__);
1811
1811
  __webpack_require__.d(__webpack_exports__, {
1812
1812
  version: ()=>package_namespaceObject.i8,
1813
+ BetaFlag: ()=>BetaFlag,
1813
1814
  Action: ()=>Action
1814
1815
  });
1815
1816
  const external_node_fs_namespaceObject = require("node:fs");
@@ -2095,7 +2096,8 @@ var __webpack_exports__ = {};
2095
2096
  20040034: "封面图片推荐jpg、png格式,不支持gif格式。",
2096
2097
  20040124: "服务器异常,请稍后重试!",
2097
2098
  20040001: "当前用户未登录,请登陆后重试!",
2098
- 401100025: "该应用不支持此媒资类型"
2099
+ 401100025: "该应用不支持此媒资类型",
2100
+ 401100033: "图片宽高不满足要求"
2099
2101
  };
2100
2102
  const mockAction = async (task, params)=>{
2101
2103
  const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
@@ -2220,6 +2222,7 @@ var __webpack_exports__ = {};
2220
2222
  };
2221
2223
  const isDraft = "draft" === params.saveType;
2222
2224
  const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
2225
+ task._timerRecord['PrePublish'] = Date.now();
2223
2226
  const res = await http.api({
2224
2227
  method: "post",
2225
2228
  url: saveUrl,
@@ -2357,6 +2360,7 @@ var __webpack_exports__ = {};
2357
2360
  }
2358
2361
  };
2359
2362
  page.on("response", handleResponse);
2363
+ task._timerRecord['PrePublish'] = Date.now();
2360
2364
  const operatorContainer = page.locator(".editor-component-operator");
2361
2365
  if ("draft" === params.saveType) await operatorContainer.locator(".op-btn-outter-content").filter({
2362
2366
  hasText: "存草稿"
@@ -2922,6 +2926,7 @@ var __webpack_exports__ = {};
2922
2926
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
2923
2927
  claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
2924
2928
  };
2929
+ task._timerRecord['PrePublish'] = Date.now();
2925
2930
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
2926
2931
  let publishOption = {};
2927
2932
  if (msToken) {
@@ -3166,6 +3171,7 @@ var __webpack_exports__ = {};
3166
3171
  const confirmBtn = page.locator('div.byte-modal-footer button.byte-btn-primary:has-text("确定")');
3167
3172
  if (await confirmBtn.isVisible()) await confirmBtn.click();
3168
3173
  }
3174
+ task._timerRecord['PrePublish'] = Date.now();
3169
3175
  if ("publish" === params.saveType) {
3170
3176
  await page.locator(".publish-footer button").filter({
3171
3177
  hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
@@ -4598,6 +4604,7 @@ var __webpack_exports__ = {};
4598
4604
  masssend_check: 1,
4599
4605
  is_masssend: 1
4600
4606
  };
4607
+ task._timerRecord['PrePublish'] = Date.now();
4601
4608
  const { appMsgId } = await http.api({
4602
4609
  method: "post",
4603
4610
  url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
@@ -5256,6 +5263,7 @@ var __webpack_exports__ = {};
5256
5263
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
5257
5264
  }
5258
5265
  await page.waitForTimeout(1000);
5266
+ task._timerRecord['PrePublish'] = Date.now();
5259
5267
  const articleId = await new Promise(async (resolve)=>{
5260
5268
  const handleResponse = async (response)=>{
5261
5269
  const url = response.url();
@@ -5787,6 +5795,7 @@ var __webpack_exports__ = {};
5787
5795
  };
5788
5796
  }
5789
5797
  }
5798
+ task._timerRecord['PrePublish'] = Date.now();
5790
5799
  const business_binds = {
5791
5800
  version: 1,
5792
5801
  bizType: "",
@@ -6014,6 +6023,7 @@ var __webpack_exports__ = {};
6014
6023
  hasText: "仅自己可见"
6015
6024
  }).click();
6016
6025
  }
6026
+ task._timerRecord['PrePublish'] = Date.now();
6017
6027
  const releaseTimeInstance = page.locator("label").filter({
6018
6028
  hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
6019
6029
  });
@@ -6039,21 +6049,32 @@ var __webpack_exports__ = {};
6039
6049
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
6040
6050
  };
6041
6051
  var package_namespaceObject = {
6042
- i8: "1.2.18"
6052
+ i8: "1.2.19"
6043
6053
  };
6054
+ const BetaFlag = "HuiwenCanary";
6044
6055
  class Action {
6045
6056
  constructor(task){
6046
6057
  this.task = task;
6047
6058
  }
6048
6059
  async bindTask(func, params) {
6049
6060
  let responseData;
6061
+ this.task._timerRecord = {
6062
+ ActionStart: Date.now()
6063
+ };
6064
+ this.task.isBeta = this.task.isFeatOn(BetaFlag);
6065
+ console.log(`当前用户: ${this.task.isBeta ? "测试用户" : "非测试用户"}`);
6050
6066
  if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
6051
- if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
6067
+ if (this.task.setSaveType) this.task.setSaveType(params.saveType ?? "");
6068
+ if (void 0 !== this.task.isInitializedGB) this.task.setGbInitType(this.task.isInitializedGB);
6069
+ if ("object" == typeof params) params.cookies = params?.cookies ?? [];
6052
6070
  try {
6053
6071
  responseData = await func(this.task, params);
6054
6072
  } catch (error) {
6055
6073
  responseData = Http.handleApiError(error);
6074
+ } finally{
6075
+ this.task._timerRecord['ActionEnd'] = Date.now();
6056
6076
  }
6077
+ if (this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
6057
6078
  if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
6058
6079
  else if (0 !== responseData.code) {
6059
6080
  this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);