ws-process 0.4.0 → 0.4.2
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 +20 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -603,9 +603,17 @@ function asyncSend(msg) {
|
|
|
603
603
|
const cProcess = getCurrentProcess(getState, msg.processID);
|
|
604
604
|
const cProcessItemRoot = getCurrentProcessItem(getState, msg.processID);
|
|
605
605
|
|
|
606
|
-
if (!msg.action || (cProcess.useApi2 === true)) {
|
|
606
|
+
if (!msg.action || (cProcess.options.useApi2 === true)) {
|
|
607
607
|
let url;
|
|
608
|
+
let method;
|
|
609
|
+
if (msg.method) {
|
|
610
|
+
method = msg.method;
|
|
611
|
+
} else {
|
|
612
|
+
method = cProcess.options.method || 'POST';
|
|
613
|
+
}
|
|
608
614
|
const user = getState().user.currentUser;
|
|
615
|
+
let httpBody = msg.body;
|
|
616
|
+
let httpParams = msg.params;
|
|
609
617
|
|
|
610
618
|
if (/^https{0,1}:\/\//.test(msg.url)) {
|
|
611
619
|
url = msg.url;
|
|
@@ -622,8 +630,12 @@ function asyncSend(msg) {
|
|
|
622
630
|
// });
|
|
623
631
|
if (msg.action === 'manageadir') {
|
|
624
632
|
url = '/a';
|
|
633
|
+
httpBody = { params: msg.params };
|
|
634
|
+
httpParams = undefined;
|
|
625
635
|
} else if (msg.action === 'manageconfiguration') {
|
|
626
636
|
url = '/c';
|
|
637
|
+
httpBody = { params: msg.params };
|
|
638
|
+
httpParams = undefined;
|
|
627
639
|
} else if (msg.action === 'api-hub') {
|
|
628
640
|
url = '/h';
|
|
629
641
|
} else {
|
|
@@ -640,7 +652,7 @@ function asyncSend(msg) {
|
|
|
640
652
|
const myDomain = [
|
|
641
653
|
'https://',
|
|
642
654
|
[
|
|
643
|
-
(user.system?.useApi2 === true || cProcess.useApi2 === true) ? 'api2' : 'api',
|
|
655
|
+
(user.system?.useApi2 === true || cProcess.options.useApi2 === true) ? 'api2' : 'api',
|
|
644
656
|
['dev', 'staging'].find(
|
|
645
657
|
(each) => each === local.stage,
|
|
646
658
|
)
|
|
@@ -670,7 +682,7 @@ function asyncSend(msg) {
|
|
|
670
682
|
headers['bsg-support-system-external-id'] = user.pid;
|
|
671
683
|
// headers['bsg-support-partner-id'] = user.partnerID;
|
|
672
684
|
// headers['bsg-support-system-id'] = user.systemID;
|
|
673
|
-
if (tryit(() =>
|
|
685
|
+
if (tryit(() => httpBody.Idp) === 'google' && !user.systemID && !user.partnerID) {
|
|
674
686
|
headers['x-api-key'] = '5db1bf127d3fcc0cfdd8880cb5cbe6f9'; // means "initial login"
|
|
675
687
|
} else {
|
|
676
688
|
headers['x-api-key'] = [user.systemID, user.partnerID].join('@');
|
|
@@ -680,9 +692,9 @@ function asyncSend(msg) {
|
|
|
680
692
|
|
|
681
693
|
const httpMSG = removeUndefinedKeys({
|
|
682
694
|
url,
|
|
683
|
-
method
|
|
684
|
-
params: defined(
|
|
685
|
-
data: defined(msg.data,
|
|
695
|
+
method,
|
|
696
|
+
params: defined(httpParams, method === 'GET' ? stringifyParams(httpBody) : undefined),
|
|
697
|
+
data: defined(msg.data, method !== 'GET' ? httpBody : undefined),
|
|
686
698
|
headers: {
|
|
687
699
|
...msg.headers,
|
|
688
700
|
...headers,
|
|
@@ -898,8 +910,8 @@ function asyncSend(msg) {
|
|
|
898
910
|
so we just wait for next message from lambda function
|
|
899
911
|
*/
|
|
900
912
|
|
|
901
|
-
const
|
|
902
|
-
if (
|
|
913
|
+
const cProcessStarted = getCurrentProcess(getState, started.processID);
|
|
914
|
+
if (cProcessStarted) {
|
|
903
915
|
local.dispatch(
|
|
904
916
|
updateWSProcess(started.processID, {
|
|
905
917
|
action: started.action,
|