@yousolution/node-red-contrib-you-sap-service-layer 0.2.2 → 0.2.4
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/.prettierrc +6 -6
- package/.vscode/launch.json +23 -23
- package/CHANGELOG.md +61 -52
- package/README.md +126 -126
- package/docker-compose.yml +14 -14
- package/examples/example.json +625 -625
- package/nodes/SQLQuery.html +179 -179
- package/nodes/SQLQuery.js +46 -46
- package/nodes/authenticateSap.html +146 -146
- package/nodes/authenticateSap.js +129 -129
- package/nodes/closeSap.html +128 -97
- package/nodes/closeSap.js +36 -36
- package/nodes/createSQLQuery.html +165 -165
- package/nodes/createSQLQuery.js +70 -70
- package/nodes/createSap.html +391 -391
- package/nodes/createSap.js +40 -40
- package/nodes/crossJoinSap.html +394 -394
- package/nodes/crossJoinSap.js +37 -37
- package/nodes/deleteSap.html +406 -406
- package/nodes/deleteSap.js +35 -35
- package/nodes/getSap.html +427 -427
- package/nodes/getSap.js +34 -34
- package/nodes/listSap.html +402 -402
- package/nodes/listSap.js +37 -37
- package/nodes/manageErrors.js +38 -38
- package/nodes/manipulateEntitySap.html +176 -176
- package/nodes/manipulateEntitySap.js +46 -46
- package/nodes/nextLink.html +100 -100
- package/nodes/nextLink.js +18 -18
- package/nodes/patchSap.html +424 -424
- package/nodes/patchSap.js +40 -40
- package/nodes/serviceSap.html +160 -206
- package/nodes/serviceSap.js +39 -39
- package/nodes/support.js +363 -363
- package/package.json +65 -65
- package/resources/entities.json +59 -59
- package/resources/services.json +343 -343
- package/test/authenticateSap.spec.js +307 -307
- package/test/closeSap.spec.js +156 -156
- package/test/createSQLQuery.spec.js +174 -174
- package/test/createSap.spec.js +183 -183
- package/test/crossJoinSap.spec.js +156 -156
- package/test/deleteSap.spec.js +156 -156
- package/test/getSap.spec.js +156 -156
- package/test/listSap.spec.js +156 -156
- package/test/manipulateEntitySap.spec.js +191 -191
- package/test/patchSap.spec.js +184 -184
- package/test/serviceSap.spec.js +170 -170
- package/test/support.spec.js +1419 -1419
- package/data/.gitkeep +0 -0
package/nodes/listSap.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const Support = require('./support');
|
|
4
|
-
const buildQuery = require('odata-query').default;
|
|
5
|
-
const { VerifyErrorSL } = require('./manageErrors');
|
|
6
|
-
|
|
7
|
-
module.exports = function (RED) {
|
|
8
|
-
function ListSapNode(config) {
|
|
9
|
-
RED.nodes.createNode(this, config);
|
|
10
|
-
const node = this;
|
|
11
|
-
|
|
12
|
-
// reset status
|
|
13
|
-
node.status({});
|
|
14
|
-
|
|
15
|
-
node.on('input', async (msg, send, done) => {
|
|
16
|
-
// reset status
|
|
17
|
-
node.status({});
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const options = { method: 'GET', hasRawQuery: true };
|
|
21
|
-
const login = Support.login;
|
|
22
|
-
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
23
|
-
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
24
|
-
msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
|
|
25
|
-
msg.statusCode = result.status;
|
|
26
|
-
if(msg.payload) {
|
|
27
|
-
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
28
|
-
node.send(msg);
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
32
|
-
done(error);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
RED.nodes.registerType('listSap', ListSapNode, {});
|
|
37
|
-
};
|
|
1
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
const Support = require('./support');
|
|
4
|
+
const buildQuery = require('odata-query').default;
|
|
5
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function ListSapNode(config) {
|
|
9
|
+
RED.nodes.createNode(this, config);
|
|
10
|
+
const node = this;
|
|
11
|
+
|
|
12
|
+
// reset status
|
|
13
|
+
node.status({});
|
|
14
|
+
|
|
15
|
+
node.on('input', async (msg, send, done) => {
|
|
16
|
+
// reset status
|
|
17
|
+
node.status({});
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const options = { method: 'GET', hasRawQuery: true };
|
|
21
|
+
const login = Support.login;
|
|
22
|
+
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
23
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
24
|
+
msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
|
|
25
|
+
msg.statusCode = result.status;
|
|
26
|
+
if(msg.payload) {
|
|
27
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
28
|
+
node.send(msg);
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
32
|
+
done(error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
RED.nodes.registerType('listSap', ListSapNode, {});
|
|
37
|
+
};
|
package/nodes/manageErrors.js
CHANGED
|
@@ -1,39 +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,
|
|
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
39
|
};
|
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
<script type="text/javascript">
|
|
2
|
-
let
|
|
3
|
-
let
|
|
4
|
-
$.getJSON('entities', (data, status) => {
|
|
5
|
-
for(entity in data) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
RED.nodes.registerType('manipulateEntitySap',{
|
|
11
|
-
category: 'Sap',
|
|
12
|
-
color: '#FFC300',
|
|
13
|
-
defaults: {
|
|
14
|
-
name: {value: ''},
|
|
15
|
-
entity: {value: ''},
|
|
16
|
-
manipulateMethod: {value: ''},
|
|
17
|
-
entityId: {value: ''},
|
|
18
|
-
headers: {value: ''},
|
|
19
|
-
bodyPost: {value: ''}
|
|
20
|
-
},
|
|
21
|
-
inputs:1,
|
|
22
|
-
outputs:1,
|
|
23
|
-
icon: 'font-awesome/fa-pencil-square',
|
|
24
|
-
label: function() {
|
|
25
|
-
return this.name||"Sap manipulate entity";
|
|
26
|
-
},
|
|
27
|
-
oneditprepare: function() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
$('#node-input-entity')
|
|
31
|
-
.append($("<option></option>")
|
|
32
|
-
.attr("value", entity)
|
|
33
|
-
.text(entity));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// set the previous value
|
|
37
|
-
if(this.entity) {
|
|
38
|
-
$('#node-input-entity').val(this.entity);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
$("#node-input-entity").change((event) => {
|
|
43
|
-
const entity = $("#node-input-entity").val();
|
|
44
|
-
|
|
45
|
-
$('#node-input-manipulateMethod').empty();
|
|
46
|
-
|
|
47
|
-
if(
|
|
48
|
-
|
|
49
|
-
$('#node-input-manipulateMethod')
|
|
50
|
-
.append($("<option></option>")
|
|
51
|
-
.attr("value", endpoint)
|
|
52
|
-
.text(endpoint));
|
|
53
|
-
});
|
|
54
|
-
// trick check if change with click or not
|
|
55
|
-
if(!event.originalEvent){
|
|
56
|
-
$('#node-input-manipulateMethod').val(this.manipulateMethod);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
$("#node-input-entityId").typedInput({
|
|
63
|
-
type:"msg",
|
|
64
|
-
types:["msg"],
|
|
65
|
-
typeField: "#node-input-entityId-type",
|
|
66
|
-
value: 'entityId'
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
$("#node-input-headers").typedInput({
|
|
70
|
-
type:"msg",
|
|
71
|
-
types:["msg"],
|
|
72
|
-
typeField: "#node-input-headers-type",
|
|
73
|
-
value: 'headers'
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
$("#node-input-bodyPost").typedInput({
|
|
77
|
-
type:"msg",
|
|
78
|
-
types:["msg"],
|
|
79
|
-
typeField: "#node-input-bodyPost-type",
|
|
80
|
-
value: 'bodyPost'
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<script type="text/html" data-template-name="manipulateEntitySap">
|
|
89
|
-
<div class="form-row">
|
|
90
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
91
|
-
<input type="text" id="node-input-name" placeholder="Name">
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<div class="form-row">
|
|
95
|
-
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
96
|
-
<select name="node-input-entity" id="node-input-entity">
|
|
97
|
-
<option></option>
|
|
98
|
-
</select>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<div class="form-row">
|
|
102
|
-
<label for="node-input-type"><i class="fa fa-gears"></i> Method</label>
|
|
103
|
-
<select name="node-input-manipulateMethod" id="node-input-manipulateMethod">
|
|
104
|
-
</select>
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
<div class="form-row" id="container-entityId">
|
|
108
|
-
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
109
|
-
<input type="text" id="node-input-entityId">
|
|
110
|
-
<input type="hidden" id="node-input-entityId-type">
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<div class="form-row">
|
|
114
|
-
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
115
|
-
<input type="text" id="node-input-headers">
|
|
116
|
-
<input type="hidden" id="node-input-headers-type">
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<div class="form-row">
|
|
120
|
-
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPost</label>
|
|
121
|
-
<input type="text" id="node-input-bodyPost">
|
|
122
|
-
<input type="hidden" id="node-input-bodyPost-type">
|
|
123
|
-
</div>
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<!-- Documentation -->
|
|
127
|
-
<script type="text/html" data-help-name="manipulateEntitySap">
|
|
128
|
-
<p>Manipulate action</p>
|
|
129
|
-
|
|
130
|
-
<h3>Inputs</h3>
|
|
131
|
-
<dl class="message-properties">
|
|
132
|
-
<dt>Name
|
|
133
|
-
<span class="property-type">string</span>
|
|
134
|
-
</dt>
|
|
135
|
-
<dd> the node's name </dd>
|
|
136
|
-
<dt>Entity
|
|
137
|
-
<span class="property-type">string</span>
|
|
138
|
-
</dt>
|
|
139
|
-
<dd> the entity name of SAP </dd>
|
|
140
|
-
<dt>entityId
|
|
141
|
-
<span class="property-type">number | string</span>
|
|
142
|
-
</dt>
|
|
143
|
-
<dd> the id of the entity of SAP </dd>
|
|
144
|
-
<dt>bodyPost
|
|
145
|
-
<span class="property-type">object</span>
|
|
146
|
-
</dt>
|
|
147
|
-
<dd> data to update to the entity </dd>
|
|
148
|
-
</dl>
|
|
149
|
-
|
|
150
|
-
<h3>Outputs</h3>
|
|
151
|
-
<ol class="node-ports">
|
|
152
|
-
<li>Standard output
|
|
153
|
-
<dl class="message-properties">
|
|
154
|
-
<dt>payload <span class="property-type">string</span></dt>
|
|
155
|
-
<dd>the standard output of the command.</dd>
|
|
156
|
-
</dl>
|
|
157
|
-
</li>
|
|
158
|
-
</ol>
|
|
159
|
-
|
|
160
|
-
<h3>Details</h3>
|
|
161
|
-
<p>this node is used to update the entity of SAP.
|
|
162
|
-
See the examples to understand how to use it.
|
|
163
|
-
</p>
|
|
164
|
-
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
165
|
-
If it contains an Object it will be converted to a JSON string before being sent.
|
|
166
|
-
If it contains a binary Buffer the message will be published as-is.</p>
|
|
167
|
-
<p>The topic used can be configured in the node or, if left blank, can be set
|
|
168
|
-
by <code>msg.topic</code>.</p>
|
|
169
|
-
<p>Likewise the QoS and retain values can be configured in the node or, if left
|
|
170
|
-
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
|
|
171
|
-
|
|
172
|
-
<h3>References</h3>
|
|
173
|
-
<ul>
|
|
174
|
-
<li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
|
|
175
|
-
<li><a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer">@yousolution-cloud/node-red-contrib-you-sap-service-layer</a> - the nodes github repository</li>
|
|
176
|
-
</ul>
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
let SAPSLentities = [];
|
|
3
|
+
let SAPSLentitiesData = {};
|
|
4
|
+
$.getJSON('entities', (data, status) => {
|
|
5
|
+
for(entity in data) {
|
|
6
|
+
SAPSLentitiesData = data;
|
|
7
|
+
SAPSLentities.push(entity);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
RED.nodes.registerType('manipulateEntitySap',{
|
|
11
|
+
category: 'Sap',
|
|
12
|
+
color: '#FFC300',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: {value: ''},
|
|
15
|
+
entity: {value: ''},
|
|
16
|
+
manipulateMethod: {value: ''},
|
|
17
|
+
entityId: {value: ''},
|
|
18
|
+
headers: {value: ''},
|
|
19
|
+
bodyPost: {value: ''}
|
|
20
|
+
},
|
|
21
|
+
inputs:1,
|
|
22
|
+
outputs:1,
|
|
23
|
+
icon: 'font-awesome/fa-pencil-square',
|
|
24
|
+
label: function() {
|
|
25
|
+
return this.name||"Sap manipulate entity";
|
|
26
|
+
},
|
|
27
|
+
oneditprepare: function() {
|
|
28
|
+
|
|
29
|
+
SAPSLentities.forEach((entity) => {
|
|
30
|
+
$('#node-input-entity')
|
|
31
|
+
.append($("<option></option>")
|
|
32
|
+
.attr("value", entity)
|
|
33
|
+
.text(entity));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// set the previous value
|
|
37
|
+
if(this.entity) {
|
|
38
|
+
$('#node-input-entity').val(this.entity);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
$("#node-input-entity").change((event) => {
|
|
43
|
+
const entity = $("#node-input-entity").val();
|
|
44
|
+
|
|
45
|
+
$('#node-input-manipulateMethod').empty();
|
|
46
|
+
|
|
47
|
+
if(SAPSLentitiesData[entity]) {
|
|
48
|
+
SAPSLentitiesData[entity].forEach((endpoint) => {
|
|
49
|
+
$('#node-input-manipulateMethod')
|
|
50
|
+
.append($("<option></option>")
|
|
51
|
+
.attr("value", endpoint)
|
|
52
|
+
.text(endpoint));
|
|
53
|
+
});
|
|
54
|
+
// trick check if change with click or not
|
|
55
|
+
if(!event.originalEvent){
|
|
56
|
+
$('#node-input-manipulateMethod').val(this.manipulateMethod);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
$("#node-input-entityId").typedInput({
|
|
63
|
+
type:"msg",
|
|
64
|
+
types:["msg"],
|
|
65
|
+
typeField: "#node-input-entityId-type",
|
|
66
|
+
value: 'entityId'
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
$("#node-input-headers").typedInput({
|
|
70
|
+
type:"msg",
|
|
71
|
+
types:["msg"],
|
|
72
|
+
typeField: "#node-input-headers-type",
|
|
73
|
+
value: 'headers'
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$("#node-input-bodyPost").typedInput({
|
|
77
|
+
type:"msg",
|
|
78
|
+
types:["msg"],
|
|
79
|
+
typeField: "#node-input-bodyPost-type",
|
|
80
|
+
value: 'bodyPost'
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<script type="text/html" data-template-name="manipulateEntitySap">
|
|
89
|
+
<div class="form-row">
|
|
90
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
91
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="form-row">
|
|
95
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
96
|
+
<select name="node-input-entity" id="node-input-entity">
|
|
97
|
+
<option></option>
|
|
98
|
+
</select>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div class="form-row">
|
|
102
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Method</label>
|
|
103
|
+
<select name="node-input-manipulateMethod" id="node-input-manipulateMethod">
|
|
104
|
+
</select>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div class="form-row" id="container-entityId">
|
|
108
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
109
|
+
<input type="text" id="node-input-entityId">
|
|
110
|
+
<input type="hidden" id="node-input-entityId-type">
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<div class="form-row">
|
|
114
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
115
|
+
<input type="text" id="node-input-headers">
|
|
116
|
+
<input type="hidden" id="node-input-headers-type">
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div class="form-row">
|
|
120
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPost</label>
|
|
121
|
+
<input type="text" id="node-input-bodyPost">
|
|
122
|
+
<input type="hidden" id="node-input-bodyPost-type">
|
|
123
|
+
</div>
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<!-- Documentation -->
|
|
127
|
+
<script type="text/html" data-help-name="manipulateEntitySap">
|
|
128
|
+
<p>Manipulate action</p>
|
|
129
|
+
|
|
130
|
+
<h3>Inputs</h3>
|
|
131
|
+
<dl class="message-properties">
|
|
132
|
+
<dt>Name
|
|
133
|
+
<span class="property-type">string</span>
|
|
134
|
+
</dt>
|
|
135
|
+
<dd> the node's name </dd>
|
|
136
|
+
<dt>Entity
|
|
137
|
+
<span class="property-type">string</span>
|
|
138
|
+
</dt>
|
|
139
|
+
<dd> the entity name of SAP </dd>
|
|
140
|
+
<dt>entityId
|
|
141
|
+
<span class="property-type">number | string</span>
|
|
142
|
+
</dt>
|
|
143
|
+
<dd> the id of the entity of SAP </dd>
|
|
144
|
+
<dt>bodyPost
|
|
145
|
+
<span class="property-type">object</span>
|
|
146
|
+
</dt>
|
|
147
|
+
<dd> data to update to the entity </dd>
|
|
148
|
+
</dl>
|
|
149
|
+
|
|
150
|
+
<h3>Outputs</h3>
|
|
151
|
+
<ol class="node-ports">
|
|
152
|
+
<li>Standard output
|
|
153
|
+
<dl class="message-properties">
|
|
154
|
+
<dt>payload <span class="property-type">string</span></dt>
|
|
155
|
+
<dd>the standard output of the command.</dd>
|
|
156
|
+
</dl>
|
|
157
|
+
</li>
|
|
158
|
+
</ol>
|
|
159
|
+
|
|
160
|
+
<h3>Details</h3>
|
|
161
|
+
<p>this node is used to update the entity of SAP.
|
|
162
|
+
See the examples to understand how to use it.
|
|
163
|
+
</p>
|
|
164
|
+
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
165
|
+
If it contains an Object it will be converted to a JSON string before being sent.
|
|
166
|
+
If it contains a binary Buffer the message will be published as-is.</p>
|
|
167
|
+
<p>The topic used can be configured in the node or, if left blank, can be set
|
|
168
|
+
by <code>msg.topic</code>.</p>
|
|
169
|
+
<p>Likewise the QoS and retain values can be configured in the node or, if left
|
|
170
|
+
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
|
|
171
|
+
|
|
172
|
+
<h3>References</h3>
|
|
173
|
+
<ul>
|
|
174
|
+
<li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
|
|
175
|
+
<li><a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer">@yousolution-cloud/node-red-contrib-you-sap-service-layer</a> - the nodes github repository</li>
|
|
176
|
+
</ul>
|
|
177
177
|
</script>
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const Support = require('./support');
|
|
4
|
-
const entities = require('../resources/entities.json');
|
|
5
|
-
const { VerifyErrorSL } = require('./manageErrors');
|
|
6
|
-
|
|
7
|
-
module.exports = function (RED) {
|
|
8
|
-
function ManipulateEntitySap(config) {
|
|
9
|
-
RED.nodes.createNode(this, config);
|
|
10
|
-
const node = this;
|
|
11
|
-
|
|
12
|
-
// reset status
|
|
13
|
-
node.status({});
|
|
14
|
-
|
|
15
|
-
node.on('input', async (msg, send, done) => {
|
|
16
|
-
// reset status
|
|
17
|
-
node.status({});
|
|
18
|
-
try {
|
|
19
|
-
const data = msg[config.bodyPost];
|
|
20
|
-
// if (!data) {
|
|
21
|
-
// node.status({ fill: 'red', shape: 'dot', text: 'bodyPatch must have value' });
|
|
22
|
-
// done(new Error('bodyPatch must have value'));
|
|
23
|
-
// return;
|
|
24
|
-
// }
|
|
25
|
-
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true, data: data };
|
|
26
|
-
const login = Support.login;
|
|
27
|
-
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
28
|
-
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
29
|
-
msg.statusCode = result.status;
|
|
30
|
-
if(msg.payload) {
|
|
31
|
-
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
32
|
-
node.send(msg);
|
|
33
|
-
}
|
|
34
|
-
} catch (error) {
|
|
35
|
-
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
36
|
-
done(error);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
RED.httpAdmin.get('/entities', RED.auth.needsPermission('manipulateEntitySap.read'), (req, res) => {
|
|
42
|
-
console.log('entities');
|
|
43
|
-
res.json(entities);
|
|
44
|
-
});
|
|
45
|
-
RED.nodes.registerType('manipulateEntitySap', ManipulateEntitySap, {});
|
|
46
|
-
};
|
|
1
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
const Support = require('./support');
|
|
4
|
+
const entities = require('../resources/entities.json');
|
|
5
|
+
const { VerifyErrorSL } = require('./manageErrors');
|
|
6
|
+
|
|
7
|
+
module.exports = function (RED) {
|
|
8
|
+
function ManipulateEntitySap(config) {
|
|
9
|
+
RED.nodes.createNode(this, config);
|
|
10
|
+
const node = this;
|
|
11
|
+
|
|
12
|
+
// reset status
|
|
13
|
+
node.status({});
|
|
14
|
+
|
|
15
|
+
node.on('input', async (msg, send, done) => {
|
|
16
|
+
// reset status
|
|
17
|
+
node.status({});
|
|
18
|
+
try {
|
|
19
|
+
const data = msg[config.bodyPost];
|
|
20
|
+
// if (!data) {
|
|
21
|
+
// node.status({ fill: 'red', shape: 'dot', text: 'bodyPatch must have value' });
|
|
22
|
+
// done(new Error('bodyPatch must have value'));
|
|
23
|
+
// return;
|
|
24
|
+
// }
|
|
25
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true, data: data };
|
|
26
|
+
const login = Support.login;
|
|
27
|
+
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
28
|
+
msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
|
|
29
|
+
msg.statusCode = result.status;
|
|
30
|
+
if(msg.payload) {
|
|
31
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
32
|
+
node.send(msg);
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
36
|
+
done(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RED.httpAdmin.get('/entities', RED.auth.needsPermission('manipulateEntitySap.read'), (req, res) => {
|
|
42
|
+
//console.log('entities');
|
|
43
|
+
res.json(entities);
|
|
44
|
+
});
|
|
45
|
+
RED.nodes.registerType('manipulateEntitySap', ManipulateEntitySap, {});
|
|
46
|
+
};
|