@iflyrpa/actions 1.2.6-beta.1 → 1.2.6-beta.2

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
@@ -648,6 +648,36 @@ const searchXiaohongshuLocation = async (_task, params)=>{
648
648
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
649
649
  }
650
650
  };
651
+ const searchXiaohongshuTopicList = async (_task, params)=>{
652
+ const http = new Http({
653
+ headers: {
654
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
655
+ referer: "https://creator.xiaohongshu.com",
656
+ origin: "https://creator.xiaohongshu.com"
657
+ }
658
+ });
659
+ try {
660
+ const result = await http.api({
661
+ method: "post",
662
+ url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
663
+ data: {
664
+ keyword: params.searchValue,
665
+ suggest_topic_request: {
666
+ title: "",
667
+ desc: `#${params.searchValue}`
668
+ },
669
+ page: {
670
+ page_size: 20,
671
+ page: 1
672
+ }
673
+ },
674
+ defaultErrorMsg: "话题搜索异常,请稍后重试。"
675
+ });
676
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
677
+ } catch (error) {
678
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
679
+ }
680
+ };
651
681
  const mock_errnoMap = {
652
682
  20004020: "图片上传异常,请重新绑定账号后同步。",
653
683
  7115: "正文图片和封面图片推荐jpg、png格式。",
@@ -856,6 +886,10 @@ const rpa_rpaAction = async (task, params)=>{
856
886
  });
857
887
  } else await route.continue();
858
888
  });
889
+ PopupListener(page, '.byte-modal.publish-exclusive-modal .title', "激励", '.byte-modal-close-icon', {
890
+ checkInterval: 1000,
891
+ stopAfterClick: false
892
+ });
859
893
  const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
860
894
  await titleInstance.click();
861
895
  await titleInstance.fill(params.title);
@@ -2566,33 +2600,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2566
2600
  };
2567
2601
  };
2568
2602
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
2569
- const searchTopic = async (topic)=>await http.api({
2570
- method: "post",
2571
- url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
2572
- data: {
2573
- keyword: topic,
2574
- suggest_topic_request: {
2575
- title: "",
2576
- desc: `#${topic}`
2577
- },
2578
- page: {
2579
- page_size: 20,
2580
- page: 1
2581
- }
2582
- },
2583
- defaultErrorMsg: "话题搜索异常,请稍后重试。"
2584
- });
2585
- let topicDesc = [];
2586
- params.topic && params.topic.length > 0 && await Promise.all(params.topic.map(async (topic)=>{
2587
- let topicInfo = {
2588
- id: null,
2589
- name: null,
2590
- type: "topic"
2591
- };
2592
- const _topicInfo = await searchTopic(topic);
2593
- if (0 === _topicInfo.data.topic_info_dtos.length || _topicInfo.data.topic_info_dtos[0].name !== topic) {
2603
+ if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
2604
+ if (!topic["id"]) {
2594
2605
  const topicData = {
2595
- topic_names: topic
2606
+ topic_names: topic["name"]
2596
2607
  };
2597
2608
  const topicDataStr = xsEncrypt.dumps(topicData);
2598
2609
  const publishXt = Date.now().toString();
@@ -2607,21 +2618,16 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
2607
2618
  data: topicData,
2608
2619
  defaultErrorMsg: "话题创建异常,请稍后重试。"
2609
2620
  });
2610
- Object.assign(topicInfo, createTopic.data.topic_infos[0]);
2611
- } else {
2612
- topicInfo.id = _topicInfo.data.topic_info_dtos[0].id;
2613
- topicInfo.name = _topicInfo.data.topic_info_dtos[0].name;
2614
- topicInfo.link = _topicInfo.data.topic_info_dtos[0].link;
2621
+ Object.assign(topic, createTopic.data.topic_infos[0]);
2615
2622
  }
2616
- topicDesc.push(topicInfo);
2617
2623
  }));
2618
2624
  const publishData = {
2619
2625
  common: {
2620
2626
  ats: [],
2621
2627
  biz_relations: [],
2622
- desc: params?.content + (params?.topic?.map((it)=>`#${it}[话题]#`).join("") || ""),
2628
+ desc: params?.content,
2623
2629
  goods_info: {},
2624
- hash_tag: topicDesc,
2630
+ hash_tag: params.topic || [],
2625
2631
  note_id: "",
2626
2632
  source: JSON.stringify({
2627
2633
  type: "web",
@@ -2761,11 +2767,11 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2761
2767
  });
2762
2768
  return;
2763
2769
  }
2764
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
2770
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
2765
2771
  const xs = await (isNoteRequest ? (async ()=>{
2766
2772
  const publishData = JSON.parse(request.postData() || "");
2767
2773
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
2768
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
2774
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
2769
2775
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
2770
2776
  const newHeaders = {
2771
2777
  ...request.headers(),
@@ -2836,9 +2842,9 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2836
2842
  await titleInstance.fill(params.title);
2837
2843
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
2838
2844
  await descInstance.click();
2839
- await descInstance.pressSequentially(params.content);
2845
+ await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]\#/g, ""));
2840
2846
  if (params.topic && params.topic.length > 0) for (const it of params.topic){
2841
- await descInstance.pressSequentially(`#${it}`);
2847
+ await descInstance.pressSequentially(`#${it["name"]}`);
2842
2848
  await page.locator('.ql-mention-loading').waitFor({
2843
2849
  state: 'detached'
2844
2850
  });
@@ -2853,8 +2859,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
2853
2859
  }), params.address.name);
2854
2860
  if (params.selfDeclaration) {
2855
2861
  await page.locator(".media-settings .flexbox").filter({
2856
- hasText: "自主声明"
2857
- }).locator(".d-select-wrapper").click();
2862
+ hasText: "内容类型声明"
2863
+ }).locator(".d-select-placeholder").click();
2858
2864
  const poperInstance = await getPoperInstance();
2859
2865
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
2860
2866
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -2930,7 +2936,7 @@ const xiaohongshuPublish = async (task, params)=>{
2930
2936
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
2931
2937
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
2932
2938
  };
2933
- var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.0"}');
2939
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.1"}');
2934
2940
  class Action {
2935
2941
  constructor(task){
2936
2942
  this.task = task;
@@ -2965,6 +2971,9 @@ class Action {
2965
2971
  xiaohongshuPublish(params) {
2966
2972
  return this.bindTask(xiaohongshuPublish, params);
2967
2973
  }
2974
+ searchXiaohongshuTopicList(params) {
2975
+ return this.bindTask(searchXiaohongshuTopicList, params);
2976
+ }
2968
2977
  searchXiaohongshuLocation(params) {
2969
2978
  return this.bindTask(searchXiaohongshuLocation, params);
2970
2979
  }