@iflyrpa/actions 1.1.27 → 1.1.29

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.
@@ -1,13 +1,12 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
3
  interface ActivityData {
4
4
  id: string;
5
5
  task_name: string;
6
6
  [key: string]: any;
7
7
  }
8
- export interface BaijiahaoPublishParams extends Omit<ActiomCommonParams, "cookies"> {
8
+ export interface BaijiahaoPublishParams extends ActiomCommonParams {
9
9
  saveType: "draft" | "publish";
10
- cookies: Partial<CookiesSetDetails>[];
11
10
  token: string;
12
11
  title: string;
13
12
  content: string;
@@ -1,7 +1,6 @@
1
- import { type CommonAction, type CookiesSetDetails } from "@iflyrpa/share";
1
+ import { type CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
- export interface GetBaijiahaoActivityParams extends Omit<ActiomCommonParams, "cookies"> {
4
- cookies: Partial<CookiesSetDetails>[];
3
+ export interface GetBaijiahaoActivityParams extends ActiomCommonParams {
5
4
  token: string;
6
5
  }
7
6
  export interface ActivityData {
@@ -1,7 +1,6 @@
1
- import { type CommonAction, type CookiesSetDetails } from "@iflyrpa/share";
1
+ import { type CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams, Toutiao } from "../../types";
3
- export interface GetToutiaoConfigParams extends Omit<ActiomCommonParams, "cookies"> {
4
- cookies: Partial<CookiesSetDetails>[];
3
+ export interface GetToutiaoConfigParams extends ActiomCommonParams {
5
4
  }
6
5
  export interface GetToutiaoConfigResult {
7
6
  suggestWords: Toutiao.Topic[];
@@ -1,7 +1,6 @@
1
- import { type CommonAction, type CookiesSetDetails } from "@iflyrpa/share";
1
+ import { type CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams, Toutiao } from "../../types";
3
- export interface SearchToutiaoTopicListParams extends Omit<ActiomCommonParams, "cookies"> {
4
- cookies: Partial<CookiesSetDetails>[];
3
+ export interface SearchToutiaoTopicListParams extends ActiomCommonParams {
5
4
  searchValue: string;
6
5
  }
7
6
  export type PublishAction = CommonAction<SearchToutiaoTopicListParams, Toutiao.Topic[]>;
@@ -1,7 +1,6 @@
1
- import { type CommonAction, type CookiesSetDetails } from "@iflyrpa/share";
1
+ import { type CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams, Xiaohongshu } from "../../types";
3
- export interface searchXiaohongshuLocationParams extends Omit<ActiomCommonParams, "cookies"> {
4
- cookies: Partial<CookiesSetDetails>[];
3
+ export interface searchXiaohongshuLocationParams extends ActiomCommonParams {
5
4
  searchValue: string;
6
5
  latitude?: number;
7
6
  longitude?: number;
@@ -1,9 +1,8 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
3
  type CoverType = "single" | "multiple" | "no";
4
- export interface ToutiaoPublishParams extends Omit<ActiomCommonParams, "cookies"> {
4
+ export interface ToutiaoPublishParams extends ActiomCommonParams {
5
5
  saveType: "draft" | "publish";
6
- cookies: Partial<CookiesSetDetails>[];
7
6
  title: string;
8
7
  content: string;
9
8
  settingInfo: {
@@ -1,4 +1,4 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
3
  /**
4
4
  * 作品声明
@@ -11,8 +11,7 @@ import type { ActiomCommonParams } from "../../types";
11
11
  * 8:健康医疗分享,仅供参考
12
12
  */
13
13
  type DeclarationType = 1 | 3 | 4 | 5 | 6 | 7 | 8;
14
- export interface WeitoutiaoPublishParams extends Omit<ActiomCommonParams, "cookies"> {
15
- cookies: Partial<CookiesSetDetails>[];
14
+ export interface WeitoutiaoPublishParams extends ActiomCommonParams {
16
15
  content: string;
17
16
  banners?: string[];
18
17
  address?: string;
@@ -1,9 +1,8 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
- export interface WeixinPublishParams extends Omit<ActiomCommonParams, "cookies"> {
3
+ export interface WeixinPublishParams extends ActiomCommonParams {
4
4
  saveType: "draft" | "publish";
5
5
  token: string | number;
6
- cookies: Partial<CookiesSetDetails>[];
7
6
  title: string;
8
7
  content: string;
9
8
  uuid?: string;
@@ -1,9 +1,8 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams } from "../../types";
3
3
  export type Source = "ai" | "official" | "fictional" | "personal";
4
- export interface WeixinmpPublishParams extends Omit<ActiomCommonParams, "cookies"> {
4
+ export interface WeixinmpPublishParams extends ActiomCommonParams {
5
5
  token: string | number;
6
- cookies: Partial<CookiesSetDetails>[];
7
6
  banners?: string[];
8
7
  title: string;
9
8
  content: string;
@@ -1,4 +1,4 @@
1
- import type { CommonAction, CookiesSetDetails } from "@iflyrpa/share";
1
+ import type { CommonAction } from "@iflyrpa/share";
2
2
  import type { ActiomCommonParams, Xiaohongshu } from "../../types";
3
3
  interface FictionalRendition {
4
4
  type: "fictional-rendition";
@@ -14,8 +14,7 @@ interface SourceStatement {
14
14
  sourceMedia?: string;
15
15
  }
16
16
  type SelfDeclaration = FictionalRendition | AIGenerated | SourceStatement;
17
- export interface XiaohongshuPublishParams extends Omit<ActiomCommonParams, "cookies"> {
18
- cookies: Partial<CookiesSetDetails>[];
17
+ export interface XiaohongshuPublishParams extends ActiomCommonParams {
19
18
  banners: string[];
20
19
  title: string;
21
20
  content: string;
package/dist/bundle.js CHANGED
@@ -12986,7 +12986,7 @@ var __webpack_exports__ = {};
12986
12986
  return lastedHtml;
12987
12987
  };
12988
12988
  const stringifyError = (error)=>{
12989
- if (error instanceof Error) return error;
12989
+ if (error instanceof Error) return error.toString();
12990
12990
  if ("object" == typeof error) return JSON.stringify(error);
12991
12991
  return error;
12992
12992
  };
@@ -13000,7 +13000,7 @@ var __webpack_exports__ = {};
13000
13000
  const action = actions[index];
13001
13001
  try {
13002
13002
  const currentResult = await action(task, params);
13003
- if (0 === currentResult.code) return currentResult;
13003
+ if (0 === currentResult.code || 200 === currentResult.code) return currentResult;
13004
13004
  task.logger.error(currentResult.message, stringifyError(currentResult.data));
13005
13005
  result = currentResult;
13006
13006
  } catch (error) {
@@ -13419,16 +13419,15 @@ var __webpack_exports__ = {};
13419
13419
  return success(articleId);
13420
13420
  };
13421
13421
  const baijiahaoPublish = async (task, params)=>{
13422
- task.logger.info("开始百家号发布");
13423
13422
  if ("rpa" === params.actionType) return rpaAction(task, params);
13424
13423
  if ("mockApi" === params.actionType) return mockAction(task, params);
13425
13424
  return executeAction(mockAction, rpaAction)(task, params);
13426
13425
  };
13427
- const getBaijiahaoActivity = async (task, params)=>{
13428
- task.logger.info("查询百家号活动投稿");
13426
+ const getBaijiahaoActivity = async (_task, params)=>{
13427
+ const cookies = params.cookies ?? [];
13429
13428
  const http = new Http({
13430
13429
  headers: {
13431
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
13430
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
13432
13431
  token: params.token
13433
13432
  }
13434
13433
  });
@@ -13444,10 +13443,9 @@ var __webpack_exports__ = {};
13444
13443
  task_type: -1
13445
13444
  }
13446
13445
  });
13447
- return success(res.data.list);
13446
+ return success(res?.data?.list);
13448
13447
  };
13449
- const getToutiaoConfig = async (task, params)=>{
13450
- task.logger.info("获取头条发布配置的话题信息、位置信息和原创首发信息");
13448
+ const getToutiaoConfig = async (_task, params)=>{
13451
13449
  const cookies = params.cookies ?? [];
13452
13450
  const http = new Http({
13453
13451
  headers: {
@@ -13503,8 +13501,7 @@ var __webpack_exports__ = {};
13503
13501
  userRights
13504
13502
  });
13505
13503
  };
13506
- const searchToutiaoTopicList = async (task, params)=>{
13507
- task.logger.info("搜索头条话题");
13504
+ const searchToutiaoTopicList = async (_task, params)=>{
13508
13505
  const http = new Http({
13509
13506
  headers: {
13510
13507
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
@@ -13750,7 +13747,7 @@ var __webpack_exports__ = {};
13750
13747
  return {
13751
13748
  code: 400,
13752
13749
  message: `头条号登录状态失效,请重新绑定账号后${"draft" === params.saveType ? "同步" : "发布"}。`,
13753
- data: ""
13750
+ data: page.url()
13754
13751
  };
13755
13752
  }
13756
13753
  const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
@@ -14194,9 +14191,9 @@ var __webpack_exports__ = {};
14194
14191
  defaultErrorMsg: "创建草稿失败,请稍后重试发布。"
14195
14192
  });
14196
14193
  if (mass_send_left < 1) return {
14197
- code: 500,
14194
+ code: 200,
14198
14195
  message: "今日群发次数用尽,请明天再试。",
14199
- data: ""
14196
+ data: mass_send_left.toString()
14200
14197
  };
14201
14198
  await http.api({
14202
14199
  method: "post",
@@ -14367,7 +14364,7 @@ var __webpack_exports__ = {};
14367
14364
  break;
14368
14365
  }
14369
14366
  if (i === scanRetryMaxCount - 1) return {
14370
- code: 500,
14367
+ code: 200,
14371
14368
  message: "群发二维码已过期,请重试发布。",
14372
14369
  data: ""
14373
14370
  };
@@ -14414,7 +14411,6 @@ var __webpack_exports__ = {};
14414
14411
  }),
14415
14412
  defaultErrorMsg: "文章群发异常,请尝试关闭群发或稍后重试。"
14416
14413
  });
14417
- task.logger.info("微信公众号发布完成。");
14418
14414
  return success(appMsgId, "微信公众号发布完成。");
14419
14415
  };
14420
14416
  const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
@@ -15200,7 +15196,7 @@ var __webpack_exports__ = {};
15200
15196
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
15201
15197
  };
15202
15198
  var package_namespaceObject = {
15203
- i8: "1.1.26"
15199
+ i8: "1.1.28"
15204
15200
  };
15205
15201
  class Action {
15206
15202
  constructor(task){
@@ -15208,12 +15204,17 @@ var __webpack_exports__ = {};
15208
15204
  }
15209
15205
  async bindTask(func, params) {
15210
15206
  let responseData;
15207
+ this.task.logger.info(`${func.name} start`);
15208
+ if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
15211
15209
  try {
15212
15210
  responseData = await func(this.task, params);
15213
15211
  } catch (error) {
15214
15212
  responseData = Http.handleApiError(error);
15215
15213
  }
15216
- if (0 !== responseData.code) this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data));
15214
+ if (0 !== responseData.code) {
15215
+ this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data));
15216
+ this.task.logger.info("action failed");
15217
+ } else this.task.logger.info("action success");
15217
15218
  return responseData;
15218
15219
  }
15219
15220
  searchToutiaoTopicList(params) {