@iflyrpa/actions 1.2.6 → 1.2.8

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
@@ -4,6 +4,7 @@ import { type GetBaijiahaoActivityParams } from "./actions/getBaijiahaoActivity"
4
4
  import { type GetToutiaoConfigParams } from "./actions/getToutiaoConfig";
5
5
  import { type SearchToutiaoTopicListParams } from "./actions/searchToutiaoTopicList";
6
6
  import { type searchXiaohongshuLocationParams } from "./actions/searchXiaohongshuLocation";
7
+ import { SearchXiaohongshuTopicListParams } from "./actions/searchXiaohongshuTopicList";
7
8
  import { type ToutiaoPublishParams } from "./actions/toutiaoPublish";
8
9
  import { type WeitoutiaoPublishParams } from "./actions/weitoutiaoPublish";
9
10
  import { type WeixinPublishParams } from "./actions/weixinPublish";
@@ -18,6 +19,7 @@ export declare class Action {
18
19
  baijiahaoPublish(params: BaijiahaoPublishParams): Promise<ResponseData<string>>;
19
20
  getBaijiahaoActivity(params: GetBaijiahaoActivityParams): Promise<ResponseData<import("./actions/getBaijiahaoActivity").ActivityData[]>>;
20
21
  xiaohongshuPublish(params: XiaohongshuPublishParams): Promise<ResponseData<string>>;
22
+ searchXiaohongshuTopicList(params: SearchXiaohongshuTopicListParams): Promise<ResponseData<import("./types").Xiaohongshu.Topic[]>>;
21
23
  searchXiaohongshuLocation(params: searchXiaohongshuLocationParams): Promise<ResponseData<import("./types").Xiaohongshu.Location[]>>;
22
24
  weixinmpPublish(params: WeixinmpPublishParams): Promise<ResponseData<any>>;
23
25
  weitoutiaoPublish(params: WeitoutiaoPublishParams): Promise<ResponseData<any>>;
package/dist/index.js CHANGED
@@ -696,6 +696,36 @@ const searchXiaohongshuLocation = async (_task, params)=>{
696
696
  return (0, share_namespaceObject.success)([]);
697
697
  }
698
698
  };
699
+ const searchXiaohongshuTopicList = async (_task, params)=>{
700
+ const http = new Http({
701
+ headers: {
702
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
703
+ referer: "https://creator.xiaohongshu.com",
704
+ origin: "https://creator.xiaohongshu.com"
705
+ }
706
+ });
707
+ try {
708
+ const result = await http.api({
709
+ method: "post",
710
+ url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
711
+ data: {
712
+ keyword: params.searchValue,
713
+ suggest_topic_request: {
714
+ title: "",
715
+ desc: `#${params.searchValue}`
716
+ },
717
+ page: {
718
+ page_size: 20,
719
+ page: 1
720
+ }
721
+ },
722
+ defaultErrorMsg: "话题搜索异常,请稍后重试。"
723
+ });
724
+ return (0, share_namespaceObject.success)(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
725
+ } catch (error) {
726
+ return (0, share_namespaceObject.success)([]);
727
+ }
728
+ };
699
729
  const mock_errnoMap = {
700
730
  20004020: "图片上传异常,请重新绑定账号后同步。",
701
731
  7115: "正文图片和封面图片推荐jpg、png格式。",
@@ -706,8 +736,11 @@ const mock_errnoMap = {
706
736
  "头条账号状态异常,资料审核未通过,请前往头条号查看。"
707
737
  ],
708
738
  2007: "文章发布失败,声明原创要求正文字数不少于 300 字,请修改后重试。",
739
+ 2010: "无头条广告权限,请修改后重试。",
740
+ 3103: "今日头条号发布次数已达上限,请明天再试。",
709
741
  1053: "正文图片和封面图片推荐jpg、png格式。",
710
- 2005: "账号无【申明原创】权限,请关闭申明后重试。"
742
+ 2005: "账号无【申明原创】权限,请关闭申明后重试。",
743
+ 100004: "用户未登录或登陆已过期,请重新登陆后重试。"
711
744
  };
712
745
  const get3101DetailError = (errorList, message, saveType)=>{
713
746
  let error = "";
@@ -2546,7 +2579,9 @@ class XsEncrypt {
2546
2579
  }
2547
2580
  }
2548
2581
  const xiaohongshuPublish_mock_errnoMap = {
2549
- 903: "账户已登出,需重新登陆重试!"
2582
+ 915: "所属C端账号手机号被修改,请重新登录",
2583
+ 903: "账户已登出,需重新登陆重试!",
2584
+ 902: "登录已过期,请重新登录!"
2550
2585
  };
2551
2586
  const xsEncrypt = new XsEncrypt();
2552
2587
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
@@ -2616,13 +2651,34 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2616
2651
  };
