@alipay/ams-checkout 0.0.1755258862-dev.0 → 0.0.1755258862-dev.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.
@@ -46,7 +46,7 @@ export var RequesterService = /*#__PURE__*/function () {
46
46
  key: "request",
47
47
  value: (function () {
48
48
  var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestData, options) {
49
- var envInfo, _data, startTime, traceId, myRequest, _yield$myRequest, data, headers, resData, handleGetWayError, errorMessage, errorCode, _error$message, _error, timeoutCode, _errorCode;
49
+ var envInfo, _data, startTime, traceId, myRequest, data, headers, response, resData, handleGetWayError, errorMessage, errorCode, _error$message, _error, timeoutCode, _errorCode;
50
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
@@ -64,16 +64,25 @@ export var RequesterService = /*#__PURE__*/function () {
64
64
  console.log('[DEBUG] createRequestInstance start');
65
65
  myRequest = this.createRequestInstance(options);
66
66
  console.log('[DEBUG] createRequestInstance completed', myRequest);
67
+ _context.prev = 9;
67
68
  console.log('[DEBUG] myRequest start');
68
- _context.next = 12;
69
+ _context.next = 13;
69
70
  return myRequest({
70
71
  data: _data
71
72
  });
72
- case 12:
73
- _yield$myRequest = _context.sent;
74
- data = _yield$myRequest.data;
75
- headers = _yield$myRequest.headers;
73
+ case 13:
74
+ response = _context.sent;
75
+ data = response.data;
76
+ headers = response.headers;
76
77
  console.log('[DEBUG] myRequest completed', data, headers);
78
+ _context.next = 23;
79
+ break;
80
+ case 19:
81
+ _context.prev = 19;
82
+ _context.t0 = _context["catch"](9);
83
+ console.error('[DEBUG] myRequest failed', _context.t0);
84
+ throw _context.t0;
85
+ case 23:
77
86
  resData = data || {};
78
87
  traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
79
88
  resData.traceId = traceId || '';
@@ -81,7 +90,7 @@ export var RequesterService = /*#__PURE__*/function () {
81
90
  handleGetWayError = fomatGetwayError(headers, traceId);
82
91
  console.log('[DEBUG] handleGetWayError completed', handleGetWayError);
83
92
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
84
- _context.next = 29;
93
+ _context.next = 36;
85
94
  break;
86
95
  }
87
96
  console.log('[DEBUG] handleGetWayError errorCode', handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode);
@@ -107,7 +116,7 @@ export var RequesterService = /*#__PURE__*/function () {
107
116
  errorCode: errorCode,
108
117
  success: false
109
118
  }));
110
- case 29:
119
+ case 36:
111
120
  this.reportRequestTimeCost({
112
121
  title: 'a3753.b101271.c388193.d521387',
113
122
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
@@ -120,17 +129,17 @@ export var RequesterService = /*#__PURE__*/function () {
120
129
  });
121
130
  console.log('[DEBUG] request completed', resData);
122
131
  return _context.abrupt("return", resData);
123
- case 34:
124
- _context.prev = 34;
125
- _context.t0 = _context["catch"](5);
126
- _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
132
+ case 41:
133
+ _context.prev = 41;
134
+ _context.t1 = _context["catch"](5);
135
+ _error = safeJson(_context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.message, {
127
136
  success: false,
128
137
  errorCode: errorEnum.SYSTEM,
129
138
  traceId: traceId,
130
- errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
139
+ errorMessage: _context.t1 === null || _context.t1 === void 0 ? void 0 : _context.t1.message
131
140
  });
132
- console.log('[DEBUG] request error 1', _error);
133
- timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
141
+ console.log('[DEBUG] request error 1', _error, 'Original error:', _context.t1);
142
+ timeoutCode = _context.t1 !== null && _context.t1 !== void 0 && (_error$message = _context.t1.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
134
143
  _errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
135
144
  this.reportRequestTimeCost({
136
145
  title: 'a3753.b101271.c388193.d521387',
@@ -139,7 +148,7 @@ export var RequesterService = /*#__PURE__*/function () {
139
148
  time: Date.now() - startTime,
140
149
  success: false,
141
150
  code: _errorCode,
142
- msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
151
+ msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t1)
143
152
  });
144
153
  console.log('[DEBUG] request error 2', {
145
154
  success: false,
@@ -153,11 +162,11 @@ export var RequesterService = /*#__PURE__*/function () {
153
162
  traceId: traceId,
154
163
  errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
155
164
  }));
156
- case 43:
165
+ case 50:
157
166
  case "end":
158
167
  return _context.stop();
159
168
  }
160
- }, _callee, this, [[5, 34]]);
169
+ }, _callee, this, [[5, 41], [9, 19]]);
161
170
  }));
