ws-process 0.3.22 → 0.3.26
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/index.js +25 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { tryit } from 'ui5-lib-rc';
|
|
|
3
3
|
import randomize from 'randomatic';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { cloneDeep } from 'lodash';
|
|
6
|
+
import { defined } from '@bsgp/lib-core';
|
|
6
7
|
import { ref, Loading, getRef } from './Loading-esm';
|
|
7
8
|
import {
|
|
8
9
|
storeSplittedData,
|
|
@@ -436,6 +437,7 @@ function handleResponseHandler(res, getState, isLast = true, isFirst = true) {
|
|
|
436
437
|
|
|
437
438
|
function asyncSend(msg) {
|
|
438
439
|
return (dispatch, getState) => {
|
|
440
|
+
// eslint-disable-next-line consistent-return
|
|
439
441
|
const promise = new Promise((resolve, reject) => {
|
|
440
442
|
if (local.wsProcess.maxConcurrency > 0) {
|
|
441
443
|
if (local.wsProcess.concurrency === local.wsProcess.maxConcurrency) {
|
|
@@ -489,43 +491,56 @@ function asyncSend(msg) {
|
|
|
489
491
|
headers['bsg-support-session'] = user.session;
|
|
490
492
|
headers['bsg-support-user-id'] = user.id;
|
|
491
493
|
headers['bsg-support-system-external-id'] = user.pid;
|
|
492
|
-
headers['bsg-support-partner-id'] = user.partnerID;
|
|
493
|
-
headers['bsg-support-system-id'] = user.systemID;
|
|
494
|
-
headers['x-api-key'] = user.
|
|
494
|
+
// headers['bsg-support-partner-id'] = user.partnerID;
|
|
495
|
+
// headers['bsg-support-system-id'] = user.systemID;
|
|
496
|
+
headers['x-api-key'] = [user.systemID, user.partnerID].join('@');
|
|
495
497
|
headers['request-datetime'] = cProcessItemRoot.requestTime;
|
|
496
498
|
headers.href = window.location.href;
|
|
497
499
|
|
|
498
500
|
const httpMSG = removeUndefinedKeys({
|
|
499
501
|
url,
|
|
500
502
|
method: msg.method,
|
|
501
|
-
params: msg.params,
|
|
502
|
-
data: msg.data,
|
|
503
|
+
params: defined(msg.params, msg.method === 'GET' ? msg.body : undefined),
|
|
504
|
+
data: defined(msg.data, msg.method !== 'GET' ? msg.body : undefined),
|
|
503
505
|
headers: {
|
|
504
506
|
...msg.headers,
|
|
505
507
|
...headers,
|
|
506
508
|
},
|
|
507
509
|
validateStatus: () => true,
|
|
508
510
|
});
|
|
509
|
-
console.log('%csending message:', 'color:green', httpMSG);
|
|
511
|
+
console.log('%csending message:', 'color:green', httpMSG, msg);
|
|
510
512
|
|
|
511
513
|
return axios(httpMSG).catch((ex) => {
|
|
512
514
|
console.log('%conmessage(converted):', 'color:red', ex);
|
|
513
|
-
|
|
515
|
+
const processID = ex.config.headers['bsg-support-process-id'];
|
|
514
516
|
const cProcessItem = getCurrentProcessItem(
|
|
515
517
|
getState,
|
|
516
|
-
|
|
518
|
+
processID,
|
|
517
519
|
);
|
|
518
520
|
if (local.validateResponse) {
|
|
519
521
|
tryit(() => local.store.dispatch(local.validateResponse(ex, cProcessItem)));
|
|
520
522
|
}
|
|
521
|
-
local.dispatch(updateWSCount(
|
|
523
|
+
local.dispatch(updateWSCount(processID));
|
|
522
524
|
reject(ex);
|
|
525
|
+
}).then((data) => {
|
|
526
|
+
const bodyUrl = tryit(() => data.data.getBodyFromUrl === true && data.data.url);
|
|
527
|
+
if (bodyUrl) {
|
|
528
|
+
return axios({
|
|
529
|
+
url: bodyUrl,
|
|
530
|
+
}).then((bodyData) => ({
|
|
531
|
+
...data,
|
|
532
|
+
data: bodyData.data,
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
return data;
|
|
523
536
|
}).then((data) => {
|
|
524
537
|
console.log('%cHTTP.res:', 'color:red', data);
|
|
525
|
-
const
|
|
538
|
+
const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
|
|
539
|
+
|
|
526
540
|
const newData = {
|
|
527
541
|
processID,
|
|
528
542
|
body: data.data,
|
|
543
|
+
headers: data.headers,
|
|
529
544
|
statusCode: data.status,
|
|
530
545
|
};
|
|
531
546
|
const cProcessItem = getCurrentProcessItem(
|