@iflyrpa/actions 1.1.14 → 1.1.15

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.js CHANGED
@@ -10268,81 +10268,6 @@ var __webpack_exports__ = {};
10268
10268
  DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY";
10269
10269
  })(helpers_DocumentPosition || (helpers_DocumentPosition = {}));
10270
10270
  var mime_types = __webpack_require__("../../node_modules/.pnpm/mime-types@2.1.35/node_modules/mime-types/index.js");
10271
- const getFileState = (filePath)=>{
10272
- const filename = external_node_path_default().basename(filePath);
10273
- const fileType = mime_types.lookup(filePath);
10274
- const stats = external_node_fs_default().statSync(filePath);
10275
- const fileSize = stats.size;
10276
- const lastModifiedDate = stats.mtime;
10277
- return {
10278
- name: filename,
10279
- type: fileType,
10280
- size: fileSize,
10281
- lastModifiedDate: lastModifiedDate.toString()
10282
- };
10283
- };
10284
- const calculateCropCoordinates = (width, height, aspectRatio)=>{
10285
- const targetRatio = aspectRatio[0] / aspectRatio[1];
10286
- let cropWidth;
10287
- let cropHeight;
10288
- if (width / height > targetRatio) {
10289
- cropHeight = height;
10290
- cropWidth = height * targetRatio;
10291
- } else {
10292
- cropWidth = width;
10293
- cropHeight = width / targetRatio;
10294
- }
10295
- const x1 = (width - cropWidth) / 2;
10296
- const y1 = (height - cropHeight) / 2;
10297
- const x2 = x1 + cropWidth;
10298
- const y2 = y1 + cropHeight;
10299
- return {
10300
- x1: x1 / width,
10301
- y1: y1 / height,
10302
- x2: x2 / width,
10303
- y2: y2 / height
10304
- };
10305
- };
10306
- const extractImgTag = (html)=>{
10307
- const srcList = [];
10308
- const parser = new Parser_Parser({
10309
- onopentag (name, attributes) {
10310
- if ("img" === name && (attributes.src.trim() || attributes.currentSrc.trim())) srcList.push(attributes.src.trim() || attributes.currentSrc.trim());
10311
- }
10312
- });
10313
- parser.write(html);
10314
- parser.end();
10315
- return srcList;
10316
- };
10317
- const replaceImgSrc = (html, callback)=>{
10318
- let lastedHtml = html;
10319
- const isImageTag = (node)=>"tag" === node.type && "img" === node.name;
10320
- const traverseDom = (node)=>{
10321
- if (hasChildren(node)) for (const child of node.children){
10322
- if (isImageTag(child)) callback(child);
10323
- traverseDom(child);
10324
- }
10325
- };
10326
- const handler = new esm_DomHandler((error, dom)=>{
10327
- if (error) console.log(error);
10328
- else dom.forEach(traverseDom);
10329
- lastedHtml = esm(dom);
10330
- });
10331
- const parser = new Parser_Parser(handler);
10332
- parser.write(html);
10333
- parser.end();
10334
- return lastedHtml;
10335
- };
10336
- const executeAction = (...actions)=>async (...p)=>{
10337
- let lastError = null;
10338
- for (const action of actions)try {
10339
- const result = await action(...p);
10340
- return result;
10341
- } catch (error) {
10342
- lastError = error instanceof Error ? error : new Error(String(error));
10343
- }
10344
- throw lastError || new Error("All actions failed");
10345
- };
10346
10271
  function bind(fn, thisArg) {
10347
10272
  return function() {
10348
10273
  return fn.apply(thisArg, arguments);
@@ -11008,7 +10933,7 @@ var __webpack_exports__ = {};
11008
10933
  }
11009
10934
  return (encoder || JSON.stringify)(rawValue);
11010
10935
  }
