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