@yousolution/node-red-contrib-you-sap-service-layer 0.2.7 → 0.2.9
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 +8 -0
- package/nodes/authenticateSap.js +9 -1
- package/nodes/serviceSap.html +10 -1
- package/nodes/serviceSap.js +25 -7
- package/nodes/support.js +15 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [0.2.9] - 2025-02-19
|
|
6
|
+
|
|
7
|
+
- Added Manage Dynamic User on Autentication Service Layer
|
|
8
|
+
|
|
9
|
+
# [0.2.8] - 2025-01-22
|
|
10
|
+
|
|
11
|
+
- Added error handling configuration from library or manual on ServiceSAP Node
|
|
12
|
+
|
|
5
13
|
# [0.2.7] - 2025-01-22
|
|
6
14
|
|
|
7
15
|
- Change Manage Error ServiceLayer on ServiceSAP Node
|
package/nodes/authenticateSap.js
CHANGED
|
@@ -50,9 +50,17 @@ module.exports = function (RED) {
|
|
|
50
50
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
//If User setted from msg
|
|
54
55
|
if (node.credentials.userType == 'msg') {
|
|
55
56
|
const user = msg[node.credentials.user];
|
|
57
|
+
let currentUser = globalContext.get(`_YOU_SapServiceLayer_${node.id}.credentials.UserName`);
|
|
58
|
+
|
|
59
|
+
if(user !== currentUser) {
|
|
60
|
+
console.log('Reset User');
|
|
61
|
+
globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, null);
|
|
62
|
+
}
|
|
63
|
+
|
|
56
64
|
globalContext.set(`_YOU_SapServiceLayer_${node.id}.credentials.UserName`, user);
|
|
57
65
|
}
|
|
58
66
|
|
package/nodes/serviceSap.html
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
serviceName: {value: ''},
|
|
16
16
|
service: {value: ''},
|
|
17
17
|
headers: {value: ''},
|
|
18
|
-
bodyPost: {value: ''}
|
|
18
|
+
bodyPost: {value: ''},
|
|
19
|
+
manageError: {value: true}
|
|
19
20
|
},
|
|
20
21
|
inputs:1,
|
|
21
22
|
outputs:1,
|
|
@@ -105,6 +106,10 @@
|
|
|
105
106
|
<input type="text" id="node-input-bodyPost">
|
|
106
107
|
<input type="hidden" id="node-input-bodyPost-type">
|
|
107
108
|
</div>
|
|
109
|
+
<div class="form-row">
|
|
110
|
+
<label for="node-input-type"><i class="fa fa-cog"></i> Manage Error</label>
|
|
111
|
+
<input type="checkbox" id="node-input-manageError">
|
|
112
|
+
</div>
|
|
108
113
|
</script>
|
|
109
114
|
|
|
110
115
|
<!-- Documentation -->
|
|
@@ -129,6 +134,10 @@
|
|
|
129
134
|
<span class="property-type">object</span>
|
|
130
135
|
</dt>
|
|
131
136
|
<dd> data to update to the entity </dd>
|
|
137
|
+
<dt>MangerError
|
|
138
|
+
<span class="property-type">Bool</span>
|
|
139
|
+
</dt>
|
|
140
|
+
<dd> Set Manage Error Respone on Library</dd>
|
|
132
141
|
</dl>
|
|
133
142
|
|
|
134
143
|
<h3>Outputs</h3>
|
package/nodes/serviceSap.js
CHANGED
|
@@ -18,16 +18,34 @@ module.exports = function (RED) {
|
|
|
18
18
|
const data = msg[config.bodyPost];
|
|
19
19
|
const options = { method: 'POST', hasRawQuery: false, isService: true, data: data };
|
|
20
20
|
const login = Support.login;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
|
|
22
|
+
const result = await Support.sendRequest({ node, msg, config, axios, login, options }, config.manageError);
|
|
23
|
+
if(config.manageError) {
|
|
24
|
+
msg.payload = VerifyErrorSL(node, msg, result.data, true);//result.data;
|
|
25
|
+
msg.statusCode = result.status;
|
|
26
|
+
if(result.status < 299) {
|
|
27
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
28
|
+
node.send(msg);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
msg.payload = result;
|
|
33
|
+
node.status({ fill: 'gray', shape: 'dot', text: 'Response Request' });
|
|
26
34
|
node.send(msg);
|
|
27
35
|
}
|
|
36
|
+
|
|
28
37
|
} catch (error) {
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
if(!config.manageError) {
|
|
39
|
+
msg.payload = result;
|
|
40
|
+
node.status({ fill: 'gray', shape: 'dot', text: 'Response Request' });
|
|
41
|
+
node.send(msg);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
45
|
+
done(error);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
31
49
|
}
|
|
32
50
|
});
|
|
33
51
|
}
|
package/nodes/support.js
CHANGED
|
@@ -87,7 +87,7 @@ async function login(node, idAuth) {
|
|
|
87
87
|
return await axiosLibrary(options);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
90
|
+
async function sendRequest({ node, msg, config, axios, login, options }, manageError=true) {
|
|
91
91
|
if (!node || !msg || !config || !axios || !login) {
|
|
92
92
|
const missingParams = [];
|
|
93
93
|
node ? null : missingParams.push('node');
|
|
@@ -102,7 +102,13 @@ async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
|
102
102
|
return await axios(requestOptions.axiosOptions);
|
|
103
103
|
} catch (error) {
|
|
104
104
|
// Refresh headers re-login
|
|
105
|
-
if
|
|
105
|
+
if(!manageError){
|
|
106
|
+
msg.statusCode = error.response.status;
|
|
107
|
+
msg.requestUrl = requestOptions.axiosOptions.url;
|
|
108
|
+
msg.payload = error.response.data;
|
|
109
|
+
return error.response.data;
|
|
110
|
+
}
|
|
111
|
+
else if (error.response && (error.response.status == 401 || error.response.status == 301)) {
|
|
106
112
|
const globalCotext = node.context().global;
|
|
107
113
|
// try {
|
|
108
114
|
// update cookies for session timeout
|
|
@@ -130,12 +136,16 @@ async function sendRequest({ node, msg, config, axios, login, options }) {
|
|
|
130
136
|
}
|
|
131
137
|
// }
|
|
132
138
|
}
|
|
133
|
-
if (error.response && error.response.data) {
|
|
139
|
+
else if (error.response && error.response.data) {
|
|
134
140
|
msg.statusCode = error.response.status;
|
|
135
141
|
msg.payload = error.response.data;
|
|
136
142
|
msg.requestUrl = requestOptions.axiosOptions.url;
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
if(!manageError){
|
|
144
|
+
node.send(msg);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
node.error(JSON.stringify(error.response.data), msg)
|
|
148
|
+
}
|
|
139
149
|
// throw new Error(JSON.stringify(error.response.data));
|
|
140
150
|
}
|
|
141
151
|
else {
|