@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.
Files changed (50) hide show
  1. package/.prettierrc +6 -6
  2. package/.vscode/launch.json +23 -23
  3. package/CHANGELOG.md +61 -52
  4. package/README.md +126 -126
  5. package/docker-compose.yml +14 -14
  6. package/examples/example.json +625 -625
  7. package/nodes/SQLQuery.html +179 -179
  8. package/nodes/SQLQuery.js +46 -46
  9. package/nodes/authenticateSap.html +146 -146
  10. package/nodes/authenticateSap.js +129 -129
  11. package/nodes/closeSap.html +128 -97
  12. package/nodes/closeSap.js +36 -36
  13. package/nodes/createSQLQuery.html +165 -165
  14. package/nodes/createSQLQuery.js +70 -70
  15. package/nodes/createSap.html +391 -391
  16. package/nodes/createSap.js +40 -40
  17. package/nodes/crossJoinSap.html +394 -394
  18. package/nodes/crossJoinSap.js +37 -37
  19. package/nodes/deleteSap.html +406 -406
  20. package/nodes/deleteSap.js +35 -35
  21. package/nodes/getSap.html +427 -427
  22. package/nodes/getSap.js +34 -34
  23. package/nodes/listSap.html +402 -402
  24. package/nodes/listSap.js +37 -37
  25. package/nodes/manageErrors.js +38 -38
  26. package/nodes/manipulateEntitySap.html +176 -176
  27. package/nodes/manipulateEntitySap.js +46 -46
  28. package/nodes/nextLink.html +100 -100
  29. package/nodes/nextLink.js +18 -18
  30. package/nodes/patchSap.html +424 -424
  31. package/nodes/patchSap.js +40 -40
  32. package/nodes/serviceSap.html +160 -206
  33. package/nodes/serviceSap.js +39 -39
  34. package/nodes/support.js +363 -363
  35. package/package.json +65 -65
  36. package/resources/entities.json +59 -59
  37. package/resources/services.json +343 -343
  38. package/test/authenticateSap.spec.js +307 -307
  39. package/test/closeSap.spec.js +156 -156
  40. package/test/createSQLQuery.spec.js +174 -174
  41. package/test/createSap.spec.js +183 -183
  42. package/test/crossJoinSap.spec.js +156 -156
  43. package/test/deleteSap.spec.js +156 -156
  44. package/test/getSap.spec.js +156 -156
  45. package/test/listSap.spec.js +156 -156
  46. package/test/manipulateEntitySap.spec.js +191 -191
  47. package/test/patchSap.spec.js +184 -184
  48. package/test/serviceSap.spec.js +170 -170
  49. package/test/support.spec.js +1419 -1419
  50. package/data/.gitkeep +0 -0
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
+ };
@@ -1,207 +1,161 @@
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 SAPSLservicesName = [];
3
+ let SAPSLservicesData = {};
4
+ $.getJSON('services', (data, status) => {
5
+ for(service in data) {
6
+ SAPSLservicesData = data;
7
+ SAPSLservicesName.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
+ headers: {value: ''},
18
+ bodyPost: {value: ''}
19
+ },
20
+ inputs:1,
21
+ outputs:1,
22
+ icon: 'font-awesome/fa-gears',
23
+ label: function() {
24
+ return this.name||"Sap service";
25
+ },
26
+ oneditprepare: function() {
27
+
28
+ $("#node-input-headers").typedInput({
29
+ type:"msg",
30
+ types:["msg"],
31
+ typeField: "#node-input-headers-type",
32
+ value: 'headers'
33
+ });
34
+
35
+ $("#node-input-bodyPost").typedInput({
36
+ type:"msg",
37
+ types:["msg"],
38
+ typeField: "#node-input-bodyPost-type",
39
+ value: 'bodyPost'
40
+ });
41
+
42
+ SAPSLservicesName.forEach((service) => {
43
+ $('#node-input-serviceName')
44
+ .append($("<option></option>")
45
+ .attr("value", service)
46
+ .text(service));
47
+ });
48
+
49
+ // set the previous value
50
+ if(this.serviceName) {
51
+ $('#node-input-serviceName').val(this.serviceName);
52
+ }
53
+
54
+
55
+ $("#node-input-serviceName").change((event) => {
56
+ const service = $("#node-input-serviceName").val();
57
+
58
+ $('#node-input-service').empty();
59
+
60
+ if(SAPSLservicesData[service]) {
61
+ SAPSLservicesData[service].forEach((endpoint) => {
62
+ $('#node-input-service')
63
+ .append($("<option></option>")
64
+ .attr("value", endpoint)
65
+ .text(endpoint));
66
+ });
67
+ // trick check if change with click or not
68
+ if(!event.originalEvent){
69
+ $('#node-input-service').val(this.service);
70
+ }
71
+ }
72
+ });
73
+
74
+ }
75
+ });
76
+ </script>
77
+
78
+ <script type="text/html" data-template-name="serviceSap">
79
+ <div class="form-row">
80
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
81
+ <input type="text" id="node-input-name" placeholder="Name">
82
+ </div>
83
+
84
+ <div class="form-row">
85
+ <label for="node-input-type"><i class="fa fa-gears"></i> Service</label>
86
+ <select name="node-input-serviceName" id="node-input-serviceName">
87
+ <option></option>
88
+ </select>
89
+ </div>
90
+
91
+ <div class="form-row">
92
+ <label for="node-input-type"><i class="fa fa-gears"></i> Endpoint</label>
93
+ <select name="node-input-service" id="node-input-service">
94
+ </select>
95
+ </div>
96
+
97
+ <div class="form-row">
98
+ <label for="node-input-type"><i class="fa fa-cog"></i> Headers</label>
99
+ <input type="text" id="node-input-headers">
100
+ <input type="hidden" id="node-input-headers-type">
101
+ </div>
102
+
103
+ <div class="form-row">
104
+ <label for="node-input-type"><i class="fa fa-cog"></i> BodyPost</label>
105
+ <input type="text" id="node-input-bodyPost">
106
+ <input type="hidden" id="node-input-bodyPost-type">
107
+ </div>
108
+ </script>
109
+
110
+ <!-- Documentation -->
111
+ <script type="text/html" data-help-name="serviceSap">
112
+ <p>Post action</p>
113
+
114
+ <h3>Inputs</h3>
115
+ <dl class="message-properties">
116
+ <dt>Name
117
+ <span class="property-type">string</span>
118
+ </dt>
119
+ <dd> the node's name </dd>
120
+ <dt>Entity
121
+ <span class="property-type">string</span>
122
+ </dt>
123
+ <dd> the entity name of SAP </dd>
124
+ <dt>entityId
125
+ <span class="property-type">number | string</span>
126
+ </dt>
127
+ <dd> the id of the entity of SAP </dd>
128
+ <dt>bodyPost
129
+ <span class="property-type">object</span>
130
+ </dt>
131
+ <dd> data to update to the entity </dd>
132
+ </dl>
133
+
134
+ <h3>Outputs</h3>
135
+ <ol class="node-ports">
136
+ <li>Standard output
137
+ <dl class="message-properties">
138
+ <dt>payload <span class="property-type">string</span></dt>
139
+ <dd>the standard output of the command.</dd>
140
+ </dl>
141
+ </li>
142
+ </ol>
143
+
144
+ <h3>Details</h3>
145
+ <p>this node is used to update the entity of SAP.
146
+ See the examples to understand how to use it.
147
+ </p>
148
+ <!-- <p><code>msg.payload</code> is used as the payload of the published message.
149
+ If it contains an Object it will be converted to a JSON string before being sent.
150
+ If it contains a binary Buffer the message will be published as-is.</p>
151
+ <p>The topic used can be configured in the node or, if left blank, can be set
152
+ by <code>msg.topic</code>.</p>
153
+ <p>Likewise the QoS and retain values can be configured in the node or, if left
154
+ blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
155
+
156
+ <h3>References</h3>
157
+ <ul>
158
+ <li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
159
+ <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>
160
+ </ul>
207
161
  </script>
@@ -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
+ };