@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.
@@ -0,0 +1,7 @@
1
+ import { type CommonAction } from "@iflyrpa/share";
2
+ import type { ActiomCommonParams, Xiaohongshu } from "../../types";
3
+ export interface SearchXiaohongshuTopicListParams extends ActiomCommonParams {
4
+ searchValue: string;
5
+ }
6
+ export type PublishAction = CommonAction<SearchXiaohongshuTopicListParams, Xiaohongshu.Topic[]>;
7
+ export declare const searchXiaohongshuTopicList: PublishAction;
@@ -20,7 +20,7 @@ export interface XiaohongshuPublishParams extends ActiomCommonParams {
20
20
  content: string;
21
21
  address?: Xiaohongshu.Location;
22
22
  selfDeclaration?: SelfDeclaration;
23
- topic?: string[];
23
+ topic?: Xiaohongshu.Topic[];
24
24
  visibleRange: "public" | "private";
25
25
  isImmediatelyPublish?: boolean;
26
26
  scheduledPublish?: string;
package/dist/bundle.js CHANGED
@@ -13583,6 +13583,36 @@ var __webpack_exports__ = {};
13583
13583
  return success([]);
13584
13584
  }
13585
13585
  };
13586
+ const searchXiaohongshuTopicList = async (_task, params)=>{
13587
+ const http = new Http({
13588
+ headers: {
13589
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
13590
+ referer: "https://creator.xiaohongshu.com",
13591
+ origin: "https://creator.xiaohongshu.com"
13592
+ }
13593
+ });
13594
+ try {
13595
+ const result = await http.api({
13596
+ method: "post",
13597
+ url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
13598
+ data: {
13599
+ keyword: params.searchValue,
13600
+ suggest_topic_request: {
13601
+ title: "",
13602
+ desc: `#${params.searchValue}`
13603
+ },
13604
+ page: {
13605
+ page_size: 20,
13606
+ page: 1
13607
+ }
13608
+ },
13609
+ defaultErrorMsg: "话题搜索异常,请稍后重试。"
13610
+ });
13611
+ return success(0 === result.code ? result.data.topic_info_dtos : [], '获取话题成功');
13612
+ } catch (error) {
13613
+ return success([]);
13614
+ }
13615
+ };
13586
13616
  const mock_errnoMap = {
13587
13617
  20004020: "图片上传异常,请重新绑定账号后同步。",
13588
13618
  7115: "正文图片和封面图片推荐jpg、png格式。",
@@ -13791,6 +13821,10 @@ var __webpack_exports__ = {};
13791
13821
  });
13792
13822
  } else await route.continue();
13793
13823
  });
13824
+ PopupListener(page, '.byte-modal.publish-exclusive-modal .title', "激励", '.byte-modal-close-icon', {
13825
+ checkInterval: 1000,
13826
+ stopAfterClick: false
13827
+ });
13794
13828
  const titleInstance = page.locator(".publish-editor-title-wrapper .publish-editor-title textarea");
13795
13829
  await titleInstance.click();
13796
13830
  await titleInstance.fill(params.title);
@@ -15504,33 +15538,10 @@ var __webpack_exports__ = {};
15504
15538
  };
15505
15539
  };
15506
15540
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
15507
- const searchTopic = async (topic)=>await http.api({
15508
- method: "post",
15509
- url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
15510
- data: {
15511
- keyword: topic,
15512
- suggest_topic_request: {
15513
- title: "",
15514
- desc: `#${topic}`
15515
- },
15516
- page: {
15517
- page_size: 20,
15518
- page: 1
15519
- }
15520
- },
15521
- defaultErrorMsg: "话题搜索异常,请稍后重试。"
15522
- });
15523
- let topicDesc = [];
15524
- params.topic && params.topic.length > 0 && await Promise.all(params.topic.map(async (topic)=>{
15525
- let topicInfo = {
15526
- id: null,
15527
- name: null,
15528
- type: "topic"
15529
- };
15530
- const _topicInfo = await searchTopic(topic);
15531
- if (0 === _topicInfo.data.topic_info_dtos.length || _topicInfo.data.topic_info_dtos[0].name !== topic) {
15541
+ if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
15542
+ if (!topic["id"]) {
15532
15543
  const topicData = {
15533
- topic_names: topic
15544
+ topic_names: topic["name"]
15534
15545
  };
15535
15546
  const topicDataStr = xsEncrypt.dumps(topicData);
15536
15547
  const publishXt = Date.now().toString();
@@ -15545,21 +15556,16 @@ var __webpack_exports__ = {};
15545
15556
  data: topicData,
15546
15557
  defaultErrorMsg: "话题创建异常,请稍后重试。"
15547
15558
  });
15548
- Object.assign(topicInfo, createTopic.data.topic_infos[0]);
15549
- } else {
15550
- topicInfo.id = _topicInfo.data.topic_info_dtos[0].id;
15551
- topicInfo.name = _topicInfo.data.topic_info_dtos[0].name;
15552
- topicInfo.link = _topicInfo.data.topic_info_dtos[0].link;
15559
+ Object.assign(topic, createTopic.data.topic_infos[0]);
15553
15560
  }
15554
- topicDesc.push(topicInfo);
15555
15561
  }));
