ws-process 0.3.25 → 0.3.28
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 +70 -44
- 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
|
@@ -480,7 +480,16 @@ function asyncSend(msg) {
|
|
|
480
480
|
// return 'api-dev';
|
|
481
481
|
// }
|
|
482
482
|
// });
|
|
483
|
-
|
|
483
|
+
|
|
484
|
+
const currentState = getState();
|
|
485
|
+
const {
|
|
486
|
+
AltDomain: altDomain
|
|
487
|
+
} = tryit(() => currentState["api-Configuration"].merged.ui.result) || {};
|
|
488
|
+
if(altDomain){
|
|
489
|
+
url = [altDomain, msg.url.replace(/^\/{0,}/, '')].join('/');
|
|
490
|
+
}else{
|
|
491
|
+
url = ['https://api.bsg.support', msg.url.replace(/^\/{0,}/, '')].join('/');
|
|
492
|
+
}
|
|
484
493
|
}
|
|
485
494
|
const user = getState().user.currentUser;
|
|
486
495
|
const headers = {};
|
|
@@ -522,9 +531,21 @@ function asyncSend(msg) {
|
|
|
522
531
|
}
|
|
523
532
|
local.dispatch(updateWSCount(processID));
|
|
524
533
|
reject(ex);
|
|
534
|
+
}).then((data) => {
|
|
535
|
+
const bodyUrl = tryit(() => data.data.getBodyFromUrl === true && data.data.url);
|
|
536
|
+
if (bodyUrl) {
|
|
537
|
+
return axios({
|
|
538
|
+
url: bodyUrl,
|
|
539
|
+
}).then((bodyData) => ({
|
|
540
|
+
...data,
|
|
541
|
+
data: bodyData.data,
|
|
542
|
+
}));
|
|
543
|
+
}
|
|
544
|
+
return data;
|
|
525
545
|
}).then((data) => {
|
|
526
546
|
console.log('%cHTTP.res:', 'color:red', data);
|
|
527
|
-
const
|
|
547
|
+
const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
|
|
548
|
+
|
|
528
549
|
const newData = {
|
|
529
550
|
processID,
|
|
530
551
|
body: data.data,
|
|
@@ -535,31 +556,34 @@ function asyncSend(msg) {
|
|
|
535
556
|
getState,
|
|
536
557
|
processID,
|
|
537
558
|
);
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
559
|
+
|
|
560
|
+
if ([undefined, true].includes(cProcessItem.doValidateResponse)) {
|
|
561
|
+
const hasError = local.validateResponse
|
|
562
|
+
? local.store.dispatch(
|
|
563
|
+
local.validateResponse(newData, cProcessItem),
|
|
564
|
+
)
|
|
565
|
+
: false;
|
|
566
|
+
if (hasError) {
|
|
544
567
|
// reject the promise from reqHandler in runProcess
|
|
545
568
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
569
|
+
const { callback } = cProcessItem;
|
|
570
|
+
if (callback) {
|
|
571
|
+
if (callback.afterFailed) {
|
|
572
|
+
callback.afterFailed(newData);
|
|
573
|
+
}
|
|
574
|
+
if (callback.always) {
|
|
575
|
+
callback.always();
|
|
576
|
+
}
|
|
550
577
|
}
|
|
551
|
-
if (
|
|
552
|
-
|
|
578
|
+
if (cProcessItem.reject) {
|
|
579
|
+
cProcessItem.reject({
|
|
580
|
+
errorOccurred: true,
|
|
581
|
+
processID,
|
|
582
|
+
data: newData,
|
|
583
|
+
});
|
|
553
584
|
}
|
|
585
|
+
return;
|
|
554
586
|
}
|
|
555
|
-
if (cProcessItem.reject) {
|
|
556
|
-
cProcessItem.reject({
|
|
557
|
-
errorOccurred: true,
|
|
558
|
-
processID,
|
|
559
|
-
data: newData,
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
return;
|
|
563
587
|
}
|
|
564
588
|
|
|
565
589
|
const { terminate } = handleResponseHandler(
|
|
@@ -776,31 +800,33 @@ function asyncSend(msg) {
|
|
|
776
800
|
jsonResponse.processID,
|
|
777
801
|
);
|
|
778
802
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
local.
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
if (callback
|
|
790
|
-
callback.afterFailed
|
|
803
|
+
if ([undefined, true].includes(cProcessItem.doValidateResponse)) {
|
|
804
|
+
const hasError = local.validateResponse
|
|
805
|
+
? local.store.dispatch(
|
|
806
|
+
local.validateResponse(jsonResponse, cProcessItem),
|
|
807
|
+
)
|
|
808
|
+
: false;
|
|
809
|
+
if (hasError) {
|
|
810
|
+
// reject the promise from reqHandler in runProcess
|
|
811
|
+
|
|
812
|
+
const { callback } = cProcessItem;
|
|
813
|
+
if (callback) {
|
|
814
|
+
if (callback.afterFailed) {
|
|
815
|
+
callback.afterFailed(jsonResponse);
|
|
816
|
+
}
|
|
817
|
+
if (callback.always) {
|
|
818
|
+
callback.always();
|
|
819
|
+
}
|
|
791
820
|
}
|
|
792
|
-
if (
|
|
793
|
-
|
|
821
|
+
if (cProcessItem.reject) {
|
|
822
|
+
cProcessItem.reject({
|
|
823
|
+
errorOccurred: true,
|
|
824
|
+
processID: cProcessItem.processID,
|
|
825
|
+
data: jsonResponse,
|
|
826
|
+
});
|
|
794
827
|
}
|
|
828
|
+
return;
|
|
795
829
|
}
|
|
796
|
-
if (cProcessItem.reject) {
|
|
797
|
-
cProcessItem.reject({
|
|
798
|
-
errorOccurred: true,
|
|
799
|
-
processID: cProcessItem.processID,
|
|
800
|
-
data: jsonResponse,
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
return;
|
|
804
830
|
}
|
|
805
831
|
|
|
806
832
|
const thisCount = tryit(() => jsonResponse.body.d.results.length);
|