@clonegod/ttd-sol-common 2.0.30 → 2.0.31
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.
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
6
|
exports.getHttpClient = getHttpClient;
|
|
40
|
-
const axios_1 =
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
8
|
const https_1 = __importDefault(require("https"));
|
|
42
9
|
class HttpClientManager {
|
|
43
10
|
constructor() {
|
|
@@ -59,55 +26,6 @@ class HttpClientManager {
|
|
|
59
26
|
'Content-Type': 'application/json',
|
|
60
27
|
},
|
|
61
28
|
});
|
|
62
|
-
instance.interceptors.response.use((response) => response, (error) => {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
64
|
-
if (error.response) {
|
|
65
|
-
const simplifiedError = Object.create(axios_1.AxiosError.prototype);
|
|
66
|
-
simplifiedError.name = error.name;
|
|
67
|
-
simplifiedError.message = `Request failed: ${error.response.status} ${error.response.statusText} - ${(_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.method) === null || _b === void 0 ? void 0 : _b.toUpperCase()} ${(_c = error.config) === null || _c === void 0 ? void 0 : _c.url}`;
|
|
68
|
-
simplifiedError.code = error.code;
|
|
69
|
-
simplifiedError.isAxiosError = true;
|
|
70
|
-
simplifiedError.config = {
|
|
71
|
-
method: (_d = error.config) === null || _d === void 0 ? void 0 : _d.method,
|
|
72
|
-
url: (_e = error.config) === null || _e === void 0 ? void 0 : _e.url,
|
|
73
|
-
baseURL: (_f = error.config) === null || _f === void 0 ? void 0 : _f.baseURL,
|
|
74
|
-
};
|
|
75
|
-
simplifiedError.response = {
|
|
76
|
-
status: error.response.status,
|
|
77
|
-
statusText: error.response.statusText,
|
|
78
|
-
data: error.response.data,
|
|
79
|
-
};
|
|
80
|
-
simplifiedError.toJSON = function () {
|
|
81
|
-
return {
|
|
82
|
-
name: this.name,
|
|
83
|
-
message: this.message,
|
|
84
|
-
code: this.code,
|
|
85
|
-
config: this.config,
|
|
86
|
-
response: this.response,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
return Promise.reject(simplifiedError);
|
|
90
|
-
}
|
|
91
|
-
const simplifiedError = Object.create(axios_1.AxiosError.prototype);
|
|
92
|
-
simplifiedError.name = error.name;
|
|
93
|
-
simplifiedError.message = `Request error: ${error.message} - ${(_h = (_g = error.config) === null || _g === void 0 ? void 0 : _g.method) === null || _h === void 0 ? void 0 : _h.toUpperCase()} ${(_j = error.config) === null || _j === void 0 ? void 0 : _j.url}`;
|
|
94
|
-
simplifiedError.code = error.code;
|
|
95
|
-
simplifiedError.isAxiosError = true;
|
|
96
|
-
simplifiedError.config = {
|
|
97
|
-
method: (_k = error.config) === null || _k === void 0 ? void 0 : _k.method,
|
|
98
|
-
url: (_l = error.config) === null || _l === void 0 ? void 0 : _l.url,
|
|
99
|
-
baseURL: (_m = error.config) === null || _m === void 0 ? void 0 : _m.baseURL,
|
|
100
|
-
};
|
|
101
|
-
simplifiedError.toJSON = function () {
|
|
102
|
-
return {
|
|
103
|
-
name: this.name,
|
|
104
|
-
message: this.message,
|
|
105
|
-
code: this.code,
|
|
106
|
-
config: this.config,
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
return Promise.reject(simplifiedError);
|
|
110
|
-
});
|
|
111
29
|
return instance;
|
|
112
30
|
}
|
|
113
31
|
getInstance(url) {
|
package/package.json
CHANGED
|
@@ -32,71 +32,71 @@ class HttpClientManager {
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
// 添加响应拦截器,简化错误信息
|
|
35
|
-
instance.interceptors.response.use(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
// instance.interceptors.response.use(
|
|
36
|
+
// (response) => response,
|
|
37
|
+
// (error: AxiosError) => {
|
|
38
|
+
// // 简化错误对象,只保留关键信息,避免打印过多内容
|
|
39
|
+
// if (error.response) {
|
|
40
|
+
// // 创建简化的错误对象
|
|
41
|
+
// const simplifiedError = Object.create(AxiosError.prototype)
|
|
42
|
+
// simplifiedError.name = error.name
|
|
43
|
+
// simplifiedError.message = `Request failed: ${error.response.status} ${error.response.statusText} - ${error.config?.method?.toUpperCase()} ${error.config?.url}`
|
|
44
|
+
// simplifiedError.code = error.code
|
|
45
|
+
// simplifiedError.isAxiosError = true
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
// // 只保留必要的配置信息
|
|
48
|
+
// simplifiedError.config = {
|
|
49
|
+
// method: error.config?.method,
|
|
50
|
+
// url: error.config?.url,
|
|
51
|
+
// baseURL: error.config?.baseURL,
|
|
52
|
+
// }
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
// // 只保留必要的响应信息
|
|
55
|
+
// simplifiedError.response = {
|
|
56
|
+
// status: error.response.status,
|
|
57
|
+
// statusText: error.response.statusText,
|
|
58
|
+
// data: error.response.data,
|
|
59
|
+
// }
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
// // 自定义 toJSON 方法,控制序列化输出
|
|
62
|
+
// simplifiedError.toJSON = function() {
|
|
63
|
+
// return {
|
|
64
|
+
// name: this.name,
|
|
65
|
+
// message: this.message,
|
|
66
|
+
// code: this.code,
|
|
67
|
+
// config: this.config,
|
|
68
|
+
// response: this.response,
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// return Promise.reject(simplifiedError as AxiosError)
|
|
73
|
+
// }
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
// // 网络错误等其他错误,简化处理
|
|
76
|
+
// const simplifiedError = Object.create(AxiosError.prototype)
|
|
77
|
+
// simplifiedError.name = error.name
|
|
78
|
+
// simplifiedError.message = `Request error: ${error.message} - ${error.config?.method?.toUpperCase()} ${error.config?.url}`
|
|
79
|
+
// simplifiedError.code = error.code
|
|
80
|
+
// simplifiedError.isAxiosError = true
|
|
81
|
+
// simplifiedError.config = {
|
|
82
|
+
// method: error.config?.method,
|
|
83
|
+
// url: error.config?.url,
|
|
84
|
+
// baseURL: error.config?.baseURL,
|
|
85
|
+
// }
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
// // 自定义 toJSON 方法,控制序列化输出
|
|
88
|
+
// simplifiedError.toJSON = function() {
|
|
89
|
+
// return {
|
|
90
|
+
// name: this.name,
|
|
91
|
+
// message: this.message,
|
|
92
|
+
// code: this.code,
|
|
93
|
+
// config: this.config,
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
97
|
+
// return Promise.reject(simplifiedError as AxiosError)
|
|
98
|
+
// }
|
|
99
|
+
// )
|
|
100
100
|
|
|
101
101
|
return instance
|
|
102
102
|
}
|