2617
2652
  };
2618
2653
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
2654
+ if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
2655
+ if (!topic["id"]) {
2656
+ const topicData = {
2657
+ topic_names: topic["name"]
2658
+ };
2659
+ const topicDataStr = xsEncrypt.dumps(topicData);
2660
+ const publishXt = Date.now().toString();
2661
+ const publishXs = await xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
2662
+ let createTopic = await http.api({
2663
+ method: "POST",
2664
+ url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
2665
+ headers: {
2666
+ "x-s": publishXs,
2667
+ "x-t": publishXt
2668
+ },
2669
+ data: topicData,
2670
+ defaultErrorMsg: "话题创建异常,请稍后重试。"
2671
+ });
2672
+ Object.assign(topic, createTopic.data.topic_infos[0]);
2673
+ }
2674
+ }));
2619
2675
  const publishData = {
2620
2676
  common: {
2621
2677
  ats: [],
2622
2678
  biz_relations: [],
2623
2679
  desc: params?.content,
2624
2680
  goods_info: {},
2625
- hash_tag: [],
2681
+ hash_tag: params.topic || [],
2626
2682
  note_id: "",
2627
2683
  source: JSON.stringify({
2628
2684
  type: "web",
@@ -2740,6 +2796,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2740
2796
  '/api/galaxy/v2/creator/activity_center/list',
2741
2797
  '/web_api/sns/v5/creator/topic/template/list',
2742
2798
  '/web_api/sns/v5/creator/file/encryption',
2799
+ '/web_api/sns/capa/postgw/topic/batch_customized',
2743
2800
  '/web_api/sns/v2/note'
2744
2801
  ];
2745
2802
  await page.route('**', async (route, request)=>{
@@ -2761,11 +2818,11 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2761
2818
  });
2762
2819
  return;
2763
2820
  }
2764
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
2821
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
2765
2822
  const xs = await (isNoteRequest ? (async ()=>{
2766
2823
  const publishData = JSON.parse(request.postData() || "");
2767
2824
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
2768
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
2825
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
2769
2826
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
2770
2827
  const newHeaders = {
2771
2828
  ...request.headers(),
@@ -2819,7 +2876,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2819
2876
  data: page.url()
2820
2877
  };
2821
2878
  }
2822
- await page.locator("#content-area .menu-container .publish-video a").click();
2879
+ await page.locator("#content-area .menu-container .publish-video .btn").click();
2823
2880
  await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
2824
2881
  hasText: /^上传图文$/
2825
2882
  }).click();
@@ -2836,7 +2893,15 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2836
2893
  await titleInstance.fill(params.title);
2837
2894
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
2838
2895
  await descInstance.click();
2839
- await descInstance.fill(params.content);
2896
+ await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]\#/g, ""));
2897
+ if (params.topic && params.topic.length > 0) for (const it of params.topic){
2898
+ await descInstance.pressSequentially(`#${it["name"]}`);
2899
+ await page.locator('.ql-mention-loading').waitFor({
2900
+ state: 'detached'
2901
+ });
2902
+ await page.waitForTimeout(1000);
2903
+ await page.locator('#quill-mention-item-0 .item-view-num').click();
2904
+ }
2840
2905
  const container = page.locator(".creator-container .content .scroll-content");
2841
2906
  await container.focus();
2842
2907
  await page.mouse.wheel(0, 500);
@@ -2845,8 +2910,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2845
2910
  }), params.address.name);
2846
2911
  if (params.selfDeclaration) {
2847
2912
  await page.locator(".media-settings .flexbox").filter({
2848
- hasText: "自主声明"
2849
- }).locator(".d-select-wrapper").click();
2913
+ hasText: "内容类型声明"
2914
+ }).locator(".d-select-placeholder").click();
2850
2915
  const poperInstance = await getPoperInstance();
2851
2916
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
2852
2917
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -2923,7 +2988,7 @@ const xiaohongshuPublish = async (task, params)=>{
2923
2988
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2924
2989
  };
2925
2990
  var package_namespaceObject = {
2926
- i8: "1.2.5"
2991
+ i8: "1.2.7"
2927
2992
  };
2928
2993
  class Action {
2929
2994
  constructor(task){
@@ -2960,6 +3025,9 @@ class Action {
2960
3025
  xiaohongshuPublish(params) {
2961
3026
  return this.bindTask(xiaohongshuPublish, params);
2962
3027
  }
3028
+ searchXiaohongshuTopicList(params) {
3029
+ return this.bindTask(searchXiaohongshuTopicList, params);
3030
+ }
2963
3031
  searchXiaohongshuLocation(params) {
2964
3032
  return this.bindTask(searchXiaohongshuLocation, params);
2965
3033
  }