@iflyrpa/actions 1.2.0 → 1.2.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/bundle.js CHANGED
@@ -12874,7 +12874,7 @@ var __webpack_exports__ = {};
12874
12874
  const lib_axios = axios;
12875
12875
  class Http {
12876
12876
  static handleApiError(error) {
12877
- if (error && 'object' == typeof error && 'code' in error && 'message' in error) return error;
12877
+ if (error && "object" == typeof error && "code" in error && "message" in error) return error;
12878
12878
  return {
12879
12879
  code: 500,
12880
12880
  message: "",
@@ -12887,15 +12887,25 @@ var __webpack_exports__ = {};
12887
12887
  addResponseInterceptor(findError) {
12888
12888
  this.apiClient.interceptors.response.use((response)=>{
12889
12889
  const error = findError(response);
12890
- return error ? Promise.reject(error) : response;
12890
+ if (error) return Promise.reject(Object.assign(error, {
12891
+ extra: {
12892
+ method: response.config.method,
12893
+ url: response.config.url
12894
+ }
12895
+ }));
12896
+ return response;
12891
12897
  }, (error)=>{
12892
12898
  const errorResponse = {
12893
12899
  code: error.response?.status || 500,
12894
12900
  message: error.message || "",
12895
- data: error.response?.data
12901
+ data: error.response?.data,
12902
+ extra: {
12903
+ method: error.config?.method,
12904
+ url: error.config?.url
12905
+ }
12896
12906
  };
12897
12907
  if (error.response?.data) {
12898
- if ('object' == typeof error.response.data) {
12908
+ if ("object" == typeof error.response.data) {
12899
12909
  const serverError = error.response.data;
12900
12910
  if (serverError.message) errorResponse.message = serverError.message;
12901
12911
  errorResponse.data = serverError;
@@ -13004,7 +13014,7 @@ var __webpack_exports__ = {};
13004
13014
  result = Http.handleApiError(error);
13005
13015
  }
13006
13016
  if (0 === result.code || 200 === result.code) break;
13007
- if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data));
13017
+ if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data), result.extra);
13008
13018
  }
13009
13019
  return result;
13010
13020
  };
@@ -13527,7 +13537,7 @@ var __webpack_exports__ = {};
13527
13537
  return success([]);
13528
13538
  }
13529
13539
  };
13530
- const searchXiaohongshuLocation = async (task, params)=>{
13540
+ const searchXiaohongshuLocation = async (_task, params)=>{
13531
13541
  const http = new Http({
13532
13542
  headers: {
13533
13543
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
@@ -13551,7 +13561,6 @@ var __webpack_exports__ = {};
13551
13561
  });
13552
13562
  return success(0 === result.code ? result.data.poi_list : []);
13553
13563
  } catch (error) {
13554
- task.logger.error("获取小红书地址失败");
13555
13564
  return success([]);
13556
13565
  }
13557
13566
  };
@@ -15106,6 +15115,7 @@ var __webpack_exports__ = {};
15106
15115
  });
15107
15116
  return success(publishResult.data.id);
15108
15117
  };
15118
+ const rpa_xsEncrypt = new XsEncrypt();
15109
15119
  const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
15110
15120
  const commonCookies = {
15111
15121
  path: "/",
@@ -15124,6 +15134,47 @@ var __webpack_exports__ = {};
15124
15134
  })) || []
15125
15135
  });
15126
15136
  const tmpCachePath = task.getTmpPath();
15137
+ const interceptUrls = [
15138
+ '/api/media/v1/upload/creator/permit',
15139
+ '/api/galaxy/v2/creator/activity_center/list',
15140
+ '/web_api/sns/v5/creator/topic/template/list',
15141
+ '/web_api/sns/v5/creator/file/encryption',
15142
+ '/web_api/sns/v2/note'
15143
+ ];
15144
+ await page.route('**', async (route, request)=>{
15145
+ const url = request.url();
15146
+ if (interceptUrls.some((pattern)=>url.includes(pattern))) {
15147
+ const urlObj = new URL(url);
15148
+ const fetchCoverUrl = urlObj.pathname + urlObj.search;
15149
+ const xt = Date.now().toString();
15150
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
15151
+ if (!a1Cookie) {
15152
+ await route.fulfill({
15153
+ status: 200,
15154
+ contentType: 'application/json',
15155
+ body: JSON.stringify({
15156
+ code: 200,
15157
+ message: "账号数据异常,请重新绑定账号后重试。",
15158
+ data: ""
15159
+ })
15160
+ });
15161
+ return;
15162
+ }
15163
+ const isNoteRequest = urlObj.pathname.includes(interceptUrls[4]);
15164
+ const xs = await (isNoteRequest ? (async ()=>{
15165
+ const publishData = JSON.parse(request.postData() || "");
15166
+ const publishDataStr = rpa_xsEncrypt.dumps(publishData);
15167
+ return rpa_xsEncrypt.encryptXs(interceptUrls[4] + publishDataStr, a1Cookie, xt);
15168
+ })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
15169
+ const newHeaders = {
15170
+ ...request.headers(),
15171
+ 'x-s': xs
15172
+ };
15173
+ await route.continue({
15174
+ headers: newHeaders
15175
+ });
15176
+ } else await route.continue();
15177
+ });
15127
15178
  const selectAddress = async (selector, address)=>{
15128
15179
  const instance = "string" == typeof selector ? page.locator(selector) : selector;
15129
15180
  await instance.click();
@@ -15271,7 +15322,7 @@ var __webpack_exports__ = {};
15271
15322
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
15272
15323
  };
15273
15324
  var package_namespaceObject = {
15274
- i8: "1.1.36"
15325
+ i8: "1.2.1"
15275
15326
  };
15276
15327
  class Action {
15277
15328
  constructor(task){
@@ -15287,7 +15338,7 @@ var __webpack_exports__ = {};
15287
15338
  }
15288
15339
  if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
15289
15340
  else if (0 !== responseData.code) {
15290
- this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data));
15341
+ this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
15291
15342
  this.task.logger.info(`${func.name} action failed`);
15292
15343
  } else this.task.logger.info(`${func.name} action success`);
15293
15344
  return responseData;