@yousolution/node-red-contrib-you-sap-service-layer 0.1.1 → 0.2.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/.prettierrc +6 -0
- package/CHANGELOG.md +17 -0
- package/docker-compose.yml +3 -3
- 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.html +116 -117
- package/nodes/deleteSap.js +6 -3
- package/nodes/getSap.html +80 -98
- 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 +94 -104
- package/nodes/patchSap.js +6 -3
- package/nodes/serviceSap.js +6 -8
- package/nodes/support.js +21 -12
- package/package.json +8 -4
- package/resources/services.json +1 -1
package/nodes/getSap.html
CHANGED
|
@@ -1,97 +1,95 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('getSap',{
|
|
2
|
+
RED.nodes.registerType('getSap', {
|
|
3
3
|
category: 'Sap',
|
|
4
4
|
color: '#FFC300',
|
|
5
5
|
defaults: {
|
|
6
|
-
name: {value: ''},
|
|
7
|
-
entity: {value: ''},
|
|
8
|
-
udo: {value: ''},
|
|
9
|
-
udt: {value: ''},
|
|
10
|
-
entityId: {value: ''},
|
|
11
|
-
docEntry: {value: ''},
|
|
12
|
-
code: {value: ''},
|
|
13
|
-
headers: {value: ''},
|
|
14
|
-
query: {value: 'query={};'}
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
entity: { value: '' },
|
|
8
|
+
udo: { value: '' },
|
|
9
|
+
udt: { value: '' },
|
|
10
|
+
entityId: { value: '' },
|
|
11
|
+
docEntry: { value: '', validate: (v) => true },
|
|
12
|
+
code: { value: '', validate: (v) => true },
|
|
13
|
+
headers: { value: '' },
|
|
14
|
+
query: { value: 'query={};' },
|
|
15
15
|
},
|
|
16
|
-
inputs:1,
|
|
17
|
-
outputs:1,
|
|
16
|
+
inputs: 1,
|
|
17
|
+
outputs: 1,
|
|
18
18
|
icon: 'font-awesome/fa-cube',
|
|
19
|
-
label: function() {
|
|
20
|
-
return this.name||
|
|
19
|
+
label: function () {
|
|
20
|
+
return this.name || 'Sap get';
|
|
21
21
|
},
|
|
22
|
-
oneditprepare: function() {
|
|
23
|
-
$(
|
|
24
|
-
type:
|
|
25
|
-
types:[
|
|
26
|
-
typeField:
|
|
27
|
-
value: 'entityId'
|
|
22
|
+
oneditprepare: function () {
|
|
23
|
+
$('#node-input-entityId').typedInput({
|
|
24
|
+
type: 'msg',
|
|
25
|
+
types: ['msg'],
|
|
26
|
+
typeField: '#node-input-entityId-type',
|
|
27
|
+
value: 'entityId',
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
$(
|
|
31
|
-
type:
|
|
32
|
-
types:[
|
|
33
|
-
typeField:
|
|
34
|
-
value: 'docEntry'
|
|
30
|
+
$('#node-input-docEntry').typedInput({
|
|
31
|
+
type: 'msg',
|
|
32
|
+
types: ['msg'],
|
|
33
|
+
typeField: '#node-input-docEntry-type',
|
|
34
|
+
value: 'docEntry',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
$(
|
|
38
|
-
type:
|
|
39
|
-
types:[
|
|
40
|
-
typeField:
|
|
41
|
-
value: 'code'
|
|
37
|
+
$('#node-input-code').typedInput({
|
|
38
|
+
type: 'msg',
|
|
39
|
+
types: ['msg'],
|
|
40
|
+
typeField: '#node-input-code-type',
|
|
41
|
+
value: 'code',
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
$(
|
|
45
|
-
type:
|
|
46
|
-
types:[
|
|
47
|
-
typeField:
|
|
48
|
-
value: 'headers'
|
|
44
|
+
$('#node-input-headers').typedInput({
|
|
45
|
+
type: 'msg',
|
|
46
|
+
types: ['msg'],
|
|
47
|
+
typeField: '#node-input-headers-type',
|
|
48
|
+
value: 'headers',
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
this.editor = RED.editor.createEditor({
|
|
52
52
|
id: 'node-input-editor',
|
|
53
53
|
mode: 'ace/mode/javascript',
|
|
54
|
-
value: this.query
|
|
54
|
+
value: this.query,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
jQuery(
|
|
57
|
+
jQuery('#node-input-entity').change(function () {
|
|
58
58
|
jQuery('#container-udo').hide();
|
|
59
59
|
jQuery('#container-udt').hide();
|
|
60
60
|
jQuery('#container-code').hide();
|
|
61
61
|
jQuery('#container-docEntry').hide();
|
|
62
62
|
jQuery('#container-entityId').hide();
|
|
63
63
|
|
|
64
|
-
if (jQuery(this).val() === 'UDO'){
|
|
64
|
+
if (jQuery(this).val() === 'UDO') {
|
|
65
65
|
jQuery('#container-udo').show();
|
|
66
66
|
jQuery('#container-docEntry').show();
|
|
67
|
-
}
|
|
68
|
-
if (jQuery(this).val() === 'UDT'){
|
|
67
|
+
}
|
|
68
|
+
if (jQuery(this).val() === 'UDT') {
|
|
69
69
|
jQuery('#container-udt').show();
|
|
70
70
|
jQuery('#container-code').show();
|
|
71
|
-
}
|
|
72
|
-
if(jQuery(this).val() !== 'UDO' && jQuery(this).val() !== 'UDT') {
|
|
71
|
+
}
|
|
72
|
+
if (jQuery(this).val() !== 'UDO' && jQuery(this).val() !== 'UDT') {
|
|
73
73
|
jQuery('#container-entityId').show();
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
},
|
|
77
|
-
oneditsave: function() {
|
|
77
|
+
oneditsave: function () {
|
|
78
78
|
this.query = this.editor.getValue();
|
|
79
79
|
this.editor.destroy();
|
|
80
80
|
delete this.editor;
|
|
81
81
|
},
|
|
82
|
-
oneditcancel: function() {
|
|
82
|
+
oneditcancel: function () {
|
|
83
83
|
this.editor.destroy();
|
|
84
84
|
delete this.editor;
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
87
|
</script>
|
|
90
88
|
|
|
91
89
|
<script type="text/html" data-template-name="getSap">
|
|
92
90
|
<div class="form-row">
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
92
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
95
93
|
</div>
|
|
96
94
|
|
|
97
95
|
<div class="form-row">
|
|
@@ -353,36 +351,36 @@
|
|
|
353
351
|
|
|
354
352
|
<div class="form-row" style="display:none" id="container-udo">
|
|
355
353
|
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
356
|
-
<input type="text" id="node-input-udo" placeholder="UDO Name"
|
|
354
|
+
<input type="text" id="node-input-udo" placeholder="UDO Name" />
|
|
357
355
|
</div>
|
|
358
356
|
|
|
359
357
|
<div class="form-row" style="display:none" id="container-udt">
|
|
360
358
|
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
361
|
-
<input type="text" id="node-input-udt" placeholder="UDT Name"
|
|
359
|
+
<input type="text" id="node-input-udt" placeholder="UDT Name" />
|
|
362
360
|
</div>
|
|
363
361
|
|
|
364
362
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
365
363
|
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
366
|
-
<input type="text" id="node-input-entityId"
|
|
367
|
-
<input type="hidden" id="node-input-entityId-type"
|
|
364
|
+
<input type="text" id="node-input-entityId" />
|
|
365
|
+
<input type="hidden" id="node-input-entityId-type" />
|
|
368
366
|
</div>
|
|
369
367
|
|
|
370
368
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
371
369
|
<label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
|
|
372
|
-
<input type="text" id="node-input-docEntry"
|
|
373
|
-
<input type="hidden" id="node-input-docEntry-type"
|
|
370
|
+
<input type="text" id="node-input-docEntry" />
|
|
371
|
+
<input type="hidden" id="node-input-docEntry-type" />
|
|
374
372
|
</div>
|
|
375
373
|
|
|
376
374
|
<div class="form-row" style="display:none" id="container-code">
|
|
377
375
|
<label for="node-input-type"><i class="fa fa-key"></i> Code</label>
|
|
378
|
-
<input type="text" id="node-input-code"
|
|
379
|
-
<input type="hidden" id="node-input-code-type"
|
|
376
|
+
<input type="text" id="node-input-code" />
|
|
377
|
+
<input type="hidden" id="node-input-code-type" />
|
|
380
378
|
</div>
|
|
381
379
|
|
|
382
380
|
<div class="form-row">
|
|
383
381
|
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
384
|
-
<input type="text" id="node-input-headers"
|
|
385
|
-
<input type="hidden" id="node-input-headers-type"
|
|
382
|
+
<input type="text" id="node-input-headers" />
|
|
383
|
+
<input type="hidden" id="node-input-headers-type" />
|
|
386
384
|
</div>
|
|
387
385
|
|
|
388
386
|
<div class="form-row">
|
|
@@ -394,52 +392,36 @@
|
|
|
394
392
|
<!-- Documentation -->
|
|
395
393
|
<script type="text/html" data-help-name="getSap">
|
|
396
394
|
<p>Get action</p>
|
|
397
|
-
|
|
395
|
+
|
|
398
396
|
<h3>Inputs</h3>
|
|
399
397
|
<dl class="message-properties">
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
</dt>
|
|
403
|
-
<dd> the node's name </dd>
|
|
404
|
-
<dt>Entity
|
|
405
|
-
<span class="property-type">string</span>
|
|
406
|
-
</dt>
|
|
407
|
-
<dd> the entity name of SAP </dd>
|
|
408
|
-
<dt>entityId
|
|
409
|
-
<span class="property-type">number | string</span>
|
|
410
|
-
</dt>
|
|
411
|
-
<dd> the id of the entity of SAP </dd>
|
|
412
|
-
<dt>query
|
|
413
|
-
<span class="property-type">string</span>
|
|
414
|
-
</dt>
|
|
415
|
-
<dd> query to filter the fields of entity SAP </dd>
|
|
398
|
+
<dt>payload <span class="property-type">string</span></dt>
|
|
399
|
+
<dd>the standard output of the command.</dd>
|
|
416
400
|
</dl>
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
<li>Standard output
|
|
421
|
-
<dl class="message-properties">
|
|
422
|
-
<dt>payload <span class="property-type">string</span></dt>
|
|
423
|
-
<dd>the standard output of the command.</dd>
|
|
424
|
-
</dl>
|
|
425
|
-
</li>
|
|
426
|
-
</ol>
|
|
427
|
-
|
|
401
|
+
</li>
|
|
402
|
+
</ol>
|
|
403
|
+
|
|
428
404
|
<h3>Details</h3>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
</p>
|
|
432
|
-
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
405
|
+
<p>this node is used to get the entity of SAP. See the examples to understand how to use it.</p>
|
|
406
|
+
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
433
407
|
If it contains an Object it will be converted to a JSON string before being sent.
|
|
434
408
|
If it contains a binary Buffer the message will be published as-is.</p>
|
|
435
409
|
<p>The topic used can be configured in the node or, if left blank, can be set
|
|
436
410
|
by <code>msg.topic</code>.</p>
|
|
437
411
|
<p>Likewise the QoS and retain values can be configured in the node or, if left
|
|
438
412
|
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
|
|
439
|
-
|
|
413
|
+
|
|
440
414
|
<h3>References</h3>
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
</
|
|
415
|
+
<ul>
|
|
416
|
+
<li>
|
|
417
|
+
<a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a>
|
|
418
|
+
- for more details
|
|
419
|
+
</li>
|
|
420
|
+
<li>
|
|
421
|
+
<a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer"
|
|
422
|
+
>@yousolution-cloud/node-red-contrib-you-sap-service-layer</a
|
|
423
|
+
>
|
|
424
|
+
- the nodes github repository
|
|
425
|
+
</li>
|
|
426
|
+
</ul>
|
|
427
|
+
</script>
|
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);
|