ws-process 0.3.27 → 0.3.29
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/Loading-esm.js +0 -0
- package/Loading-esm.js.map +0 -0
- package/Loading.css +0 -0
- package/Loading.js +0 -0
- package/index.js +48 -21
- package/package.json +1 -1
package/Loading-esm.js
CHANGED
|
File without changes
|
package/Loading-esm.js.map
CHANGED
|
File without changes
|
package/Loading.css
CHANGED
|
File without changes
|
package/Loading.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -24,7 +24,24 @@ import reducer, { initialState } from './reducer';
|
|
|
24
24
|
import 'url-search-params-polyfill';
|
|
25
25
|
import { cutStringByLength, createSplitPayload } from './lib/split-payload';
|
|
26
26
|
|
|
27
|
-
const local = {
|
|
27
|
+
const local = {
|
|
28
|
+
processes: {},
|
|
29
|
+
wsProcess: initialState,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
local.dispatch = (action) => {
|
|
33
|
+
local.wsProcess = reducer(local.wsProcess, action);
|
|
34
|
+
if (getRef().current) {
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case storeSplittedData().type:
|
|
37
|
+
case clearDataSplitted().type:
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
getRef().current.setState({ wsProcess: local.wsProcess });
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
28
45
|
|
|
29
46
|
function getType(obj) {
|
|
30
47
|
return Object.prototype.toString.call(obj);
|
|
@@ -359,8 +376,13 @@ function handleResponseHandler(res, getState, isLast = true, isFirst = true) {
|
|
|
359
376
|
res.processID,
|
|
360
377
|
);
|
|
361
378
|
const { resHandler, callback, requestTime } = cProcessItem;
|
|
362
|
-
console.warn('distance:', new Date() - new Date(requestTime), res.processID, prc.count);
|
|
363
379
|
|
|
380
|
+
if(process.env.NODE_ENV === "test"){
|
|
381
|
+
// pass
|
|
382
|
+
}else{
|
|
383
|
+
console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(()=>res.headers["x-log-id"]));
|
|
384
|
+
}
|
|
385
|
+
|
|
364
386
|
const result = resHandler
|
|
365
387
|
? local.store.dispatch(
|
|
366
388
|
resHandler({
|
|
@@ -480,7 +502,16 @@ function asyncSend(msg) {
|
|
|
480
502
|
// return 'api-dev';
|
|
481
503
|
// }
|
|
482
504
|
// });
|
|
483
|
-
|
|
505
|
+
|
|
506
|
+
const currentState = getState();
|
|
507
|
+
const {
|
|
508
|
+
AltDomain: altDomain
|
|
509
|
+
} = tryit(() => currentState["api-Configuration"].merged.ui.result) || {};
|
|
510
|
+
if(altDomain){
|
|
511
|
+
url = [altDomain, msg.url.replace(/^\/{0,}/, '')].join('/');
|
|
512
|
+
}else{
|
|
513
|
+
url = ['https://api.bsg.support', msg.url.replace(/^\/{0,}/, '')].join('/');
|
|
514
|
+
}
|
|
484
515
|
}
|
|
485
516
|
const user = getState().user.currentUser;
|
|
486
517
|
const headers = {};
|
|
@@ -508,7 +539,12 @@ function asyncSend(msg) {
|
|
|
508
539
|
},
|
|
509
540
|
validateStatus: () => true,
|
|
510
541
|
});
|
|
511
|
-
|
|
542
|
+
|
|
543
|
+
if(process.env.NODE_ENV === "test"){
|
|
544
|
+
// pass
|
|
545
|
+
}else{
|
|
546
|
+
console.log('%csending message:', 'color:green', httpMSG, msg);
|
|
547
|
+
}
|
|
512
548
|
|
|
513
549
|
return axios(httpMSG).catch((ex) => {
|
|
514
550
|
console.log('%conmessage(converted):', 'color:red', ex);
|
|
@@ -534,7 +570,11 @@ function asyncSend(msg) {
|
|
|
534
570
|
}
|
|
535
571
|
return data;
|
|
536
572
|
}).then((data) => {
|
|
537
|
-
|
|
573
|
+
if(process.env.NODE_ENV === "test"){
|
|
574
|
+
// pass
|
|
575
|
+
}else{
|
|
576
|
+
console.log('%cHTTP.res:', 'color:red', data);
|
|
577
|
+
}
|
|
538
578
|
const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
|
|
539
579
|
|
|
540
580
|
const newData = {
|
|
@@ -930,7 +970,7 @@ function runProcess(processID, data) {
|
|
|
930
970
|
// const args = leakArguments(arguments, 1);
|
|
931
971
|
|
|
932
972
|
return (dispatch, getState) => {
|
|
933
|
-
console.
|
|
973
|
+
console.debug('run process ', processID);
|
|
934
974
|
return new Promise((resolve, reject) => {
|
|
935
975
|
const { processes } = local.wsProcess;
|
|
936
976
|
|
|
@@ -946,7 +986,7 @@ function runProcess(processID, data) {
|
|
|
946
986
|
if (prc.count === prc.items.length) {
|
|
947
987
|
// process finished
|
|
948
988
|
|
|
949
|
-
console.
|
|
989
|
+
console.debug('process finished ', processID);
|
|
950
990
|
|
|
951
991
|
// const unfinishedProcesses = Object.keys(processes).filter(subKey => {
|
|
952
992
|
// if (processes[subKey].count < processes[subKey].items.length) {
|
|
@@ -1238,20 +1278,7 @@ function init({
|
|
|
1238
1278
|
local.store = store;
|
|
1239
1279
|
local.stage = stage;
|
|
1240
1280
|
local.wsURL = wsURL;
|
|
1241
|
-
|
|
1242
|
-
local.dispatch = (action) => {
|
|
1243
|
-
local.wsProcess = reducer(local.wsProcess, action);
|
|
1244
|
-
if (getRef().current) {
|
|
1245
|
-
switch (action.type) {
|
|
1246
|
-
case storeSplittedData().type:
|
|
1247
|
-
case clearDataSplitted().type:
|
|
1248
|
-
break;
|
|
1249
|
-
default:
|
|
1250
|
-
getRef().current.setState({ wsProcess: local.wsProcess });
|
|
1251
|
-
break;
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1281
|
+
|
|
1255
1282
|
local.beforeEachProcess = beforeEachProcess || (() => {});
|
|
1256
1283
|
local.afterEachProcess = afterEachProcess || (() => {});
|
|
1257
1284
|
local.beforeAllProcesses = beforeAllProcesses || (() => {});
|