162
171
  function request(_x, _x2) {
163
172
  return _request.apply(this, arguments);
@@ -207,23 +216,36 @@ export var RequesterService = /*#__PURE__*/function () {
207
216
  key: "createRequestInstance",
208
217
  value: function createRequestInstance(options) {
209
218
  var _options$timeout, _options$withCredenti;
219
+ console.log('[DEBUG] createRequestInstance start with options:', {
220
+ env: options.env,
221
+ 'Operation-Type': options['Operation-Type'],
222
+ hostSign: options === null || options === void 0 ? void 0 : options.hostSign,
223
+ timeout: options.timeout,
224
+ method: options === null || options === void 0 ? void 0 : options.method,
225
+ withCredentials: options.withCredentials,
226
+ headers: Object.keys(options.headers || {})
227
+ });
210
228
  var date = new Date(); // 获取当前时间
211
229
  var timestamp = date.getTime(); // 获取时间戳
212
230
  var utcTimestamp = timestamp + date.getTimezoneOffset() * 60 * 1000; // 获取 UTC 时间戳
213
231
  var env = options.env || 'prod';
214
232
  var lightSandboxConfig = lightSandboxMap(options['Operation-Type'], env); // light_sandbox
215
-
233
+ console.log('[DEBUG] lightSandboxConfig:', lightSandboxConfig);
216
234
  var baseURL = options.baseURL || lightSandboxConfig.baseURL || hostSignMap(options === null || options === void 0 ? void 0 : options.hostSign, env) || requestHost[env];
235
+ console.log('[DEBUG] baseURL:', baseURL);
217
236
  var _headers = _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
218
237
  appId: lightSandboxConfig.appId || appId,
219
238
  workspaceId: options.env === 'pre' ? 'pre' : 'default'
220
239
  }, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), "version", '2.0'), 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), 'Client-Time', utcTimestamp), "tntInstId", tntInstId), 'sdk-version', sdkVersion || ''), options.headers);
240
+
221
241
  // sandbox 影子链路
222
242
  if (this.sandboxFlag === 'true' || env === 'sandbox') {
223
243
  _headers['load-test'] = true;
224
244
  _headers.sofaPenAttrs = 'instMock=O&loadMode=2';
225
245
  }
226
246
  if (env !== 'dev') delete _headers['sofa-group-name'];
247
+ console.log('[DEBUG] request headers keys:', Object.keys(_headers));
248
+ console.log('[DEBUG] axios:', axios);
227
249
  var instance = axios.create({
228
250
  baseURL: baseURL,
229
251
  timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
@@ -231,7 +253,14 @@ export var RequesterService = /*#__PURE__*/function () {
231
253
  withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
232
254
  method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
233
255
  });
256
+ console.log('[DEBUG] axios instance created with config:', {
257
+ baseURL: instance.defaults.baseURL,
258
+ timeout: instance.defaults.timeout,
259
+ method: instance.defaults.method,
260
+ withCredentials: instance.defaults.withCredentials
261
+ });
234
262
  return instance.request;
263
+ // return instance.request.bind(instance);
235
264
  }
236
265
  }]);
237
266
  return RequesterService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1755258862-dev.0",
3
+ "version": "0.0.1755258862-dev.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",