ws-process 0.3.59 → 0.4.1
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 +31 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import/extensions */
|
|
1
2
|
/* eslint-disable import/no-unresolved */
|
|
2
3
|
// ws-process.js
|
|
3
4
|
import axios from 'axios';
|
|
@@ -599,11 +600,20 @@ function asyncSend(msg) {
|
|
|
599
600
|
}),
|
|
600
601
|
);
|
|
601
602
|
|
|
603
|
+
const cProcess = getCurrentProcess(getState, msg.processID);
|
|
602
604
|
const cProcessItemRoot = getCurrentProcessItem(getState, msg.processID);
|
|
603
605
|
|
|
604
|
-
if (!msg.action) {
|
|
606
|
+
if (!msg.action || (cProcess.options.useApi2 === true)) {
|
|
605
607
|
let url;
|
|
608
|
+
let method;
|
|
609
|
+
if (msg.method) {
|
|
610
|
+
method = msg.method;
|
|
611
|
+
} else {
|
|
612
|
+
method = cProcess.options.method || 'POST';
|
|
613
|
+
}
|
|
606
614
|
const user = getState().user.currentUser;
|
|
615
|
+
let httpBody = msg.body;
|
|
616
|
+
let httpParams = msg.params;
|
|
607
617
|
|
|
608
618
|
if (/^https{0,1}:\/\//.test(msg.url)) {
|
|
609
619
|
url = msg.url;
|
|
@@ -618,18 +628,29 @@ function asyncSend(msg) {
|
|
|
618
628
|
// return 'api-dev';
|
|
619
629
|
// }
|
|
620
630
|
// });
|
|
631
|
+
if (msg.action === 'manageadir') {
|
|
632
|
+
url = '/a';
|
|
633
|
+
httpBody = { params: msg.params };
|
|
634
|
+
httpParams = undefined;
|
|
635
|
+
} else if (msg.action === 'manageconfiguration') {
|
|
636
|
+
url = '/c';
|
|
637
|
+
} else if (msg.action === 'api-hub') {
|
|
638
|
+
url = '/h';
|
|
639
|
+
} else {
|
|
640
|
+
url = msg.url;
|
|
641
|
+
}
|
|
621
642
|
|
|
622
643
|
const currentState = getState();
|
|
623
644
|
const {
|
|
624
645
|
AltDomain: altDomain,
|
|
625
646
|
} = tryit(() => currentState['api-Configuration'].merged.ui.result) || {};
|
|
626
647
|
if (altDomain) {
|
|
627
|
-
url = [altDomain,
|
|
648
|
+
url = [altDomain, url.replace(/^\/{0,}/, '')].join('/');
|
|
628
649
|
} else {
|
|
629
650
|
const myDomain = [
|
|
630
651
|
'https://',
|
|
631
652
|
[
|
|
632
|
-
user.system?.useApi2 === true ? 'api2' : 'api',
|
|
653
|
+
(user.system?.useApi2 === true || cProcess.options.useApi2 === true) ? 'api2' : 'api',
|
|
633
654
|
['dev', 'staging'].find(
|
|
634
655
|
(each) => each === local.stage,
|
|
635
656
|
)
|
|
@@ -642,7 +663,7 @@ function asyncSend(msg) {
|
|
|
642
663
|
].join('');
|
|
643
664
|
url = [
|
|
644
665
|
myDomain,
|
|
645
|
-
|
|
666
|
+
url.replace(/^\/{0,}/, ''),
|
|
646
667
|
].join('/');
|
|
647
668
|
}
|
|
648
669
|
}
|
|
@@ -659,7 +680,7 @@ function asyncSend(msg) {
|
|
|
659
680
|
headers['bsg-support-system-external-id'] = user.pid;
|
|
660
681
|
// headers['bsg-support-partner-id'] = user.partnerID;
|
|
661
682
|
// headers['bsg-support-system-id'] = user.systemID;
|
|
662
|
-
if (tryit(() =>
|
|
683
|
+
if (tryit(() => httpBody.Idp) === 'google' && !user.systemID && !user.partnerID) {
|
|
663
684
|
headers['x-api-key'] = '5db1bf127d3fcc0cfdd8880cb5cbe6f9'; // means "initial login"
|
|
664
685
|
} else {
|
|
665
686
|
headers['x-api-key'] = [user.systemID, user.partnerID].join('@');
|
|
@@ -669,9 +690,9 @@ function asyncSend(msg) {
|
|
|
669
690
|
|
|
670
691
|
const httpMSG = removeUndefinedKeys({
|
|
671
692
|
url,
|
|
672
|
-
method
|
|
673
|
-
params: defined(
|
|
674
|
-
data: defined(msg.data,
|
|
693
|
+
method,
|
|
694
|
+
params: defined(httpParams, method === 'GET' ? stringifyParams(httpBody) : undefined),
|
|
695
|
+
data: defined(msg.data, method !== 'GET' ? httpBody : undefined),
|
|
675
696
|
headers: {
|
|
676
697
|
...msg.headers,
|
|
677
698
|
...headers,
|
|
@@ -887,8 +908,8 @@ function asyncSend(msg) {
|
|
|
887
908
|
so we just wait for next message from lambda function
|
|
888
909
|
*/
|
|
889
910
|
|
|
890
|
-
const
|
|
891
|
-
if (
|
|
911
|
+
const cProcessStarted = getCurrentProcess(getState, started.processID);
|
|
912
|
+
if (cProcessStarted) {
|
|
892
913
|
local.dispatch(
|
|
893
914
|
updateWSProcess(started.processID, {
|
|
894
915
|
action: started.action,
|