@alipay/ams-checkout 0.0.1755258862-dev.3 → 0.0.1755258862-dev.4
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.
@@ -53,6 +53,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
53
53
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
54
54
|
while (1) switch (_context.prev = _context.next) {
|
55
55
|
case 0:
|
56
|
+
console.log('[DEBUG] - startBizFlow - START', {
|
57
|
+
paymentContext: paymentContext
|
58
|
+
});
|
59
|
+
this.logger.logInfo({
|
60
|
+
title: '[DEBUG] - startBizFlow - START',
|
61
|
+
msg: JSON.stringify(paymentContext)
|
62
|
+
});
|
63
|
+
|
56
64
|
// 放在最前面的逻辑
|
57
65
|
// 在PC场景下,几乎所有渠道都是没有拉端的逻辑的,所以需要改成1.0, 这个是历史原因
|
58
66
|
if (isPC()) {
|
@@ -69,16 +77,46 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
69
77
|
requireFastSdk = paymentContext.paymentSessionObj.action.requireFastSdk;
|
70
78
|
authUrlInfo = ((_paymentContext$payme2 = paymentContext.paymentSessionObj) === null || _paymentContext$payme2 === void 0 ? void 0 : _paymentContext$payme2.authUrlInfo) || {};
|
71
79
|
this.channelBehavior = ChannelCustomize.getChannelBehavior(paymentContext.paymentSessionObj);
|
80
|
+
console.log('[DEBUG] - startBizFlow - variables initialized', {
|
81
|
+
productSceneVersion: productSceneVersion,
|
82
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
83
|
+
autoDebitWithToken: autoDebitWithToken,
|
84
|
+
requireFastSdk: requireFastSdk,
|
85
|
+
hostSign: this.hostSign
|
86
|
+
});
|
87
|
+
this.logger.logInfo({
|
88
|
+
title: '[DEBUG] - startBizFlow - variables initialized',
|
89
|
+
msg: JSON.stringify({
|
90
|
+
productSceneVersion: productSceneVersion,
|
91
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
92
|
+
autoDebitWithToken: autoDebitWithToken,
|
93
|
+
requireFastSdk: requireFastSdk,
|
94
|
+
hostSign: this.hostSign
|
95
|
+
})
|
96
|
+
});
|
72
97
|
// 首次支付
|
73
98
|
isFirstTimeToPay = !autoDebitWithToken; // 处理ESP1.0极速外跳支付场景
|
74
99
|
if (!(productSceneVersion === '1.0' && isFirstTimeToPay && requireFastSdk)) {
|
75
|
-
_context.next =
|
100
|
+
_context.next = 18;
|
76
101
|
break;
|
77
102
|
}
|
103
|
+
console.log('[DEBUG] - startBizFlow - ESP1.0 fast redirect scenario');
|
104
|
+
this.logger.logInfo({
|
105
|
+
title: '[DEBUG] - startBizFlow - ESP1.0 fast redirect scenario'
|
106
|
+
});
|
107
|
+
// EASY_PAY 1.0首次支付,requireFastSdk为true,不需要接口请求
|
78
108
|
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
79
|
-
case
|
109
|
+
case 18:
|
80
110
|
// 下面的场景是需要渲染UI的渠道, 打开WebUrl
|
81
|
-
webAppUrl = this.buildWebAppUrl();
|
111
|
+
webAppUrl = this.buildWebAppUrl();
|
112
|
+
console.log('[DEBUG] - startBizFlow - webAppUrl built', {
|
113
|
+
webAppUrl: webAppUrl
|
114
|
+
});
|
115
|
+
this.logger.logInfo({
|
116
|
+
title: '[DEBUG] - startBizFlow - webAppUrl built',
|
117
|
+
msg: webAppUrl
|
118
|
+
});
|
119
|
+
// const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
|
82
120
|
resultPayload = {
|
83
121
|
url: webAppUrl,
|
84
122
|
allowClickPopupOutsideClose: (_this$channelBehavior = this.channelBehavior) === null || _this$channelBehavior === void 0 ? void 0 : _this$channelBehavior.allowClickOutsideClose
|
@@ -88,16 +126,28 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
88
126
|
hostSign: this.hostSign,
|
89
127
|
productSceneVersion: productSceneVersion
|
90
128
|
});
|
91
|
-
|
92
|
-
|
129
|
+
console.log('[DEBUG] - startBizFlow - product info saved');
|
130
|
+
this.logger.logInfo({
|
131
|
+
title: '[DEBUG] - startBizFlow - START'
|
132
|
+
});
|
93
133
|
this.sendRequestAndWaitWebLaunch();
|
94
|
-
console.log('[DEBUG] sendRequestAndWaitWebLaunch completed');
|
134
|
+
console.log('[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed');
|
135
|
+
this.logger.logInfo({
|
136
|
+
title: '[DEBUG] - startBizFlow - sendRequestAndWaitWebLaunch completed'
|
137
|
+
});
|
95
138
|
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
139
|
+
console.log('[DEBUG] - startBizFlow - returning RENDER behavior', {
|
140
|
+
resultPayload: resultPayload
|
141
|
+
});
|
142
|
+
this.logger.logInfo({
|
143
|
+
title: '[DEBUG] - startBizFlow - returning RENDER behavior',
|
144
|
+
msg: JSON.stringify(resultPayload)
|
145
|
+
});
|
96
146
|
return _context.abrupt("return", {
|
97
147
|
behaviorType: 'RENDER',
|
98
148
|
payload: resultPayload
|
99
149
|
});
|
100
|
-
case
|
150
|
+
case 31:
|
101
151
|
case "end":
|
102
152
|
return _context.stop();
|
103
153
|
}
|
@@ -164,21 +214,51 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
164
214
|
key: "sendRequestAndWaitWebLaunch",
|
165
215
|
value: function sendRequestAndWaitWebLaunch() {
|
166
216
|
var _this = this;
|
217
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - START');
|
218
|
+
this.logger.logInfo({
|
219
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - START'
|
220
|
+
});
|
167
221
|
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
222
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - eventCenter initialized');
|
223
|
+
this.logger.logInfo({
|
224
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - eventCenter initialized'
|
225
|
+
});
|
168
226
|
var webLaunchPromise = new Promise(function (resolve) {
|
169
227
|
eventCenter.listen('onLaunch', function (res) {
|
228
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - onLaunch event received', res);
|
229
|
+
_this.logger.logInfo({
|
230
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - onLaunch event received',
|
231
|
+
msg: res
|
232
|
+
});
|
170
233
|
resolve(res);
|
171
234
|
});
|
172
235
|
});
|
173
236
|
|
174
237
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
238
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - waiting for promises');
|
239
|
+
this.logger.logInfo({
|
240
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - waiting for promises'
|
241
|
+
});
|
175
242
|
Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
176
243
|
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext$4;
|
177
244
|
var _ref2 = _slicedToArray(_ref, 3),
|
178
245
|
_initSecurityRes = _ref2[0],
|
179
246
|
submitRes = _ref2[1],
|
180
247
|
_webLaunchRes = _ref2[2];
|
248
|
+
{}
|
249
|
+
_this.logger.logInfo({
|
250
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - all promises resolved'
|
251
|
+
});
|
181
252
|
var logMetaData = _this.logger.getLogConfig().mdata;
|
253
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - logMetaData', logMetaData);
|
254
|
+
_this.logger.logInfo({
|
255
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - logMetaData',
|
256
|
+
msg: JSON.stringify(logMetaData)
|
257
|
+
});
|
258
|
+
console.log('[DEBUG] - sendRequestAndWaitWebLaunch - dispatching renderComponent');
|
259
|
+
_this.logger.logInfo({
|
260
|
+
title: '[DEBUG] - sendRequestAndWaitWebLaunch - dispatching renderComponent'
|
261
|
+
});
|
182
262
|
eventCenter.dispatchToApp({
|
183
263
|
event: 'renderComponent',
|
184
264
|
data: {
|
@@ -223,6 +303,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
223
303
|
while (1) switch (_context2.prev = _context2.next) {
|
224
304
|
case 0:
|
225
305
|
console.log('[DEBUG] processSubmitPay start');
|
306
|
+
this.logger.logInfo({
|
307
|
+
title: '[DEBUG] processSubmitPay start'
|
308
|
+
});
|
226
309
|
submitParams = {
|
227
310
|
paymentSessionData: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionId) || '',
|
228
311
|
paymentSessionConfig: (_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.paymentSessionConfig
|
@@ -244,14 +327,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
244
327
|
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
245
328
|
//console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
246
329
|
if (this.allowSubmitPayCallAhead) {
|
247
|
-
_context2.next =
|
330
|
+
_context2.next = 9;
|
248
331
|
break;
|
249
332
|
}
|
250
333
|
return _context2.abrupt("return", {
|
251
334
|
message: 'sdk no need to make submitPay request',
|
252
335
|
success: true
|
253
336
|
});
|
254
|
-
case
|
337
|
+
case 9:
|
255
338
|
requestBizId = uuid(); // 下面真实发请求
|
256
339
|
this.logger.logInfo({
|
257
340
|
title: 'sdk_event_submitPay'
|
@@ -271,13 +354,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
271
354
|
extParams.complianceSDK = true;
|
272
355
|
submitParams.extParams = extParams;
|
273
356
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
274
|
-
_context2.prev =
|
357
|
+
_context2.prev = 15;
|
275
358
|
_context2.t0 = requester;
|
276
359
|
_context2.t1 = submitParams;
|
277
360
|
_context2.t2 = this.initConfig.environment;
|
278
|
-
_context2.next =
|
361
|
+
_context2.next = 21;
|
279
362
|
return this.acquireApdidToken();
|
280
|
-
case
|
363
|
+
case 21:
|
281
364
|
_context2.t3 = _context2.sent;
|
282
365
|
_context2.t4 = {
|
283
366
|
deviceId: _context2.t3
|
@@ -291,9 +374,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
291
374
|
needEnvInfo: true,
|
292
375
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
293
376
|
};
|
294
|
-
_context2.next =
|
377
|
+
_context2.next = 27;
|
295
378
|
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
296
|
-
case
|
379
|
+
case 27:
|
297
380
|
res = _context2.sent;
|
298
381
|
this.logger.logInfo({
|
299
382
|
title: 'sdk_event_submitPayEnd'
|
@@ -303,10 +386,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
303
386
|
rpcTraceId: res.traceId
|
304
387
|
});
|
305
388
|
console.log('[DEBUG] processSubmitPay completed', res);
|
389
|
+
this.logger.logInfo({
|
390
|
+
title: '[DEBUG] processSubmitPay completed',
|
391
|
+
msg: JSON.stringify(res)
|
392
|
+
});
|
306
393
|
return _context2.abrupt("return", res);
|
307
|
-
case
|
308
|
-
_context2.prev =
|
309
|
-
_context2.t7 = _context2["catch"](
|
394
|
+
case 34:
|
395
|
+
_context2.prev = 34;
|
396
|
+
_context2.t7 = _context2["catch"](15);
|
310
397
|
this.logger.logError({
|
311
398
|
title: 'sdk_event_submitPay_failed'
|
312
399
|
}, {
|
@@ -316,12 +403,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
316
403
|
rpcTraceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
317
404
|
});
|
318
405
|
console.log('[DEBUG] processSubmitPay ERROR', _context2.t7);
|
406
|
+
this.logger.logError({
|
407
|
+
title: '[DEBUG] processSubmitPay ERROR',
|
408
|
+
msg: _context2.t7
|
409
|
+
});
|
319
410
|
throw _context2.t7;
|
320
|
-
case
|
411
|
+
case 40:
|
321
412
|
case "end":
|
322
413
|
return _context2.stop();
|
323
414
|
}
|
324
|
-
}, _callee2, this, [[
|
415
|
+
}, _callee2, this, [[15, 34]]);
|
325
416
|
}));
|
326
417
|
function processSubmitPay() {
|
327
418
|
return _processSubmitPay.apply(this, arguments);
|
@@ -363,7 +454,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
363
454
|
while (1) switch (_context4.prev = _context4.next) {
|
364
455
|
case 0:
|
365
456
|
console.log('[DEBUG] initSecuritySDK start');
|
366
|
-
|
457
|
+
this.logger.logInfo({
|
458
|
+
title: '[DEBUG] initSecuritySDK start'
|
459
|
+
});
|
460
|
+
_context4.prev = 2;
|
367
461
|
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
368
462
|
nonCompliant = (_this$paymentContext$8 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$8 === void 0 ? void 0 : _this$paymentContext$8.nonCompliant;
|
369
463
|
nonInitSecuritySDK = (_this$paymentContext$9 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$9 === void 0 ? void 0 : _this$paymentContext$9.nonInitSecuritySDK;
|
@@ -396,30 +490,37 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
396
490
|
}
|
397
491
|
}
|
398
492
|
if (!shouldInitSecuritySDK) {
|
399
|
-
_context4.next =
|
493
|
+
_context4.next = 12;
|
400
494
|
break;
|
401
495
|
}
|
402
|
-
_context4.next =
|
496
|
+
_context4.next = 12;
|
403
497
|
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
404
|
-
case
|
498
|
+
case 12:
|
405
499
|
console.log('[DEBUG] initSecuritySDK completed');
|
500
|
+
this.logger.logInfo({
|
501
|
+
title: '[DEBUG] initSecuritySDK completed'
|
502
|
+
});
|
406
503
|
this.logger.logInfo({
|
407
504
|
title: 'a3753.b101271.c388193.d514078'
|
408
505
|
}, {
|
409
506
|
riskSdkInfo: shouldInitSecuritySDK ? RiskSdkInfoEnum.NEED : RiskSdkInfoEnum.NO_NEED
|
410
507
|
});
|
411
|
-
_context4.next =
|
508
|
+
_context4.next = 21;
|
412
509
|
break;
|
413
|
-
case
|
414
|
-
_context4.prev =
|
415
|
-
_context4.t0 = _context4["catch"](
|
510
|
+
case 17:
|
511
|
+
_context4.prev = 17;
|
512
|
+
_context4.t0 = _context4["catch"](2);
|
416
513
|
console.log('[DEBUG] initSecuritySDK ERROR');
|
514
|
+
this.logger.logError({
|
515
|
+
title: '[DEBUG] initSecuritySDK ERROR',
|
516
|
+
msg: _context4.t0
|
517
|
+
});
|
417
518
|
// do nothing when init security failed
|
418
|
-
case
|
519
|
+
case 21:
|
419
520
|
case "end":
|
420
521
|
return _context4.stop();
|
421
522
|
}
|
422
|
-
}, _callee4, this, [[
|
523
|
+
}, _callee4, this, [[2, 17]]);
|
423
524
|
}));
|
424
525
|
function initSecuritySDK() {
|
425
526
|
return _initSecuritySDK.apply(this, arguments);
|
@@ -46,11 +46,19 @@ 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 logger, envInfo, _data, startTime, traceId, myRequest, _yield$myRequest, data, headers, 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:
|
53
53
|
console.log('[DEBUG] request start', requestData, options);
|
54
|
+
logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
55
|
+
logger.logInfo({
|
56
|
+
title: '[DEBUG] request start',
|
57
|
+
msg: JSON.stringify({
|
58
|
+
requestData: requestData,
|
59
|
+
options: options
|
60
|
+
})
|
61
|
+
});
|
54
62
|
envInfo = this.getEnvInfo(options);
|
55
63
|
_data = [_objectSpread(_objectSpread({}, requestData), {}, {
|
56
64
|
envInfo: envInfo,
|
@@ -60,31 +68,65 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
60
68
|
})];
|
61
69
|
startTime = Date.now();
|
62
70
|
traceId = '';
|
63
|
-
_context.prev =
|
71
|
+
_context.prev = 7;
|
64
72
|
console.log('[DEBUG] createRequestInstance start');
|
73
|
+
logger.logInfo({
|
74
|
+
title: '[DEBUG] createRequestInstance start'
|
75
|
+
});
|
65
76
|
myRequest = this.createRequestInstance(options);
|
66
77
|
console.log('[DEBUG] createRequestInstance completed', myRequest);
|
78
|
+
logger.logInfo({
|
79
|
+
title: '[DEBUG] createRequestInstance completed',
|
80
|
+
msg: JSON.stringify({
|
81
|
+
myRequest: myRequest
|
82
|
+
})
|
83
|
+
});
|
67
84
|
console.log('[DEBUG] myRequest start');
|
68
|
-
|
85
|
+
logger.logInfo({
|
86
|
+
title: '[DEBUG] myRequest start'
|
87
|
+
});
|
88
|
+
_context.next = 17;
|
69
89
|
return myRequest({
|
70
90
|
data: _data
|
71
91
|
});
|
72
|
-
case
|
92
|
+
case 17:
|
73
93
|
_yield$myRequest = _context.sent;
|
74
94
|
data = _yield$myRequest.data;
|
75
95
|
headers = _yield$myRequest.headers;
|
76
96
|
console.log('[DEBUG] myRequest completed', data, headers);
|
97
|
+
logger.logInfo({
|
98
|
+
title: '[DEBUG] myRequest completed',
|
99
|
+
msg: JSON.stringify({
|
100
|
+
data: data,
|
101
|
+
headers: headers
|
102
|
+
})
|
103
|
+
});
|
77
104
|
resData = data || {};
|
78
105
|
traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
|
79
106
|
resData.traceId = traceId || '';
|
80
107
|
console.log('[DEBUG] handleGetWayError start');
|
108
|
+
logger.logInfo({
|
109
|
+
title: '[DEBUG] handleGetWayError start'
|
110
|
+
});
|
81
111
|
handleGetWayError = fomatGetwayError(headers, traceId);
|
82
112
|
console.log('[DEBUG] handleGetWayError completed', handleGetWayError);
|
113
|
+
logger.logInfo({
|
114
|
+
title: '[DEBUG] handleGetWayError completed',
|
115
|
+
msg: JSON.stringify({
|
116
|
+
handleGetWayError: handleGetWayError
|
117
|
+
})
|
118
|
+
});
|
83
119
|
if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
|
84
|
-
_context.next =
|
120
|
+
_context.next = 39;
|
85
121
|
break;
|
86
122
|
}
|
87
123
|
console.log('[DEBUG] handleGetWayError errorCode', handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode);
|
124
|
+
logger.logInfo({
|
125
|
+
title: '[DEBUG] handleGetWayError errorCode',
|
126
|
+
msg: JSON.stringify({
|
127
|
+
errorCode: handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode
|
128
|
+
})
|
129
|
+
});
|
88
130
|
errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
|
89
131
|
errorCode = handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode;
|
90
132
|
this.reportRequestTimeCost({
|
@@ -102,12 +144,20 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
102
144
|
errorCode: errorCode,
|
103
145
|
success: false
|
104
146
|
});
|
147
|
+
logger.logInfo({
|
148
|
+
title: '[DEBUG] handleGetWayError error',
|
149
|
+
msg: JSON.stringify({
|
150
|
+
errorMessage: errorMessage,
|
151
|
+
errorCode: errorCode,
|
152
|
+
success: false
|
153
|
+
})
|
154
|
+
});
|
105
155
|
throw new Error(JSON.stringify({
|
106
156
|
errorMessage: errorMessage,
|
107
157
|
errorCode: errorCode,
|
108
158
|
success: false
|
109
159
|
}));
|
110
|
-
case
|
160
|
+
case 39:
|
111
161
|
this.reportRequestTimeCost({
|
112
162
|
title: 'a3753.b101271.c388193.d521387',
|
113
163
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
@@ -119,10 +169,16 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
119
169
|
traceId: traceId
|
120
170
|
});
|
121
171
|
console.log('[DEBUG] request completed', resData);
|
172
|
+
logger.logInfo({
|
173
|
+
title: '[DEBUG] request completed',
|
174
|
+
msg: JSON.stringify({
|
175
|
+
resData: resData
|
176
|
+
})
|
177
|
+
});
|
122
178
|
return _context.abrupt("return", resData);
|
123
|
-
case
|
124
|
-
_context.prev =
|
125
|
-
_context.t0 = _context["catch"](
|
179
|
+
case 45:
|
180
|
+
_context.prev = 45;
|
181
|
+
_context.t0 = _context["catch"](7);
|
126
182
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
127
183
|
success: false,
|
128
184
|
errorCode: errorEnum.SYSTEM,
|
@@ -130,6 +186,13 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
130
186
|
errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
|
131
187
|
});
|
132
188
|
console.log('[DEBUG] request error 1', _error, 'Original error:', _context.t0);
|
189
|
+
logger.logInfo({
|
190
|
+
title: '[DEBUG] request error 1',
|
191
|
+
msg: JSON.stringify({
|
192
|
+
_error: _error,
|
193
|
+
originalError: _context.t0
|
194
|
+
})
|
195
|
+
});
|
133
196
|
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
|
134
197
|
_errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
|
135
198
|
this.reportRequestTimeCost({
|
@@ -147,17 +210,26 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
147
210
|
traceId: traceId,
|
148
211
|
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
149
212
|
});
|
213
|
+
logger.logInfo({
|
214
|
+
title: '[DEBUG] request error 2',
|
215
|
+
msg: JSON.stringify({
|
216
|
+
success: false,
|
217
|
+
errorCode: _errorCode,
|
218
|
+
traceId: traceId,
|
219
|
+
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
220
|
+
})
|
221
|
+
});
|
150
222
|
return _context.abrupt("return", Promise.reject({
|
151
223
|
success: false,
|
152
224
|
errorCode: _errorCode,
|
153
225
|
traceId: traceId,
|
154
226
|
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
155
227
|
}));
|
156
|
-
case
|
228
|
+
case 56:
|
157
229
|
case "end":
|
158
230
|
return _context.stop();
|
159
231
|
}
|
160
|
-
}, _callee, this, [[
|
232
|
+
}, _callee, this, [[7, 45]]);
|
161
233
|
}));
|
162
234
|
function request(_x, _x2) {
|
163
235
|
return _request.apply(this, arguments);
|
@@ -216,14 +288,35 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
216
288
|
withCredentials: options.withCredentials,
|
217
289
|
headers: Object.keys(options.headers || {})
|
218
290
|
});
|
291
|
+
var logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
292
|
+
logger.logInfo({
|
293
|
+
title: '[DEBUG] createRequestInstance start',
|
294
|
+
msg: JSON.stringify({
|
295
|
+
env: options.env,
|
296
|
+
'Operation-Type': options['Operation-Type'],
|
297
|
+
hostSign: options === null || options === void 0 ? void 0 : options.hostSign,
|
298
|
+
timeout: options.timeout,
|
299
|
+
method: options === null || options === void 0 ? void 0 : options.method,
|
300
|
+
withCredentials: options.withCredentials,
|
301
|
+
headers: Object.keys(options.headers || {})
|
302
|
+
})
|
303
|
+
});
|
219
304
|
var date = new Date(); // 获取当前时间
|
220
305
|
var timestamp = date.getTime(); // 获取时间戳
|
221
306
|
var utcTimestamp = timestamp + date.getTimezoneOffset() * 60 * 1000; // 获取 UTC 时间戳
|
222
307
|
var env = options.env || 'prod';
|
223
308
|
var lightSandboxConfig = lightSandboxMap(options['Operation-Type'], env); // light_sandbox
|
224
309
|
console.log('[DEBUG] lightSandboxConfig:', lightSandboxConfig);
|
310
|
+
logger.logInfo({
|
311
|
+
title: '[DEBUG] lightSandboxConfig',
|
312
|
+
msg: JSON.stringify(lightSandboxConfig)
|
313
|
+
});
|
225
314
|
var baseURL = options.baseURL || lightSandboxConfig.baseURL || hostSignMap(options === null || options === void 0 ? void 0 : options.hostSign, env) || requestHost[env];
|
226
315
|
console.log('[DEBUG] baseURL:', baseURL);
|
316
|
+
logger.logInfo({
|
317
|
+
title: '[DEBUG] baseURL',
|
318
|
+
msg: baseURL
|
319
|
+
});
|
227
320
|
var _headers = _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
228
321
|
appId: lightSandboxConfig.appId || appId,
|
229
322
|
workspaceId: options.env === 'pre' ? 'pre' : 'default'
|
@@ -236,7 +329,23 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
236
329
|
}
|
237
330
|
if (env !== 'dev') delete _headers['sofa-group-name'];
|
238
331
|
console.log('[DEBUG] request headers keys:', Object.keys(_headers));
|
239
|
-
|
332
|
+
logger.logInfo({
|
333
|
+
title: '[DEBUG] request headers keys',
|
334
|
+
msg: JSON.stringify(Object.keys(_headers))
|
335
|
+
});
|
336
|
+
|
337
|
+
// 确保 axios 库正确加载
|
338
|
+
if (typeof axios === 'undefined') {
|
339
|
+
console.log('[DEBUG] axios undefined');
|
340
|
+
logger.logError({
|
341
|
+
title: '[DEBUG] axios undefined'
|
342
|
+
});
|
343
|
+
}
|
344
|
+
console.log('[DEBUG] axios version:', axios.VERSION);
|
345
|
+
logger.logInfo({
|
346
|
+
title: '[DEBUG] axios version',
|
347
|
+
msg: axios.VERSION
|
348
|
+
});
|
240
349
|
var instance = axios.create({
|
241
350
|
baseURL: baseURL,
|
242
351
|
timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
|
@@ -250,8 +359,28 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
250
359
|
method: instance.defaults.method,
|
251
360
|
withCredentials: instance.defaults.withCredentials
|
252
361
|
});
|
253
|
-
|
254
|
-
|
362
|
+
logger.logInfo({
|
363
|
+
title: '[DEBUG] axios instance created',
|
364
|
+
msg: JSON.stringify({
|
365
|
+
baseURL: instance.defaults.baseURL,
|
366
|
+
timeout: instance.defaults.timeout,
|
367
|
+
method: instance.defaults.method,
|
368
|
+
withCredentials: instance.defaults.withCredentials
|
369
|
+
})
|
370
|
+
});
|
371
|
+
console.log('[DEBUG] instance.request', instance.request);
|
372
|
+
logger.logInfo({
|
373
|
+
title: '[DEBUG] instance.request',
|
374
|
+
msg: JSON.stringify(instance.request)
|
375
|
+
});
|
376
|
+
console.log('[DEBUG] instance.request.bind(instance)', instance.request.bind(instance));
|
377
|
+
logger.logInfo({
|
378
|
+
title: '[DEBUG] instance.request.bind',
|
379
|
+
msg: JSON.stringify(instance.request.bind(instance))
|
380
|
+
});
|
381
|
+
|
382
|
+
// return instance.request;
|
383
|
+
return instance.request.bind(instance);
|
255
384
|
}
|
256
385
|
}]);
|
257
386
|
return RequesterService;
|