15556
15562
  const publishData = {
15557
15563
  common: {
15558
15564
  ats: [],
15559
15565
  biz_relations: [],
15560
- desc: params?.content + (params?.topic?.map((it)=>`#${it}[话题]#`).join("") || ""),
15566
+ desc: params?.content,
15561
15567
  goods_info: {},
15562
- hash_tag: topicDesc,
15568
+ hash_tag: params.topic || [],
15563
15569
  note_id: "",
15564
15570
  source: JSON.stringify({
15565
15571
  type: "web",
@@ -15699,11 +15705,11 @@ var __webpack_exports__ = {};
15699
15705
  });
15700
15706
  return;
15701
15707
  }
15702
- const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
15708
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
15703
15709
  const xs = await (isNoteRequest ? (async ()=>{
15704
15710
  const publishData = JSON.parse(request.postData() || "");
15705
15711
  const publishDataStr = rpa_xsEncrypt.dumps(publishData);
15706
- return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
15712
+ return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
15707
15713
  })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
15708
15714
  const newHeaders = {
15709
15715
  ...request.headers(),
@@ -15774,9 +15780,9 @@ var __webpack_exports__ = {};
15774
15780
  await titleInstance.fill(params.title);
15775
15781
  const descInstance = page.locator(".editor-container #quillEditor .ql-editor");
15776
15782
  await descInstance.click();
15777
- await descInstance.pressSequentially(params.content);
15783
+ await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]\#/g, ""));
15778
15784
  if (params.topic && params.topic.length > 0) for (const it of params.topic){
15779
- await descInstance.pressSequentially(`#${it}`);
15785
+ await descInstance.pressSequentially(`#${it["name"]}`);
15780
15786
  await page.locator('.ql-mention-loading').waitFor({
15781
15787
  state: 'detached'
15782
15788
  });
@@ -15791,8 +15797,8 @@ var __webpack_exports__ = {};
15791
15797
  }), params.address.name);
15792
15798
  if (params.selfDeclaration) {
15793
15799
  await page.locator(".media-settings .flexbox").filter({
15794
- hasText: "自主声明"
15795
- }).locator(".d-select-wrapper").click();
15800
+ hasText: "内容类型声明"
15801
+ }).locator(".d-select-placeholder").click();
15796
15802
  const poperInstance = await getPoperInstance();
15797
15803
  const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
15798
15804
  if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
@@ -15868,7 +15874,7 @@ var __webpack_exports__ = {};
15868
15874
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
15869
15875
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
15870
15876
  };
15871
- var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.0"}');
15877
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.6-beta.1"}');
15872
15878
  class Action {
15873
15879
  constructor(task){
15874
15880
  this.task = task;
@@ -15903,6 +15909,9 @@ var __webpack_exports__ = {};
15903
15909
  xiaohongshuPublish(params) {
15904
15910
  return this.bindTask(xiaohongshuPublish, params);
15905
15911
  }
15912
+ searchXiaohongshuTopicList(params) {
15913
+ return this.bindTask(searchXiaohongshuTopicList, params);
15914
+ }
15906
15915
  searchXiaohongshuLocation(params) {
15907
15916
  return this.bindTask(searchXiaohongshuLocation, params);
15908
15917
  }