@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 ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "singleQuote": true,
3
+ "useTabs":false,
4
+ "tabWidth": 2,
5
+ "printWidth": 120
6
+ }
package/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
+ # [0.2.2] - 2024-10-23
5
+
6
+ - Fix compatibility node-RED > 3.1.0
7
+
8
+ # [0.2.0] - 2024-06-19
9
+
10
+ > *Warning Breaking Change!* please make backups of flows and try in test environment before upgrading
11
+
12
+ - We have improved the management of login token expiration
13
+ - We have updated the manage dynamic login on AUTH Request
14
+ - We have updated the result handling in PATCH request
15
+ - We have resolved an error send Entry on UDT PATCH request
16
+ - We have updated the result handling in SERVICE request
17
+ - We have updated the error parsing function
18
+ - We Add Service "OrdersService_Preview" on SERVICE
19
+ - Bug Fix
20
+ - Library Axios & Odata Updated
4
21
 
5
22
  # [0.1.1] - 2022-12-09
6
23
 
@@ -2,13 +2,13 @@ version: '3.7'
2
2
 
3
3
  services:
4
4
  nodered:
5
- image: nodered/node-red:2.0.6-12
5
+ image: nodered/node-red:3.1.9-18
6
6
  # network_mode: host
7
7
  extra_hosts:
8
- - "api.yousolution.local:192.168.1.100"
8
+ - 'api.yousolution.local:192.168.1.100'
9
9
  volumes:
10
10
  - ./data:/data
11
11
  ports:
12
12
  - '1880:1880'
13
13
  environment:
14
- NODE_ENV: 'dev'
14
+ NODE_ENV: 'dev'
package/nodes/SQLQuery.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
 
