@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/bundle.js +31 -5
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
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 ? "定时发布" : "确认发布"
|
|
@@ -4212,6 +4218,7 @@ var __webpack_exports__ = {};
|
|
|
4212
4218
|
64703: "摘要超出120字长度限制,请修改摘要后重试。",
|
|
4213
4219
|
"-4": "不支持发布审核中或转码中的视频",
|
|
4214
4220
|
"-2": "不支持发布审核中或转码中的视频",
|
|
4221
|
+
"-1": "系统错误,请注意备份内容后重试",
|
|
4215
4222
|
770001: "不支持发布审核中或转码中的视频",
|
|
4216
4223
|
200074: "系统繁忙,请稍后重试!",
|
|
4217
4224
|
64702: "标题超出64字长度限制,请修改标题后重试。"
|
|
@@ -4294,7 +4301,9 @@ var __webpack_exports__ = {};
|
|
|
4294
4301
|
const uploadImages = async (images)=>{
|
|
4295
4302
|
const cloudImages = [];
|
|
4296
4303
|
const localImages = await Promise.all(images.map((url)=>{
|
|
4297
|
-
|
|
4304
|
+
let fileName = (0, share_namespaceObject.getFilenameFromUrl)(url);
|
|
4305
|
+
let ext = external_node_path_default().extname(fileName);
|
|
4306
|
+
fileName = ext ? fileName : `${fileName}.png`;
|
|
4298
4307
|
return (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
4299
4308
|
}));
|
|
4300
4309
|
for(let index = 0; index < images.length; index++){
|
|
@@ -4595,6 +4604,7 @@ var __webpack_exports__ = {};
|
|
|
4595
4604
|
masssend_check: 1,
|
|
4596
4605
|
is_masssend: 1
|
|
4597
4606
|
};
|
|
4607
|
+
task._timerRecord['PrePublish'] = Date.now();
|
|
4598
4608
|
const { appMsgId } = await http.api({
|
|
4599
4609
|
method: "post",
|
|
4600
4610
|
url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
|
|
@@ -5067,7 +5077,9 @@ var __webpack_exports__ = {};
|
|
|
5067
5077
|
await titleInstance.fill(params.settingInfo.wxAbstract);
|
|
5068
5078
|
}
|
|
5069
5079
|
if (params.settingInfo.wxCover) {
|
|
5070
|
-
|
|
5080
|
+
let fileName = (0, share_namespaceObject.getFilenameFromUrl)(params.settingInfo.wxCover);
|
|
5081
|
+
let ext = external_node_path_default().extname(fileName);
|
|
5082
|
+
fileName = ext ? fileName : `${fileName}.png`;
|
|
5071
5083
|
const cover = await (0, share_namespaceObject.downloadImage)(params.settingInfo.wxCover, external_node_path_default().join(tmpCachePath, fileName));
|
|
5072
5084
|
await page.locator("#article_setting_area #js_cover_area .select-cover__btn").hover();
|
|
5073
5085
|
await page.locator("#article_setting_area #js_cover_area .pop-opr__group-select-cover .pop-opr__list .pop-opr__item").filter({
|
|
@@ -5251,6 +5263,7 @@ var __webpack_exports__ = {};
|
|
|
5251
5263
|
await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
|
|
5252
5264
|
}
|
|
5253
5265
|
await page.waitForTimeout(1000);
|
|
5266
|
+
task._timerRecord['PrePublish'] = Date.now();
|
|
5254
5267
|
const articleId = await new Promise(async (resolve)=>{
|
|
5255
5268
|
const handleResponse = async (response)=>{
|
|
5256
5269
|
const url = response.url();
|
|
@@ -5782,6 +5795,7 @@ var __webpack_exports__ = {};
|
|
|
5782
5795
|
};
|
|
5783
5796
|
}
|
|
5784
5797
|
}
|
|
5798
|
+
task._timerRecord['PrePublish'] = Date.now();
|
|
5785
5799
|
const business_binds = {
|
|
5786
5800
|
version: 1,
|
|
5787
5801
|
bizType: "",
|
|
@@ -6009,6 +6023,7 @@ var __webpack_exports__ = {};
|
|
|
6009
6023
|
hasText: "仅自己可见"
|
|
6010
6024
|
}).click();
|
|
6011
6025
|
}
|
|
6026
|
+
task._timerRecord['PrePublish'] = Date.now();
|
|
6012
6027
|
const releaseTimeInstance = page.locator("label").filter({
|
|
6013
6028
|
hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
|
|
6014
6029
|
});
|
|
@@ -6034,21 +6049,32 @@ var __webpack_exports__ = {};
|
|
|
6034
6049
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
6035
6050
|
};
|
|
6036
6051
|
var package_namespaceObject = {
|
|
6037
|
-
i8: "1.2.
|
|
6052
|
+
i8: "1.2.19"
|
|
6038
6053
|
};
|
|
6054
|
+
const BetaFlag = "HuiwenCanary";
|
|
6039
6055
|
class Action {
|
|
6040
6056
|
constructor(task){
|
|
6041
6057
|
this.task = task;
|
|
6042
6058
|
}
|
|
6043
6059
|
async bindTask(func, params) {
|
|
6044
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 ? "测试用户" : "非测试用户"}`);
|
|
6045
6066
|
if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
|
|
6046
|
-
if (
|
|
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 ?? [];
|
|
6047
6070
|
try {
|
|
6048
6071
|
responseData = await func(this.task, params);
|
|
6049
6072
|
} catch (error) {
|
|
6050
6073
|
responseData = Http.handleApiError(error);
|
|
6074
|
+
} finally{
|
|
6075
|
+
this.task._timerRecord['ActionEnd'] = Date.now();
|
|
6051
6076
|
}
|
|
6077
|
+
if (this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
|
|
6052
6078
|
if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
|
|
6053
6079
|
else if (0 !== responseData.code) {
|
|
6054
6080
|
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
|