@iflyrpa/actions 1.2.7 → 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格式。",
@@ -2549,7 +2579,9 @@ class XsEncrypt {
2549
2579
  }
2550
2580
  }
2551
2581
  const xiaohongshuPublish_mock_errnoMap = {
2552
- 903: "账户已登出,需重新登陆重试!"
2582
+ 915: "所属C端账号手机号被修改,请重新登录",
2583
+ 903: "账户已登出,需重新登陆重试!",
2584
+ 902: "登录已过期,请重新登录!"
2553
2585
  };
2554
2586
  const xsEncrypt = new XsEncrypt();
2555
2587
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
@@ -2619,13 +2651,34 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2619
2651
  };
2620
2652
  };
2621
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
+ }));
2622
2675
  const publishData = {
2623
2676
  common: {
2624
2677
  ats: [],
2625
2678
  biz_relations: [],
2626
2679
  desc: params?.content,
2627
2680
  goods_info: {},
2628
- hash_tag: [],
2681
+ hash_tag: params.topic || [],
2629
2682
  note_id: "",
2630
2683
  source: JSON.stringify({
2631
2684
  type: "web",
@@ -2743,6 +2796,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2743
2796
  '/api/galaxy/v2/creator/activity_center/list',
2744
2797
  '/web_api/sns/v5/creator/topic/template/list',
2745
2798
  '/web_api/sns/v5/creator/file/encryption',
2799
+ '/web_api/sns/capa/postgw/topic/batch_customized',
2746
2800
  '/web_api/sns/v2/note'
2747
2801
  ];
2748
2802
  await page.route('**', async (route, request)=>{
@@ -2764,11 +2818,11 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2764
2818
  });
2765
2819
  return;
2766
2820
  }
2767
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
2821
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
2768
2822
  const xs = await (isNoteRequest ? (async ()=>{
2769
2823
  const publishData = JSON.parse(request.postData() || "");
2770
2824
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
2771
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
2825
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
2772
2826
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
2773
2827
  const newHeaders = {
2774
2828
  ...request.headers(),
@@ -2822,7 +2876,7 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2822
2876
  data: page.url()
2823
2877
  };
2824
2878
  }
2825
- await page.locator("#content-area .menu-container .publish-video a").click();
2879
+ await page.locator("#content-area .menu-container .publish-video .btn").click();
2826
2880
  await page.locator('.creator-container .header .creator-tab:not([style*="-9999px"]) .title').filter({
2827
2881
  hasText: /^上传图文$/
2828
2882
  }).click();
@@ -2839,7 +2893,15 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2839
2893
  await titleInstance.fill(params.title);
2840
2894
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
2841
2895
  await descInstance.click();
2842
- 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
+ }
2843
2905
  const container = page.locator(".creator-container .content .scroll-content");
2844
2906
  await container.focus();
2845
2907
  await page.mouse.wheel(0, 500);
@@ -2848,8 +2910,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2848
2910
  }), params.address.name);
2849
2911
  if (params.selfDeclaration) {
2850
2912
  await page.locator(".media-settings .flexbox").filter({
2851
- hasText: "自主声明"
2852
- }).locator(".d-select-wrapper").click();
2913
+ hasText: "内容类型声明"
2914
+ }).locator(".d-select-placeholder").click();
2853
2915
  const poperInstance = await getPoperInstance();
2854
2916
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
2855
2917
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -2926,7 +2988,7 @@ const xiaohongshuPublish = async (task, params)=>{
2926
2988
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2927
2989
  };
2928
2990
  var package_namespaceObject = {
2929
- i8: "1.2.6"
2991
+ i8: "1.2.7"
2930
2992
  };
2931
2993
  class Action {
2932
2994
  constructor(task){
@@ -2963,6 +3025,9 @@ class Action {
2963
3025
  xiaohongshuPublish(params) {
2964
3026
  return this.bindTask(xiaohongshuPublish, params);
2965
3027
  }
3028
+ searchXiaohongshuTopicList(params) {
3029
+ return this.bindTask(searchXiaohongshuTopicList, params);
3030
+ }
2966
3031
  searchXiaohongshuLocation(params) {
2967
3032
  return this.bindTask(searchXiaohongshuLocation, params);
2968
3033
  }