@iflyrpa/actions 1.2.0 → 1.2.1
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 +18 -9
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -9
- package/dist/index.mjs.map +1 -1
- package/dist/utils/http.d.ts +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ const external_axios_namespaceObject = require("axios");
|
|
|
56
56
|
var external_axios_default = /*#__PURE__*/ __webpack_require__.n(external_axios_namespaceObject);
|
|
57
57
|
class Http {
|
|
58
58
|
static handleApiError(error) {
|
|
59
|
-
if (error &&
|
|
59
|
+
if (error && "object" == typeof error && "code" in error && "message" in error) return error;
|
|
60
60
|
return {
|
|
61
61
|
code: 500,
|
|
62
62
|
message: "",
|
|
@@ -69,15 +69,25 @@ class Http {
|
|
|
69
69
|
addResponseInterceptor(findError) {
|
|
70
70
|
this.apiClient.interceptors.response.use((response)=>{
|
|
71
71
|
const error = findError(response);
|
|
72
|
-
|
|
72
|
+
if (error) return Promise.reject(Object.assign(error, {
|
|
73
|
+
extra: {
|
|
74
|
+
method: response.config.method,
|
|
75
|
+
url: response.config.url
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
return response;
|
|
73
79
|
}, (error)=>{
|
|
74
80
|
const errorResponse = {
|
|
75
81
|
code: error.response?.status || 500,
|
|
76
82
|
message: error.message || "",
|
|
77
|
-
data: error.response?.data
|
|
83
|
+
data: error.response?.data,
|
|
84
|
+
extra: {
|
|
85
|
+
method: error.config?.method,
|
|
86
|
+
url: error.config?.url
|
|
87
|
+
}
|
|
78
88
|
};
|
|
79
89
|
if (error.response?.data) {
|
|
80
|
-
if (
|
|
90
|
+
if ("object" == typeof error.response.data) {
|
|
81
91
|
const serverError = error.response.data;
|
|
82
92
|
if (serverError.message) errorResponse.message = serverError.message;
|
|
83
93
|
errorResponse.data = serverError;
|
|
@@ -186,7 +196,7 @@ const executeAction = (...actions)=>async (task, params)=>{
|
|
|
186
196
|
result = Http.handleApiError(error);
|
|
187
197
|
}
|
|
188
198
|
if (0 === result.code || 200 === result.code) break;
|
|
189
|
-
if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data));
|
|
199
|
+
if (index !== actions.length - 1) task.logger.error(result.message, stringifyError(result.data), result.extra);
|
|
190
200
|
}
|
|
191
201
|
return result;
|
|
192
202
|
};
|
|
@@ -640,7 +650,7 @@ const searchToutiaoTopicList = async (_task, params)=>{
|
|
|
640
650
|
return (0, share_namespaceObject.success)([]);
|
|
641
651
|
}
|
|
642
652
|
};
|
|
643
|
-
const searchXiaohongshuLocation = async (
|
|
653
|
+
const searchXiaohongshuLocation = async (_task, params)=>{
|
|
644
654
|
const http = new Http({
|
|
645
655
|
headers: {
|
|
646
656
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
@@ -664,7 +674,6 @@ const searchXiaohongshuLocation = async (task, params)=>{
|
|
|
664
674
|
});
|
|
665
675
|
return (0, share_namespaceObject.success)(0 === result.code ? result.data.poi_list : []);
|
|
666
676
|
} catch (error) {
|
|
667
|
-
task.logger.error("获取小红书地址失败");
|
|
668
677
|
return (0, share_namespaceObject.success)([]);
|
|
669
678
|
}
|
|
670
679
|
};
|
|
@@ -2384,7 +2393,7 @@ const xiaohongshuPublish = async (task, params)=>{
|
|
|
2384
2393
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
2385
2394
|
};
|
|
2386
2395
|
var package_namespaceObject = {
|
|
2387
|
-
i8: "1.
|
|
2396
|
+
i8: "1.2.0"
|
|
2388
2397
|
};
|
|
2389
2398
|
class Action {
|
|
2390
2399
|
constructor(task){
|
|
@@ -2400,7 +2409,7 @@ class Action {
|
|
|
2400
2409
|
}
|
|
2401
2410
|
if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
|
|
2402
2411
|
else if (0 !== responseData.code) {
|
|
2403
|
-
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data));
|
|
2412
|
+
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
|
|
2404
2413
|
this.task.logger.info(`${func.name} action failed`);
|
|
2405
2414
|
} else this.task.logger.info(`${func.name} action success`);
|
|
2406
2415
|
return responseData;
|