11011
- const defaults = {
10936
+ const defaults_defaults = {
11012
10937
  transitional: defaults_transitional,
11013
10938
  adapter: [
11014
10939
  'xhr',
@@ -11048,7 +10973,7 @@ var __webpack_exports__ = {};
11048
10973
  ],
11049
10974
  transformResponse: [
11050
10975
  function(data) {
11051
- const transitional = this.transitional || defaults.transitional;
10976
+ const transitional = this.transitional || defaults_defaults.transitional;
11052
10977
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
11053
10978
  const JSONRequested = 'json' === this.responseType;
11054
10979
  if (utils.isResponse(data) || utils.isReadableStream(data)) return data;
@@ -11094,9 +11019,9 @@ var __webpack_exports__ = {};
11094
11019
  'put',
11095
11020
  'patch'
11096
11021
  ], (method)=>{
11097
- defaults.headers[method] = {};
11022
+ defaults_defaults.headers[method] = {};
11098
11023
  });
11099
- const lib_defaults = defaults;
11024
+ const defaults = defaults_defaults;
11100
11025
  const ignoreDuplicateOf = utils.toObjectSet([
11101
11026
  'age',
11102
11027
  'authorization',
@@ -11328,7 +11253,7 @@ var __webpack_exports__ = {};
11328
11253
  utils.freezeMethods(AxiosHeaders_AxiosHeaders);
11329
11254
  const AxiosHeaders = AxiosHeaders_AxiosHeaders;
11330
11255
  function transformData(fns, response) {
11331
- const config = this || lib_defaults;
11256
+ const config = this || defaults;
11332
11257
  const context = response || config;
11333
11258
  const headers = AxiosHeaders.from(context.headers);
11334
11259
  let data = context.data;
@@ -12606,7 +12531,7 @@ var __webpack_exports__ = {};
12606
12531
  'put',
12607
12532
  'patch'
12608
12533
  ].indexOf(config.method)) config.headers.setContentType('application/x-www-form-urlencoded', false);
12609
- const adapter = adapters_adapters.getAdapter(config.adapter || lib_defaults.adapter);
12534
+ const adapter = adapters_adapters.getAdapter(config.adapter || defaults.adapter);
12610
12535
  return adapter(config).then(function(response) {
12611
12536
  throwIfCancellationRequested(config);
12612
12537
  response.data = transformData.call(config, config.transformResponse, response);
@@ -12992,7 +12917,7 @@ var __webpack_exports__ = {};
12992
12917
  };
12993
12918
  return instance;
12994
12919
  }
12995
- const axios = createInstance(lib_defaults);
12920
+ const axios = createInstance(defaults);
12996
12921
  axios.Axios = core_Axios;
12997
12922
  axios.CanceledError = cancel_CanceledError;
12998
12923
  axios.CancelToken = cancel_CancelToken;
@@ -13055,6 +12980,87 @@ var __webpack_exports__ = {};
13055
12980
  this.apiClient = lib_axios.create(config);
13056
12981
  }
13057
12982
  }
12983
+ const getFileState = (filePath)=>{
12984
+ const filename = external_node_path_default().basename(filePath);
12985
+ const fileType = mime_types.lookup(filePath);
12986
+ const stats = external_node_fs_default().statSync(filePath);
12987
+ const fileSize = stats.size;
12988
+ const lastModifiedDate = stats.mtime;
12989
+ return {
12990
+ name: filename,
12991
+ type: fileType,
12992
+ size: fileSize,
12993
+ lastModifiedDate: lastModifiedDate.toString()
12994
+ };
12995
+ };
12996
+ const calculateCropCoordinates = (width, height, aspectRatio)=>{
12997
+ const targetRatio = aspectRatio[0] / aspectRatio[1];
12998
+ let cropWidth;
12999
+ let cropHeight;
13000
+ if (width / height > targetRatio) {
13001
+ cropHeight = height;
13002
+ cropWidth = height * targetRatio;
13003
+ } else {
13004
+ cropWidth = width;
13005
+ cropHeight = width / targetRatio;
13006
+ }
13007
+ const x1 = (width - cropWidth) / 2;
13008
+ const y1 = (height - cropHeight) / 2;
13009
+ const x2 = x1 + cropWidth;
13010
+ const y2 = y1 + cropHeight;
13011
+ return {
13012
+ x1: x1 / width,
13013
+ y1: y1 / height,
13014
+ x2: x2 / width,
13015
+ y2: y2 / height
13016
+ };
13017
+ };
13018
+ const extractImgTag = (html)=>{
13019
+ const srcList = [];
13020
+ const parser = new Parser_Parser({
13021
+ onopentag (name, attributes) {
13022
+ if ("img" === name && (attributes.src.trim() || attributes.currentSrc.trim())) srcList.push(attributes.src.trim() || attributes.currentSrc.trim());
13023
+ }
13024
+ });
13025
+ parser.write(html);
13026
+ parser.end();
13027
+ return srcList;
13028
+ };
13029
+ const replaceImgSrc = (html, callback)=>{
13030
+ let lastedHtml = html;
13031
+ const isImageTag = (node)=>"tag" === node.type && "img" === node.name;
13032
+ const traverseDom = (node)=>{
13033
+ if (hasChildren(node)) for (const child of node.children){
13034
+ if (isImageTag(child)) callback(child);
13035
+ traverseDom(child);
13036
+ }
13037
+ };
13038
+ const handler = new esm_DomHandler((error, dom)=>{
13039
+ if (error) console.log(error);
13040
+ else dom.forEach(traverseDom);
13041
+ lastedHtml = esm(dom);
13042
+ });
13043
+ const parser = new Parser_Parser(handler);
13044
+ parser.write(html);
13045
+ parser.end();
13046
+ return lastedHtml;
13047
+ };
13048
+ const executeAction = (...actions)=>async (task, params)=>{
13049
+ let result = {
13050
+ code: 500,
13051
+ message: "所有操作均失败",
13052
+ data: null
13053
+ };
13054
+ for (const action of actions)try {
13055
+ const currentResult = await action(task, params);
13056
+ if (0 === currentResult.code) return currentResult;
13057
+ task.logger.error(currentResult.message, currentResult.data);
13058
+ result = currentResult;
13059
+ } catch (error) {
13060
+ result = Http.handleApiError(error);
13061
+ }
13062
+ return result;
13063
+ };
13058
13064
  const errnoMap = {
13059
13065
  20040706: "正文图片和封面图片推荐jpg、png格式。",
13060
13066
  20040084: "正文图片和封面图片推荐jpg、png格式。",
@@ -14582,7 +14588,7 @@ var __webpack_exports__ = {};
14582
14588
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
14583
14589
  };
14584
14590
  var package_namespaceObject = {
14585
- i8: "1.1.14"
14591
+ i8: "1.1.15"
14586
14592
  };
14587
14593
  class Action {
14588
14594
  async bindTask(func, params) {
@@ -14591,8 +14597,8 @@ var __webpack_exports__ = {};
14591
14597
  responseData = await func(this.task, params);
14592
14598
  } catch (error) {
14593
14599
  responseData = Http.handleApiError(error);
14594
- this.task.logger.error(responseData.message || `${func.name} 执行失败`, responseData.data);
14595
14600
  }
14601
+ if (0 !== responseData.code) this.task.logger.error(responseData.message || `${func.name} 执行失败`, responseData.data);
14596
14602
  return responseData;
14597
14603
  }
14598
14604
  searchToutiaoTopicList(params) {