5
6
  module.exports = function (RED) {
6
7
  function SQLQuery(config) {
@@ -28,11 +29,13 @@ module.exports = function (RED) {
28
29
  const options = { method: 'POST', hasRawQuery: false, isSQLQuery: true, data: data };
29
30
  const login = Support.login;
30
31
  const result = await Support.sendRequest({ node, msg, config, axios, login, options });
31
- msg.payload = result.data;
32
+ msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
32
33
  msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
33
34
  msg.statusCode = result.status;
34
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
35
- node.send(msg);
35
+ if(msg.payload) {
36
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
37
+ node.send(msg);
38
+ }
36
39
  } catch (error) {
37
40
  node.status({ fill: 'red', shape: 'dot', text: 'Error' });
38
41
  done(error);
@@ -22,15 +22,32 @@ module.exports = function (RED) {
22
22
  },
23
23
  });
24
24
 
25
- if (!node.credentials.user || !node.credentials.password || !node.credentials.company) {
25
+ if (!node.credentials.user || !node.credentials.company) {
26
26
  node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials' });
27
27
  }
28
28
 
29
29
  node.on('input', async (msg, send, done) => {
30
+
31
+ if(!node.credentials.password && !msg.password){
32
+ node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials Password Code' });
33
+ }
34
+
35
+ if(msg.password){
36
+ globalContext.set(`_YOU_SapServiceLayer_${node.id}.credentials.Password`, msg.password);
37
+ //node.status({ fill: 'gray', shape: 'ring', text: 'Missing credentials Password Code' });
38
+ }
39
+
30
40
  // If Company setted from msg
31
41
  if (node.credentials.companyType == 'msg') {
32
42
  const company = msg[node.credentials.company];
43
+ let currentCompany = globalContext.get(`_YOU_SapServiceLayer_${node.id}.credentials.CompanyDB`);
44
+
45
+ if(company !== currentCompany) {
46
+ globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, null);
47
+ }
48
+
33
49
  globalContext.set(`_YOU_SapServiceLayer_${node.id}.credentials.CompanyDB`, company);
50
+
34
51
  }
35
52
 
36
53
  // If User setted from msg
@@ -42,36 +59,62 @@ module.exports = function (RED) {
42
59
  // reset status
43
60
  node.status({});
44
61
 
45
- if (!node.credentials.user || !node.credentials.password || !node.credentials.company) {
62
+ if (!node.credentials.user || !node.credentials.company) {
46
63
  node.status({ fill: 'red', shape: 'dot', text: 'Missing credentials' });
47
64
  done(new Error('Missing credentials'));
48
65
  return;
49
66
  }
50
67
 
68
+ let currentDate = new Date();
51
69
  const headers = globalContext.get(`_YOU_SapServiceLayer_${node.id}.headers`);
70
+ const exipiredTime = globalContext.get(`_YOU_SapServiceLayer_${node.id}.exp`);
71
+ let validToken = true;
52
72
 
53
73
  msg._YOU_SapServiceLayer = {
54
74
  idAuth: node.id,
55
75
  };
56
76
 
57
- if (!headers) {
77
+ if(headers && exipiredTime) {
78
+ let providedDate = new Date(exipiredTime);
79
+ let timeDifference = currentDate - providedDate;
80
+ let minutesDifference = timeDifference / (1000 * 60);
81
+ validToken = minutesDifference > 25 ? false : true;
82
+ }
83
+
84
+
85
+ if (!headers || !validToken) {
58
86
  try {
59
87
  const result = await Support.login(node, node.id);
60
- globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, result.headers['set-cookie']);
88
+ if(result.data.hasOwnProperty("error")) {
89
+ node.error( result.data.error , msg);
90
+ node.status({ fill: 'red', shape: 'dot', text: 'disconnected' });
91
+ }
92
+ else {
93
+ globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, result.headers['set-cookie']);
94
+ globalContext.set(`_YOU_SapServiceLayer_${node.id}.exp`, currentDate.toISOString());
95
+ node.send(msg);
96
+ node.status({ fill: 'green', shape: 'dot', text: 'connected' });
97
+ }
98
+ // globalContext.set(`_YOU_SapServiceLayer_${node.id}.headers`, result.headers['set-cookie']);
99
+ // globalContext.set(`_YOU_SapServiceLayer_${node.id}.exp`, currentDate.toISOString());
61
100
  } catch (error) {
62
101
  msg.payload = error;
63
102
  if (error.response && error.response.data) {
64
103
  msg.statusCode = error.response.status;
65
104
  msg.payload = error.response.data;
66
105
  }
67
- node.send(msg);
106
+ node.error( error , msg);
107
+ //node.send(msg);
68
108
  node.status({ fill: 'red', shape: 'dot', text: 'disconnected' });
69
109
  done(error);
70
- return;
110
+ //return;
71
111
  }
72
112
  }
73
- node.send(msg);
74
- node.status({ fill: 'green', shape: 'dot', text: 'connected' });
113
+ else {
114
+ node.send(msg);
115
+ node.status({ fill: 'green', shape: 'dot', text: 'connected' });
116
+ }
117
+
75
118
  });
76
119
  }
77
120
  RED.nodes.registerType('authenticateSap', AuthenticateSapNode, {
package/nodes/closeSap.js CHANGED
@@ -1,6 +1,8 @@
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');
5
+
4
6
 
5
7
  module.exports = function (RED) {
6
8
  function CloseSapNode(config) {
@@ -18,10 +20,12 @@ module.exports = function (RED) {
18
20
  const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isClose: true };
19
21
  const login = Support.login;
20
22
  const result = await Support.sendRequest({ node, msg, config, axios, login, options });
21
- msg.payload = result.data;
23
+ msg.payload = VerifyErrorSL(node, msg, result.data);// result.data;
22
24
  msg.statusCode = result.status;
23
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
24
- node.send(msg);
25
+ if(msg.payload) {
26
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
27
+ node.send(msg);
28
+ }
25
29
  } catch (error) {
26
30
  node.status({ fill: 'red', shape: 'dot', text: 'Error' });
27
31
  done(error);
@@ -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
 
5
6
  module.exports = function (RED) {
6
7
  function CreateSQLQuery(config) {
@@ -53,10 +54,12 @@ module.exports = function (RED) {
53
54
  const options = { method: 'POST', hasRawQuery: false, isCreateSQLQuery: true, data: data };
54
55
  const login = Support.login;
55
56
  const result = await Support.sendRequest({ node, msg, config, axios, login, options });
56
- msg.payload = result;
57
+ msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
57
58
  msg.statusCode = result.status;
58
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
59
- node.send(msg);
59
+ if(msg.payload) {
60
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
61
+ node.send(msg);
62
+ }
60
63
  } catch (error) {
61
64
  node.status({ fill: 'red', shape: 'dot', text: 'Error' });
62
65
  done(error);
@@ -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
 
5
6
  module.exports = function (RED) {
6
7
  function CreateSapNode(config) {
@@ -22,13 +23,16 @@ module.exports = function (RED) {
22
23
  const options = { method: 'POST', hasRawQuery: false, data: data };
23
24
  const login = Support.login;
24
25
  const result = await Support.sendRequest({ node, msg, config, axios, login, options });
25
- msg.payload = result;
26
+ msg.payload =VerifyErrorSL(node, msg, result.data);// result.data;
26
27
  msg.statusCode = result.status;
27
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
28
- node.send(msg);
28
+ if(msg.payload) {
29
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
30
+ node.send(msg);
31
+ }
29
32
  } catch (error) {
30
33
  node.status({ fill: 'red', shape: 'dot', text: 'Error' });
31
- done(error);
34
+ //node.error(error, msg);
35
+ // done(error);
32
36
  }
33
37
  });
34
38
  }
@@ -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) {
@@ -19,11 +20,13 @@ module.exports = function (RED) {
19
20
  const options = { method: 'GET', hasRawQuery: true, hasEntityId: false, isCrossJoin: 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.statusCode = result.status;
24
25
  msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
25
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
26
- node.send(msg);
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);
@@ -1,72 +1,72 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('deleteSap',{
2
+ RED.nodes.registerType('deleteSap', {
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: ''}
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
14
  },
15
- inputs:1,
16
- outputs:1,
15
+ inputs: 1,
16
+ outputs: 1,
17
17
  icon: 'font-awesome/fa-trash',
18
- label: function() {
19
- return this.name||"Sap delete";
18
+ label: function () {
19
+ return this.name || 'Sap delete';
20
20
  },
21
- oneditprepare: function() {
22
- $("#node-input-entityId").typedInput({
23
- type:"msg",
24
- types:["msg"],
25
- typeField: "#node-input-entityId-type",
26
- value: 'entityId'
21
+ oneditprepare: function () {
22
+ $('#node-input-entityId').typedInput({
23
+ type: 'msg',
24
+ types: ['msg'],
25
+ typeField: '#node-input-entityId-type',
26
+ value: 'entityId',
27
27
  });
28
28
 
29
- $("#node-input-docEntry").typedInput({
30
- type:"msg",
31
- types:["msg"],
32
- typeField: "#node-input-docEntry-type",
33
- value: 'docEntry'
29
+ $('#node-input-docEntry').typedInput({
30
+ type: 'msg',
31
+ types: ['msg'],
32
+ typeField: '#node-input-docEntry-type',
33
+ value: 'docEntry',
34
34
  });
35
35
 
36
- $("#node-input-headers").typedInput({
37
- type:"msg",
38
- types:["msg"],
39
- typeField: "#node-input-headers-type",
40
- value: 'headers'
36
+ $('#node-input-headers').typedInput({
37
+ type: 'msg',
38
+ types: ['msg'],
39
+ typeField: '#node-input-headers-type',
40
+ value: 'headers',
41
41
  });
42
42
 
43
- jQuery("#node-input-entity").change(function() {
43
+ jQuery('#node-input-entity').change(function () {
44
44
  jQuery('#container-udo').hide();
45
45
  jQuery('#container-docEntry').hide();
46
46
  jQuery('#container-udt').hide();
47
47
  jQuery('#container-code').hide();
48
48
  jQuery('#container-entityId').show();
49
49
 
50
- if (jQuery(this).val() === 'UDO'){
50
+ if (jQuery(this).val() === 'UDO') {
51
51
  jQuery('#container-udo').show();
52
52
  jQuery('#container-docEntry').show();
53
- }
54
- if (jQuery(this).val() === 'UDT'){
53
+ }
54
+ if (jQuery(this).val() === 'UDT') {
55
55
  jQuery('#container-udt').show();
56
56
  jQuery('#container-code').show();
57
- }
58
- if(jQuery(this).val() !== 'UDO' || jQuery(this).val() !== 'UDT') {
57
+ }
58
+ if (jQuery(this).val() !== 'UDO' || jQuery(this).val() !== 'UDT') {
59
59
  jQuery('#container-entityId').hide();
60
60
  }
61
61
  });
62
- }
62
+ },
63
63
  });
64
64
  </script>
65
-
65
+
66
66
  <script type="text/html" data-template-name="deleteSap">
67
67
  <div class="form-row">
68
68
  <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
69
- <input type="text" id="node-input-name" placeholder="Name">
69
+ <input type="text" id="node-input-name" placeholder="Name" />
70
70
  </div>
71
71
 
72
72
  <div class="form-row">
@@ -277,131 +277,130 @@
277
277
 
278
278
  <div class="form-row" style="display:none" id="container-udo">
279
279
  <label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
280
- <input type="text" id="node-input-udo" placeholder="UDO Name">
280
+ <input type="text" id="node-input-udo" placeholder="UDO Name" />
281
281
  </div>
282
282
 
283
283
  <div class="form-row" style="display:none" id="container-udt">
284
284
  <label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
285
- <input type="text" id="node-input-udt" placeholder="UDT Name">
285
+ <input type="text" id="node-input-udt" placeholder="UDT Name" />
286
286
  </div>
287
287
 
288
288
  <div class="form-row" style="display:none" id="container-entityId">
289
289
  <label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
290
- <input type="text" id="node-input-entityId">
291
- <input type="hidden" id="node-input-entityId-type">
290
+ <input type="text" id="node-input-entityId" />
291
+ <input type="hidden" id="node-input-entityId-type" />
292
292
  </div>
293
293
 
294
294
  <div class="form-row" style="display:none" id="container-docEntry">
295
295
  <label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
296
- <input type="text" id="node-input-docEntry">
297
- <input type="hidden" id="node-input-docEntry-type">
296
+ <input type="text" id="node-input-docEntry" />
297
+ <input type="hidden" id="node-input-docEntry-type" />
298
298
  </div>
299
299
 
300
300
  <div class="form-row" style="display:none" id="container-code">
301
301
  <label for="node-input-type"><i class="fa fa-key"></i> Code</label>
302
- <input type="text" id="node-input-code">
303
- <input type="hidden" id="node-input-code-type">
302
+ <input type="text" id="node-input-code" />
303
+ <input type="hidden" id="node-input-code-type" />
304
304
  </div>
305
305
 
306
306
  <div class="form-row">
307
307
  <label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
308
- <input type="text" id="node-input-headers">
309
- <input type="hidden" id="node-input-headers-type">
308
+ <input type="text" id="node-input-headers" />
309
+ <input type="hidden" id="node-input-headers-type" />
310
310
  </div>
311
311
  </script>
312
-
312
+
313
313
  <!-- Documentation -->
314
314
  <script type="text/html" data-help-name="deleteSap">
315
315
  <p>Delete action</p>
316
-
316
+
317
317
  <h3>Inputs</h3>
318
+ <dl class="message-properties">
319
+ <dt>
320
+ Name
321
+ <span class="property-type">string</span>
322
+ </dt>
323
+ <dd>the node's name</dd>
324
+ <dt>
325
+ Entity
326
+ <span class="property-type">string</span>
327
+ </dt>
328
+ <dd>the entity name of SAP</dd>
329
+ <dt>
330
+ entityId
331
+ <span class="property-type">number | string</span>
332
+ </dt>
333
+ <dd>the id of the entity of SAP</dd>
334
+ </dl>
335
+
336
+ <h3>Outputs</h3>
337
+ <ol class="node-ports">
338
+ <li>
339
+ Standard output
318
340
  <dl class="message-properties">
319
- <dt>Name
320
- <span class="property-type">string</span>
321
- </dt>
322
- <dd> the node's name </dd>
323
- <dt>Entity
324
- <span class="property-type">string</span>
325
- </dt>
326
- <dd> the entity name of SAP </dd>
327
- <dt>entityId
328
- <span class="property-type">number | string</span>
329
- </dt>
330
- <dd> the id of the entity of SAP </dd>
341
+ <dt>payload <span class="property-type">string</span></dt>
342
+ <dd>the standard output of the command.</dd>
331
343
  </dl>
332
-
333
- <h3>Outputs</h3>
334
- <ol class="node-ports">
335
- <li>Standard output
336
- <dl class="message-properties">
337
- <dt>payload <span class="property-type">string</span></dt>
338
- <dd>the standard output of the command.</dd>
339
- </dl>
340
- </li>
341
- </ol>
342
-
344
+ </li>
345
+ </ol>
346
+
343
347
  <h3>Details</h3>
344
- <p>this node is used to delete an entity of SAP.
345
- See the examples to understand how to use it.
346
- </p>
347
- <!-- <p><code>msg.payload</code> is used as the payload of the published message.
348
+ <p>this node is used to delete an entity of SAP. See the examples to understand how to use it.</p>
349
+ <!-- <p><code>msg.payload</code> is used as the payload of the published message.
348
350
  If it contains an Object it will be converted to a JSON string before being sent.
349
351
  If it contains a binary Buffer the message will be published as-is.</p>
350
352
  <p>The topic used can be configured in the node or, if left blank, can be set
351
353
  by <code>msg.topic</code>.</p>
352
354
  <p>Likewise the QoS and retain values can be configured in the node or, if left
353
355
  blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
354
-
356
+
355
357
  <h3>References</h3>
356
- <ul>
357
- <li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
358
- <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>
359
- </ul>
360
- </script><!-- Documentation -->
358
+ <ul>
359
+ <li>
360
+ <a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a>
361
+ - for more details
362
+ </li>
363
+ <li>
364
+ <a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer"
365
+ >@yousolution-cloud/node-red-contrib-you-sap-service-layer</a
366
+ >
367
+ - the nodes github repository
368
+ </li>
369
+ </ul>
370
+ </script>
371
+ <!-- Documentation -->
361
372
  <script type="text/html" data-help-name="closeSap">
362
373
  <p>Close action</p>
363
-
374
+
364
375
  <h3>Inputs</h3>
365
376
  <dl class="message-properties">
366
- <dt>Name
367
- <span class="property-type">string</span>
368
- </dt>
369
- <dd> the node's name </dd>
370
- <dt>Entity
371
- <span class="property-type">string</span>
372
- </dt>
373
- <dd> the entity name of SAP resource </dd>
374
- <dt>entityId
375
- <span class="property-type">number | string</span>
376
- </dt>
377
- <dd> the id of the entity of SAP resource </dd>
377
+ <dt>payload <span class="property-type">string</span></dt>
378
+ <dd>the standard output of the command.</dd>
378
379
  </dl>
379
-
380
- <h3>Outputs</h3>
381
- <ol class="node-ports">
382
- <li>Standard output
383
- <dl class="message-properties">
384
- <dt>payload <span class="property-type">string</span></dt>
385
- <dd>the standard output of the command.</dd>
386
- </dl>
387
- </li>
388
- </ol>
389
-
380
+ </li>
381
+ </ol>
382
+
390
383
  <h3>Details</h3>
391
- <p>this node is used to close the entity of SAP resource.
392
- See the examples to understand how to use it.
393
- </p>
394
- <!-- <p><code>msg.payload</code> is used as the payload of the published message.
384
+ <p>this node is used to close the entity of SAP resource. See the examples to understand how to use it.</p>
385
+ <!-- <p><code>msg.payload</code> is used as the payload of the published message.
395
386
  If it contains an Object it will be converted to a JSON string before being sent.
396
387
  If it contains a binary Buffer the message will be published as-is.</p>
397
388
  <p>The topic used can be configured in the node or, if left blank, can be set
398
389
  by <code>msg.topic</code>.</p>
399
390
  <p>Likewise the QoS and retain values can be configured in the node or, if left
400
391
  blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
401
-
392
+
402
393
  <h3>References</h3>
403
- <ul>
404
- <li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
405
- <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>
406
- </ul>
407
- </script>
394
+ <ul>
395
+ <li>
396
+ <a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a>
397
+ - for more details
398
+ </li>
399
+ <li>
400
+ <a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer"
401
+ >@yousolution-cloud/node-red-contrib-you-sap-service-layer</a
402
+ >
403
+ - the nodes github repository
404
+ </li>
405
+ </ul>
406
+ </script>
@@ -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
 
5
6
  module.exports = function (RED) {
6
7
  function DeleteSapNode(config) {
@@ -18,10 +19,12 @@ module.exports = function (RED) {
18
19
  const options = { method: 'DELETE', hasRawQuery: true, hasEntityId: true, data: {} };
19
20
  const login = Support.login;
20
21
  const result = await Support.sendRequest({ node, msg, config, axios, login, options });
21
- msg.payload = result.data;
22
+ msg.payload = VerifyErrorSL(node, msg, result.data, true );// result.data;
22
23
  msg.statusCode = result.status;
23
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
24
- node.send(msg);
24
+ if(result.status <= 205) {
25
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
26
+ node.send(msg);
27
+ }
25
28
  } catch (error) {
26
29
  node.status({ fill: 'red', shape: 'dot', text: 'Error' });
27
30
  done(error);