@yousolution/node-red-contrib-you-sap-service-layer 0.1.1 → 0.2.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/CHANGELOG.md +14 -0
- package/docker-compose.yml +1 -1
- package/nodes/SQLQuery.js +6 -3
- package/nodes/authenticateSap.js +51 -8
- package/nodes/closeSap.js +7 -3
- package/nodes/createSQLQuery.js +6 -3
- package/nodes/createSap.js +8 -4
- package/nodes/crossJoinSap.js +6 -3
- package/nodes/deleteSap.js +6 -3
- package/nodes/getSap.js +6 -3
- package/nodes/listSap.js +6 -3
- package/nodes/manageErrors.js +39 -0
- package/nodes/manipulateEntitySap.js +6 -3
- package/nodes/patchSap.html +2 -2
- package/nodes/patchSap.js +6 -3
- package/nodes/serviceSap.js +6 -3
- package/nodes/support.js +21 -12
- package/package.json +8 -4
- package/resources/services.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [0.2.0] - 2024-06-19
|
|
6
|
+
|
|
7
|
+
> *Warning Breaking Change!* please make backups of flows and try in test environment before upgrading
|
|
8
|
+
|
|
9
|
+
- We have improved the management of login token expiration
|
|
10
|
+
- We have updated the manage dynamic login on AUTH Request
|
|
11
|
+
- We have updated the result handling in PATCH request
|
|
12
|
+
- We have resolved an error send Entry on UDT PATCH request
|
|
13
|
+
- We have updated the result handling in SERVICE request
|
|
14
|
+
- We have updated the error parsing function
|
|
15
|
+
- We Add Service "OrdersService_Preview" on SERVICE
|
|
16
|
+
- Bug Fix
|
|
17
|
+
- Library Axios & Odata Updated
|
|
18
|
+
|
|
5
19
|
# [0.1.1] - 2022-12-09
|
|
6
20
|
|
|
7
21
|
- Added label output to nextLink block
|
package/docker-compose.yml
CHANGED
package/nodes/SQLQuery.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
|
|
5
6
|
module.exports = function (RED) {
|
|
6
7
|
function SQLQuery(config) {
|
|
@@ -28,11 +29,13 @@ module.exports = function (RED) {
|
|
|
28
29
|
const options = { method: 'POST', hasRawQuery: false, isSQLQuery: true, data: data };
|
|
29
30
|
const login = Support.login;
|
|
30
31
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
31
|
-
msg.payload = result.data;
|
|
32
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
32
33
|
msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
|
|
33
34
|
msg.statusCode = result.status;
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if(msg.payload) {
|
|
36
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
37
|
+
node.send(msg);
|
|
38
|
+
}
|
|
36
39
|
} catch (error) {
|
|
37
40
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
38
41
|
done(error);
|
package/nodes/authenticateSap.js
CHANGED
|
@@ -22,15 +22,32 @@ module.exports = function (RED) {
|
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
if (!node.credentials.user || !node.credentials.
|
|
25
|
+
if (!node.credentials.user || !node.credentials.company) {
|
|
26
26
|
node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials' });
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
node.on('input', async (msg, send, done) => {
|
|
30
|
+
|
|
31
|
+
if(!node.credentials.password && !msg.password){
|
|
32
|
+
node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials Password Code' });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if(msg.password){
|
|
36
|
+
globalContext.set(`_YOU_SapServiceLayer_${node.id}.credentials.Password`, msg.password);
|
|
37
|
+
//node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials Password Code' });
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
// If Company setted from msg
|
|
31
41
|
if (node.credentials.companyType == 'msg') {
|
|
32
42
|
const company = msg[node.credentials.company];
|
|
43
|
+
let currentCompany = globalContext.get(`_YOU_SapServiceLayer_${node.id}.credentials.CompanyDB`);
|
|
44
|
+
|
|
45
|
+
if(company !== currentCompany) {
|
|
46
|
+
globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, null);
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
globalContext.set(`_YOU_SapServiceLayer_${node.id}.credentials.CompanyDB`, company);
|
|
50
|
+
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
// If User setted from msg
|
|
@@ -42,36 +59,62 @@ module.exports = function (RED) {
|
|
|
42
59
|
// reset status
|
|
43
60
|
node.status({});
|
|
44
61
|
|
|
45
|
-
if (!node.credentials.user || !node.credentials.
|
|
62
|
+
if (!node.credentials.user || !node.credentials.company) {
|
|
46
63
|
node.status({ fill: 'red', shape: 'dot', text: 'Missing credentials' });
|
|
47
64
|
done(new Error('Missing credentials'));
|
|
48
65
|
return;
|
|
49
66
|
}
|
|
50
67
|
|
|
68
|
+
let currentDate = new Date();
|
|
51
69
|
const headers = globalContext.get(`_YOU_SapServiceLayer_${node.id}.headers`);
|
|
70
|
+
const exipiredTime = globalContext.get(`_YOU_SapServiceLayer_${node.id}.exp`);
|
|
71
|
+
let validToken = true;
|
|
52
72
|
|
|
53
73
|
msg._YOU_SapServiceLayer = {
|
|
54
74
|
idAuth: node.id,
|
|
55
75
|
};
|
|
56
76
|
|
|
57
|
-
if
|
|
77
|
+
if(headers && exipiredTime) {
|
|
78
|
+
let providedDate = new Date(exipiredTime);
|
|
79
|
+
let timeDifference = currentDate - providedDate;
|
|
80
|
+
let minutesDifference = timeDifference / (1000 * 60);
|
|
81
|
+
validToken = minutesDifference > 25 ? false : true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
if (!headers || !validToken) {
|
|
58
86
|
try {
|
|
59
87
|
const result = await Support.login(node, node.id);
|
|
60
|
-
|
|
88
|
+
if(result.data.hasOwnProperty("error")) {
|
|
89
|
+
node.error( result.data.error , msg);
|
|
90
|
+
node.status({ fill: 'red', shape: 'dot', text: 'disconnected' });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, result.headers['set-cookie']);
|
|
94
|
+
globalContext.set(`_YOU_SapServiceLayer_${node.id}.exp`, currentDate.toISOString());
|
|
95
|
+
node.send(msg);
|
|
96
|
+
node.status({ fill: 'green', shape: 'dot', text: 'connected' });
|
|
97
|
+
}
|
|
98
|
+
// globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, result.headers['set-cookie']);
|
|
99
|
+
// globalContext.set(`_YOU_SapServiceLayer_${node.id}.exp`, currentDate.toISOString());
|
|
61
100
|
} catch (error) {
|
|
62
101
|
msg.payload = error;
|
|
63
102
|
if (error.response && error.response.data) {
|
|
64
103
|
msg.statusCode = error.response.status;
|
|
65
104
|
msg.payload = error.response.data;
|
|
66
105
|
}
|
|
67
|
-
node.
|
|
106
|
+
node.error( error , msg);
|
|
107
|
+
//node.send(msg);
|
|
68
108
|
node.status({ fill: 'red', shape: 'dot', text: 'disconnected' });
|
|
69
109
|
done(error);
|
|
70
|
-
return;
|
|
110
|
+
//return;
|
|
71
111
|
}
|
|
72
112
|
}
|
|
73
|
-
|
|
74
|
-
|
|
113
|
+
else {
|
|
114
|
+
node.send(msg);
|
|
115
|
+
node.status({ fill: 'green', shape: 'dot', text: 'connected' });
|
|
116
|
+
}
|
|
117
|
+
|
|
75
118
|
});
|
|
76
119
|
}
|
|
77
120
|
RED.nodes.registerType('authenticateSap', AuthenticateSapNode, {
|
package/nodes/closeSap.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
module.exports = function (RED) {
|
|
6
8
|
function CloseSapNode(config) {
|
|
@@ -18,10 +20,12 @@ module.exports = function (RED) {
|
|
|
18
20
|
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isClose: true };
|
|
19
21
|
const login = Support.login;
|
|
20
22
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
21
|
-
msg.payload = result.data;
|
|
23
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);// result.data;
|
|
22
24
|
msg.statusCode = result.status;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if(msg.payload) {
|
|
26
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
27
|
+
node.send(msg);
|
|
28
|
+
}
|
|
25
29
|
} catch (error) {
|
|
26
30
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
27
31
|
done(error);
|
package/nodes/createSQLQuery.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
|
|
5
6
|
module.exports = function (RED) {
|
|
6
7
|
function CreateSQLQuery(config) {
|
|
@@ -53,10 +54,12 @@ module.exports = function (RED) {
|
|
|
53
54
|
const options = { method: 'POST', hasRawQuery: false, isCreateSQLQuery: true, data: data };
|
|
54
55
|
const login = Support.login;
|
|
55
56
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
56
|
-
msg.payload = result;
|
|
57
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
57
58
|
msg.statusCode = result.status;
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if(msg.payload) {
|
|
60
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
61
|
+
node.send(msg);
|
|
62
|
+
}
|
|
60
63
|
} catch (error) {
|
|
61
64
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
62
65
|
done(error);
|
package/nodes/createSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
|
|
5
6
|
module.exports = function (RED) {
|
|
6
7
|
function CreateSapNode(config) {
|
|
@@ -22,13 +23,16 @@ module.exports = function (RED) {
|
|
|
22
23
|
const options = { method: 'POST', hasRawQuery: false, data: data };
|
|
23
24
|
const login = Support.login;
|
|
24
25
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
25
|
-
msg.payload = result;
|
|
26
|
+
msg.payload =VerifyErrorSL(node, msg, result.data);// result.data;
|
|
26
27
|
msg.statusCode = result.status;
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if(msg.payload) {
|
|
29
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
30
|
+
node.send(msg);
|
|
31
|
+
}
|
|
29
32
|
} catch (error) {
|
|
30
33
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
31
|
-
|
|
34
|
+
//node.error(error, msg);
|
|
35
|
+
// done(error);
|
|
32
36
|
}
|
|
33
37
|
});
|
|
34
38
|
}
|
package/nodes/crossJoinSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
// const buildQuery = require('odata-query').default;
|
|
5
6
|
|
|
6
7
|
module.exports = function (RED) {
|
|
@@ -19,11 +20,13 @@ module.exports = function (RED) {
|
|
|
19
20
|
const options = { method: 'GET', hasRawQuery: true, hasEntityId: false, isCrossJoin: true };
|
|
20
21
|
const login = Support.login;
|
|
21
22
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
22
|
-
msg.payload = result.data;
|
|
23
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);// result.data;
|
|
23
24
|
msg.statusCode = result.status;
|
|
24
25
|
msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if(msg.payload) {
|
|
27
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
28
|
+
node.send(msg);
|
|
29
|
+
}
|
|
27
30
|
} catch (error) {
|
|
28
31
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
29
32
|
done(error);
|
package/nodes/deleteSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
|
|
5
6
|
module.exports = function (RED) {
|
|
6
7
|
function DeleteSapNode(config) {
|
|
@@ -18,10 +19,12 @@ module.exports = function (RED) {
|
|
|
18
19
|
const options = { method: 'DELETE', hasRawQuery: true, hasEntityId: true, data: {} };
|
|
19
20
|
const login = Support.login;
|
|
20
21
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
21
|
-
msg.payload = result.data;
|
|
22
|
+
msg.payload = VerifyErrorSL(node, msg, result.data, true );// result.data;
|
|
22
23
|
msg.statusCode = result.status;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if(msg.payload) {
|
|
25
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
26
|
+
node.send(msg);
|
|
27
|
+
}
|
|
25
28
|
} catch (error) {
|
|
26
29
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
27
30
|
done(error);
|
package/nodes/getSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
// const buildQuery = require('odata-query').default;
|
|
5
6
|
|
|
6
7
|
module.exports = function (RED) {
|
|
@@ -17,10 +18,12 @@ module.exports = function (RED) {
|
|
|
17
18
|
const options = { method: 'GET', hasRawQuery: true, hasEntityId: true };
|
|
18
19
|
const login = Support.login;
|
|
19
20
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
20
|
-
msg.payload = result.data;
|
|
21
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
21
22
|
msg.statusCode = result.status;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
if(msg.payload) {
|
|
24
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
25
|
+
node.send(msg);
|
|
26
|
+
}
|
|
24
27
|
} catch (error) {
|
|
25
28
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
26
29
|
done(error);
|
package/nodes/listSap.js
CHANGED
|
@@ -2,6 +2,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
4
|
const buildQuery = require('odata-query').default;
|
|
5
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
5
6
|
|
|
6
7
|
module.exports = function (RED) {
|
|
7
8
|
function ListSapNode(config) {
|
|
@@ -19,11 +20,13 @@ module.exports = function (RED) {
|
|
|
19
20
|
const options = { method: 'GET', hasRawQuery: true };
|
|
20
21
|
const login = Support.login;
|
|
21
22
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
22
|
-
msg.payload = result.data;
|
|
23
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
23
24
|
msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
|
|
24
25
|
msg.statusCode = result.status;
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if(msg.payload) {
|
|
27
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
28
|
+
node.send(msg);
|
|
29
|
+
}
|
|
27
30
|
} catch (error) {
|
|
28
31
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
29
32
|
done(error);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
function VerifyErrorSL (node, msg, response, consentEmpty=false) {
|
|
3
|
+
if (!response.hasOwnProperty("success") && !response.hasOwnProperty("error") && !Object.keys(response).length && !consentEmpty) { // Error Generic
|
|
4
|
+
msg.payload = response;
|
|
5
|
+
node.error('Not Valid Requests', msg)
|
|
6
|
+
node.status({ fill: 'red', shape: 'dot', text: 'Not Valid Requests' });
|
|
7
|
+
}
|
|
8
|
+
else if(response.hasOwnProperty("error")){ //Error ServiceLayer
|
|
9
|
+
if(response.error.hasOwnProperty('message')){
|
|
10
|
+
if(response.error.message.hasOwnProperty('value')) {
|
|
11
|
+
msg.payload = response;
|
|
12
|
+
node.error(response.error.message.value, msg)
|
|
13
|
+
node.status({ fill: 'red', shape: 'dot', text: response.error.message.value });
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
msg.payload = response;
|
|
17
|
+
node.error(response.error.message , msg)
|
|
18
|
+
node.status({ fill: 'red', shape: 'dot', text: response.error.message });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
msg.payload = response;
|
|
23
|
+
node.error(response.reason , msg)
|
|
24
|
+
node.status({ fill: 'red', shape: 'dot', text: JSON.stringify(response) });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
else { // OK Response
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
VerifyErrorSL: VerifyErrorSL,
|
|
39
|
+
};
|
|
@@ -2,6 +2,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
4
|
const entities = require('../resources/entities.json');
|
|
5
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
5
6
|
|
|
6
7
|
module.exports = function (RED) {
|
|
7
8
|
function ManipulateEntitySap(config) {
|
|
@@ -24,10 +25,12 @@ module.exports = function (RED) {
|
|
|
24
25
|
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true, data: data };
|
|
25
26
|
const login = Support.login;
|
|
26
27
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
27
|
-
msg.payload = result.data;
|
|
28
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
28
29
|
msg.statusCode = result.status;
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if(msg.payload) {
|
|
31
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
32
|
+
node.send(msg);
|
|
33
|
+
}
|
|
31
34
|
} catch (error) {
|
|
32
35
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
33
36
|
done(error);
|
package/nodes/patchSap.html
CHANGED
|
@@ -339,12 +339,12 @@
|
|
|
339
339
|
</select>
|
|
340
340
|
</div>
|
|
341
341
|
|
|
342
|
-
<div class="form-row" style="display:none" id="container-
|
|
342
|
+
<div class="form-row" style="display:none" id="container-udo">
|
|
343
343
|
<label for="node-input-udo"><i class="fa fa-tag"></i> UDO</label>
|
|
344
344
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
345
345
|
</div>
|
|
346
346
|
|
|
347
|
-
<div class="form-row" style="display:none" id="container-
|
|
347
|
+
<div class="form-row" style="display:none" id="container-udt">
|
|
348
348
|
<label for="node-input-udt"><i class="fa fa-tag"></i> UDT</label>
|
|
349
349
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
350
350
|
</div>
|
package/nodes/patchSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
|
|
5
6
|
module.exports = function (RED) {
|
|
6
7
|
function PatchSapNode(config) {
|
|
@@ -23,10 +24,12 @@ module.exports = function (RED) {
|
|
|
23
24
|
const options = { method: 'PATCH', hasRawQuery: false, hasEntityId: true, data: data };
|
|
24
25
|
const login = Support.login;
|
|
25
26
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
26
|
-
msg.payload = result.data;
|
|
27
|
+
msg.payload = VerifyErrorSL(node, msg, result.data, true);//result.data;
|
|
27
28
|
msg.statusCode = result.status;
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if(msg.payload) {
|
|
30
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
31
|
+
node.send(msg);
|
|
32
|
+
}
|
|
30
33
|
} catch (error) {
|
|
31
34
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
32
35
|
done(error);
|
package/nodes/serviceSap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const Support = require('./support');
|
|
4
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
4
5
|
const services = require('../resources/services.json');
|
|
5
6
|
|
|
6
7
|
module.exports = function (RED) {
|
|
@@ -23,10 +24,12 @@ module.exports = function (RED) {
|
|
|
23
24
|
const options = { method: 'POST', hasRawQuery: false, isService: true, data: data };
|
|
24
25
|
const login = Support.login;
|
|
25
26
|
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
26
|
-
msg.payload = result;
|
|
27
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
27
28
|
msg.statusCode = result.status;
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if(msg.payload) {
|
|
30
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
31
|
+
node.send(msg);
|
|
32
|
+
}
|
|
30
33
|
} catch (error) {
|
|
31
34
|
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
32
35
|
done(error);
|
package/nodes/support.js
CHANGED
|
@@ -7,6 +7,7 @@ const thickIdApi = [
|
|
|
7
7
|
'AssetClasses',
|
|
8
8
|
'AssetDepreciationGroups',
|
|
9
9
|
'AssetGroups',
|
|
10
|
+
'AlternateCatNum',
|
|
10
11
|
'BankChargesAllocationCodes',
|
|
11
12
|
'BusinessPartners',
|
|
12
13
|
'CampaignResponseType',
|
|
@@ -83,12 +84,7 @@ async function login(node, idAuth) {
|
|
|
83
84
|
'Content-Length': dataString.length,
|
|
84
85
|
},
|
|
85
86
|
};
|
|
86
|
-
|
|
87
|
-
// try {
|
|
88
87
|
return await axiosLibrary(options);
|
|
89
|
-
// } catch (error) {
|
|
90
|
-
// throw Error(`ERROR FUNCTION LOGIN: ${error}`);
|
|
91
|
-
// }
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
@@ -124,10 +120,13 @@ async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
|
124
120
|
msg.statusCode = error.response.status;
|
|
125
121
|
msg.payload = error.response.data;
|
|
126
122
|
msg.requestUrl = requestOptions.axiosOptions.url;
|
|
127
|
-
node.send(msg);
|
|
128
|
-
|
|
123
|
+
//node.send(msg);
|
|
124
|
+
node.error(JSON.stringify(error.response.data), msg);
|
|
125
|
+
//throw new Error(JSON.stringify(error.response.data));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw error;
|
|
129
129
|
}
|
|
130
|
-
throw error;
|
|
131
130
|
}
|
|
132
131
|
// }
|
|
133
132
|
}
|
|
@@ -135,10 +134,14 @@ async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
|
135
134
|
msg.statusCode = error.response.status;
|
|
136
135
|
msg.payload = error.response.data;
|
|
137
136
|
msg.requestUrl = requestOptions.axiosOptions.url;
|
|
138
|
-
node.send(msg);
|
|
139
|
-
|
|
137
|
+
//node.send(msg);
|
|
138
|
+
node.error(JSON.stringify(error.response.data), msg)
|
|
139
|
+
// throw new Error(JSON.stringify(error.response.data));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw error;
|
|
140
143
|
}
|
|
141
|
-
|
|
144
|
+
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -252,7 +255,13 @@ function generateRequest(node, msg, config, options) {
|
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
if (thickIdApi.includes(entity) || config.entity === 'UDT') {
|
|
255
|
-
|
|
258
|
+
if(Number.isInteger(entityId)){
|
|
259
|
+
url = `https://${host}:${port}/b1s/${version}/${entity}(${entityId})`;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
url = `https://${host}:${port}/b1s/${version}/${entity}('${entityId}')`;
|
|
263
|
+
}
|
|
264
|
+
|
|
256
265
|
} else {
|
|
257
266
|
url = `https://${host}:${port}/b1s/${version}/${entity}(${entityId})`;
|
|
258
267
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yousolution/node-red-contrib-you-sap-service-layer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Unofficial module SAP Service Layer for NODE-RED",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"update": "
|
|
7
|
+
"update": "run-script-os",
|
|
8
|
+
"update:linux:darwin": "npm pack && mv yousolution-node-red-contrib-you-sap-service-layer-$npm_package_version.tgz ./data && cd data && npm i yousolution-node-red-contrib-you-sap-service-layer-$npm_package_version.tgz && docker-compose restart",
|
|
9
|
+
"update:win32": "npm pack && copy yousolution-node-red-contrib-you-sap-service-layer-%npm_package_version%.tgz .\\data\\ && cd .\\data\\ && npm i yousolution-node-red-contrib-you-sap-service-layer-%npm_package_version%.tgz && docker-compose restart",
|
|
10
|
+
"update:default": "npm pack && mv yousolution-node-red-contrib-you-sap-service-layer-$npm_package_version.tgz ./data && cd data && npm i yousolution-node-red-contrib-you-sap-service-layer-$npm_package_version.tgz && docker-compose restart",
|
|
8
11
|
"test": "mocha 'test/**/*.spec.js'",
|
|
9
12
|
"coverage": "nyc npm run test"
|
|
10
13
|
},
|
|
@@ -37,8 +40,8 @@
|
|
|
37
40
|
}
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"axios": "^
|
|
41
|
-
"odata-query": "^
|
|
43
|
+
"axios": "^1.2.2",
|
|
44
|
+
"odata-query": "^7.0.4"
|
|
42
45
|
},
|
|
43
46
|
"repository": {
|
|
44
47
|
"type": "git",
|
|
@@ -56,6 +59,7 @@
|
|
|
56
59
|
"node-red": "^2.1.4",
|
|
57
60
|
"node-red-node-test-helper": "^0.2.7",
|
|
58
61
|
"nyc": "^15.1.0",
|
|
62
|
+
"run-script-os": "^1.1.6",
|
|
59
63
|
"sinon": "^12.0.1"
|
|
60
64
|
}
|
|
61
65
|
}
|
package/resources/services.json
CHANGED
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
"NFModelsService": ["NFModelsService_GetList"],
|
|
201
201
|
"NFTaxCategoriesService": ["NFTaxCategoriesService_GetList"],
|
|
202
202
|
"OccurrenceCodesService": ["OccurrenceCodesService_GetList"],
|
|
203
|
-
"OrdersService": ["OrdersService_GetApprovalTemplates", "OrdersService_HandleApprovalRequest"],
|
|
203
|
+
"OrdersService": ["OrdersService_GetApprovalTemplates", "OrdersService_Preview" ,"OrdersService_HandleApprovalRequest"],
|
|
204
204
|
"PartnersSetupsService": ["PartnersSetupsService_GetList"],
|
|
205
205
|
"PaymentBlocksService": ["PaymentBlocksService_GetPaymentBlockList"],
|
|
206
206
|
"PaymentCalculationService": ["PaymentCalculationService_GetPaymentAmount"],
|