@iflyrpa/actions 1.2.19 → 1.2.20-beta.1

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 ? "定时发布" : "确认发布"
@@ -4547,6 +4552,7 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
4547
4552
  masssend_check: 1,
4548
4553
  is_masssend: 1
4549
4554
  };
4555
+ task._timerRecord['PrePublish'] = Date.now();
4550
4556
  const { appMsgId } = await http.api({
4551
4557
  method: "post",
4552
4558
  url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
@@ -5205,6 +5211,7 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
5205
5211
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
5206
5212
  }
5207
5213
  await page.waitForTimeout(1000);
5214
+ task._timerRecord['PrePublish'] = Date.now();
5208
5215
  const articleId = await new Promise(async (resolve)=>{
5209
5216
  const handleResponse = async (response)=>{
5210
5217
  const url = response.url();
@@ -5736,6 +5743,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5736
5743
  };
5737
5744
  }
5738
5745
  }
5746
+ task._timerRecord['PrePublish'] = Date.now();
5739
5747
  const business_binds = {
5740
5748
  version: 1,
5741
5749
  bizType: "",
@@ -5963,6 +5971,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5963
5971
  hasText: "仅自己可见"
5964
5972
  }).click();
5965
5973
  }
5974
+ task._timerRecord['PrePublish'] = Date.now();
5966
5975
  const releaseTimeInstance = page.locator("label").filter({
5967
5976
  hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
5968
5977
  });
@@ -5987,22 +5996,30 @@ const xiaohongshuPublish = async (task, params)=>{
5987
5996
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
5988
5997
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5989
5998
  };
5990
- var package_namespaceObject = {
5991
- i8: "1.2.18"
5992
- };
5999
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.20-beta.0"}');
6000
+ const BetaFlag = "HuiwenCanary";
5993
6001
  class Action {
5994
6002
  constructor(task){
5995
6003
  this.task = task;
5996
6004
  }
5997
6005
  async bindTask(func, params) {
5998
6006
  let responseData;
6007
+ this.task.isBeta = this.task.isFeatOn(BetaFlag);
6008
+ this.task._timerRecord = {
6009
+ ActionStart: Date.now()
6010
+ };
5999
6011
  if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
6000
- if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
6012
+ if (this.task.setSaveType) this.task.setSaveType(params.saveType ?? "");
6013
+ if (void 0 !== this.task.isInitializedGB) this.task.setGbInitType(this.task.isInitializedGB);
6014
+ if ("object" == typeof params) params.cookies = params?.cookies ?? [];
6001
6015
  try {
6002
6016
  responseData = await func(this.task, params);
6003
6017
  } catch (error) {
6004
6018
  responseData = Http.handleApiError(error);
6019
+ } finally{
6020
+ this.task._timerRecord['ActionEnd'] = Date.now();
6005
6021
  }
6022
+ if (this.task.isBeta && this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
6006
6023
  if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
6007
6024
  else if (0 !== responseData.code) {
6008
6025
  this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
@@ -6087,6 +6104,6 @@ class Action {
6087
6104
  }
6088
6105
  }
6089
6106
  var __webpack_exports__version = package_namespaceObject.i8;
6090
- export { Action, __webpack_exports__version as version };
6107
+ export { Action, BetaFlag, __webpack_exports__version as version };
6091
6108
 
6092
6109
  //# sourceMappingURL=index.mjs.map