@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.
Files changed (49) hide show
  1. package/.prettierrc +6 -6
  2. package/.vscode/launch.json +23 -23
  3. package/CHANGELOG.md +57 -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 +206 -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
@@ -1,180 +1,180 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('SQLQuery',{
3
- category: 'Sap',
4
- color: '#FFC300',
5
- defaults: {
6
- name: {value: ''},
7
- sqlCode: {value: ''},
8
- // sqlName: {value: ''},
9
- // sqlText: {value: ''},
10
- headers: {value: ''},
11
- nextLink: {value: ''},
12
- bodyPost: {value: ''}
13
- },
14
- inputs:1,
15
- outputs:1,
16
- icon: 'font-awesome/fa-search',
17
- label: function() {
18
- return this.name||"SQL Query";
19
- },
20
- oneditprepare: function() {
21
-
22
- $("#node-input-sqlCode").typedInput({
23
- type:"msg",
24
- types:["msg"],
25
- typeField: "#node-input-sqlCode-type",
26
- value: 'sqlCode'
27
- });
28
-
29
- // $("#node-input-sqlName").typedInput({
30
- // type:"msg",
31
- // types:["msg"],
32
- // typeField: "#node-input-sqlName-type",
33
- // value: 'sqlName'
34
- // });
35
-
36
- // $("#node-input-sqlText").typedInput({
37
- // type:"msg",
38
- // types:["msg"],
39
- // typeField: "#node-input-sqlText-type",
40
- // value: 'sqlText'
41
- // });
42
-
43
- $("#node-input-headers").typedInput({
44
- type:"msg",
45
- types:["msg"],
46
- typeField: "#node-input-headers-type",
47
- value: 'headers'
48
- });
49
-
50
- $("#node-input-nextLink").typedInput({
51
- type:"msg",
52
- types:["msg"],
53
- typeField: "#node-input-nextLink-type",
54
- value: 'nextLink'
55
- });
56
-
57
- $("#node-input-bodyPost").typedInput({
58
- type:"msg",
59
- types:["msg"],
60
- typeField: "#node-input-bodyPost-type",
61
- value: 'bodyPost'
62
- });
63
-
64
- // jQuery("#node-input-entity").change(function() {
65
- // jQuery('#container-udo').hide();
66
- // jQuery('#container-udt').hide();
67
- // jQuery('#container-partnerName').hide();
68
- // jQuery('#container-scriptName').hide();
69
- // if (jQuery(this).val() === 'UDO'){
70
- // jQuery('#container-udo').show();
71
- // }
72
- // if (jQuery(this).val() === 'UDT'){
73
- // jQuery('#container-udt').show();
74
- // }
75
- // if (jQuery(this).val() === 'script'){
76
- // jQuery('#container-partnerName').show();
77
- // jQuery('#container-scriptName').show();
78
- // }
79
-
80
- // });
81
- }
82
- });
83
- </script>
84
-
85
- <script type="text/html" data-template-name="SQLQuery">
86
- <div class="form-row">
87
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
88
- <input type="text" id="node-input-name" placeholder="Name">
89
- </div>
90
-
91
- <div class="form-row">
92
- <label for="node-input-type"><i class="fa fa-cog"></i> SqlCode</label>
93
- <input type="text" id="node-input-sqlCode">
94
- <input type="hidden" id="node-input-sqlCode-type">
95
- </div>
96
-
97
- <!-- <div class="form-row">
98
- <label for="node-input-type"><i class="fa fa-cog"></i> SqlName</label>
99
- <input type="text" id="node-input-sqlName">
100
- <input type="hidden" id="node-input-sqlName-type">
101
- </div>
102
-
103
- <div class="form-row">
104
- <label for="node-input-type"><i class="fa fa-cog"></i> SqlText</label>
105
- <input type="text" id="node-input-sqlText">
106
- <input type="hidden" id="node-input-sqlText-type">
107
- </div> -->
108
-
109
- <div class="form-row">
110
- <label for="node-input-type"><i class="fa fa-cog"></i> Headers</label>
111
- <input type="text" id="node-input-headers">
112
- <input type="hidden" id="node-input-headers-type">
113
- </div>
114
-
115
- <div class="form-row">
116
- <label for="node-input-type"><i class="fa fa-cog"></i> NextLink</label>
117
- <input type="text" id="node-input-nextLink">
118
- <input type="hidden" id="node-input-nextLink-type">
119
- </div>
120
-
121
- <div class="form-row">
122
- <label for="node-input-type"><i class="fa fa-cog"></i> BodyPost</label>
123
- <input type="text" id="node-input-bodyPost">
124
- <input type="hidden" id="node-input-bodyPost-type">
125
- </div>
126
- </script>
127
-
128
-
129
- <!-- Documentation -->
130
- <script type="text/html" data-help-name="SQLQuery">
131
- <p>Create a new Entity action</p>
132
-
133
- <h3>Inputs</h3>
134
- <dl class="message-properties">
135
- <dt>Name
136
- <span class="property-type">string</span>
137
- </dt>
138
- <dd> the node's name </dd>
139
- <dt>Entity
140
- <span class="property-type">string</span>
141
- </dt>
142
- <dd> the entity name of SAP resource </dd>
143
- <dt>EntityId
144
- <span class="property-type">number | string</span>
145
- </dt>
146
- <dd> the id of the entity of SAP resource </dd>
147
- <dt>bodyPost
148
- <span class="property-type">object</span>
149
- </dt>
150
- <dd> the data of the entity </dd>
151
- </dl>
152
-
153
- <h3>Outputs</h3>
154
- <ol class="node-ports">
155
- <li>Standard output
156
- <dl class="message-properties">
157
- <dt>payload <span class="property-type">string</span></dt>
158
- <dd>the standard output of the command.</dd>
159
- </dl>
160
- </li>
161
- </ol>
162
-
163
- <h3>Details</h3>
164
- <p>this node is used to create the entity of SAP.
165
- See the examples to understand how to use it.
166
- </p>
167
- <!-- <p><code>msg.payload</code> is used as the payload of the published message.
168
- If it contains an Object it will be converted to a JSON string before being sent.
169
- If it contains a binary Buffer the message will be published as-is.</p>
170
- <p>The topic used can be configured in the node or, if left blank, can be set
171
- by <code>msg.topic</code>.</p>
172
- <p>Likewise the QoS and retain values can be configured in the node or, if left
173
- blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
174
-
175
- <h3>References</h3>
176
- <ul>
177
- <li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
178
- <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>
179
- </ul>
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('SQLQuery',{
3
+ category: 'Sap',
4
+ color: '#FFC300',
5
+ defaults: {
6
+ name: {value: ''},
7
+ sqlCode: {value: ''},
8
+ // sqlName: {value: ''},
9
+ // sqlText: {value: ''},
10
+ headers: {value: ''},
11
+ nextLink: {value: ''},
12
+ bodyPost: {value: ''}
13
+ },
14
+ inputs:1,
15
+ outputs:1,
16
+ icon: 'font-awesome/fa-search',
17
+ label: function() {
18
+ return this.name||"SQL Query";
19
+ },
20
+ oneditprepare: function() {
21
+
22
+ $("#node-input-sqlCode").typedInput({
23
+ type:"msg",
24
+ types:["msg"],
25
+ typeField: "#node-input-sqlCode-type",
26
+ value: 'sqlCode'
27
+ });
28
+
29
+ // $("#node-input-sqlName").typedInput({
30
+ // type:"msg",
31
+ // types:["msg"],
32
+ // typeField: "#node-input-sqlName-type",
33
+ // value: 'sqlName'
34
+ // });
35
+
36
+ // $("#node-input-sqlText").typedInput({
37
+ // type:"msg",
38
+ // types:["msg"],
39
+ // typeField: "#node-input-sqlText-type",
40
+ // value: 'sqlText'
41
+ // });
42
+
43
+ $("#node-input-headers").typedInput({
44
+ type:"msg",
45
+ types:["msg"],
46
+ typeField: "#node-input-headers-type",
47
+ value: 'headers'
48
+ });
49
+
50
+ $("#node-input-nextLink").typedInput({
51
+ type:"msg",
52
+ types:["msg"],
53
+ typeField: "#node-input-nextLink-type",
54
+ value: 'nextLink'
55
+ });
56
+
57
+ $("#node-input-bodyPost").typedInput({
58
+ type:"msg",
59
+ types:["msg"],
60
+ typeField: "#node-input-bodyPost-type",
61
+ value: 'bodyPost'
62
+ });
63
+
64
+ // jQuery("#node-input-entity").change(function() {
65
+ // jQuery('#container-udo').hide();
66
+ // jQuery('#container-udt').hide();
67
+ // jQuery('#container-partnerName').hide();
68
+ // jQuery('#container-scriptName').hide();
69
+ // if (jQuery(this).val() === 'UDO'){
70
+ // jQuery('#container-udo').show();
71
+ // }
72
+ // if (jQuery(this).val() === 'UDT'){
73
+ // jQuery('#container-udt').show();
74
+ // }
75
+ // if (jQuery(this).val() === 'script'){
76
+ // jQuery('#container-partnerName').show();
77
+ // jQuery('#container-scriptName').show();
78
+ // }
79
+
80
+ // });
81
+ }
82
+ });
83
+ </script>
84
+
85
+ <script type="text/html" data-template-name="SQLQuery">
86
+ <div class="form-row">
87
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
88
+ <input type="text" id="node-input-name" placeholder="Name">
89
+ </div>
90
+
91
+ <div class="form-row">
92
+ <label for="node-input-type"><i class="fa fa-cog"></i> SqlCode</label>
93
+ <input type="text" id="node-input-sqlCode">
94
+ <input type="hidden" id="node-input-sqlCode-type">
95
+ </div>
96
+
97
+ <!-- <div class="form-row">
98
+ <label for="node-input-type"><i class="fa fa-cog"></i> SqlName</label>
99
+ <input type="text" id="node-input-sqlName">
100
+ <input type="hidden" id="node-input-sqlName-type">
101
+ </div>
102
+
103
+ <div class="form-row">
104
+ <label for="node-input-type"><i class="fa fa-cog"></i> SqlText</label>
105
+ <input type="text" id="node-input-sqlText">
106
+ <input type="hidden" id="node-input-sqlText-type">
107
+ </div> -->
108
+
109
+ <div class="form-row">
110
+ <label for="node-input-type"><i class="fa fa-cog"></i> Headers</label>
111
+ <input type="text" id="node-input-headers">
112
+ <input type="hidden" id="node-input-headers-type">
113
+ </div>
114
+
115
+ <div class="form-row">
116
+ <label for="node-input-type"><i class="fa fa-cog"></i> NextLink</label>
117
+ <input type="text" id="node-input-nextLink">
118
+ <input type="hidden" id="node-input-nextLink-type">
119
+ </div>
120
+
121
+ <div class="form-row">
122
+ <label for="node-input-type"><i class="fa fa-cog"></i> BodyPost</label>
123
+ <input type="text" id="node-input-bodyPost">
124
+ <input type="hidden" id="node-input-bodyPost-type">
125
+ </div>
126
+ </script>
127
+
128
+
129
+ <!-- Documentation -->
130
+ <script type="text/html" data-help-name="SQLQuery">
131
+ <p>Create a new Entity action</p>
132
+
133
+ <h3>Inputs</h3>
134
+ <dl class="message-properties">
135
+ <dt>Name
136
+ <span class="property-type">string</span>
137
+ </dt>
138
+ <dd> the node's name </dd>
139
+ <dt>Entity
140
+ <span class="property-type">string</span>
141
+ </dt>
142
+ <dd> the entity name of SAP resource </dd>
143
+ <dt>EntityId
144
+ <span class="property-type">number | string</span>
145
+ </dt>
146
+ <dd> the id of the entity of SAP resource </dd>
147
+ <dt>bodyPost
148
+ <span class="property-type">object</span>
149
+ </dt>
150
+ <dd> the data of the entity </dd>
151
+ </dl>
152
+
153
+ <h3>Outputs</h3>
154
+ <ol class="node-ports">
155
+ <li>Standard output
156
+ <dl class="message-properties">
157
+ <dt>payload <span class="property-type">string</span></dt>
158
+ <dd>the standard output of the command.</dd>
159
+ </dl>
160
+ </li>
161
+ </ol>
162
+
163
+ <h3>Details</h3>
164
+ <p>this node is used to create the entity of SAP.
165
+ See the examples to understand how to use it.
166
+ </p>
167
+ <!-- <p><code>msg.payload</code> is used as the payload of the published message.
168
+ If it contains an Object it will be converted to a JSON string before being sent.
169
+ If it contains a binary Buffer the message will be published as-is.</p>
170
+ <p>The topic used can be configured in the node or, if left blank, can be set
171
+ by <code>msg.topic</code>.</p>
172
+ <p>Likewise the QoS and retain values can be configured in the node or, if left
173
+ blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
174
+
175
+ <h3>References</h3>
176
+ <ul>
177
+ <li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
178
+ <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>
179
+ </ul>
180
180
  </script>
package/nodes/SQLQuery.js CHANGED
@@ -1,46 +1,46 @@
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 SQLQuery(config) {
8
- RED.nodes.createNode(this, config);
9
- const node = this;
10
- // reset status
11
- node.status({});
12
-
13
- node.on('input', async (msg, send, done) => {
14
- // reset status
15
- node.status({});
16
- try {
17
- const data = msg[config.bodyPost];
18
- const params = {
19
- SqlCode: msg[config.sqlCode],
20
- };
21
-
22
- if (!params.SqlCode) {
23
- const missingParams = [];
24
- params.SqlCode ? null : missingParams.push('SqlCode');
25
- done(new Error(`Missing mandatory params: ${missingParams.join(',')}.`));
26
- return;
27
- }
28
-
29
- const options = { method: 'POST', hasRawQuery: false, isSQLQuery: true, data: data };
30
- const login = Support.login;
31
- const result = await Support.sendRequest({ node, msg, config, axios, login, options });
32
- msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
33
- msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
34
- msg.statusCode = result.status;
35
- if(msg.payload) {
36
- node.status({ fill: 'green', shape: 'dot', text: 'success' });
37
- node.send(msg);
38
- }
39
- } catch (error) {
40
- node.status({ fill: 'red', shape: 'dot', text: 'Error' });
41
- done(error);
42
- }
43
- });
44
- }
45
- RED.nodes.registerType('SQLQuery', SQLQuery, {});
46
- };
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 SQLQuery(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ // reset status
11
+ node.status({});
12
+
13
+ node.on('input', async (msg, send, done) => {
14
+ // reset status
15
+ node.status({});
16
+ try {
17
+ const data = msg[config.bodyPost];
18
+ const params = {
19
+ SqlCode: msg[config.sqlCode],
20
+ };
21
+
22
+ if (!params.SqlCode) {
23
+ const missingParams = [];
24
+ params.SqlCode ? null : missingParams.push('SqlCode');
25
+ done(new Error(`Missing mandatory params: ${missingParams.join(',')}.`));
26
+ return;
27
+ }
28
+
29
+ const options = { method: 'POST', hasRawQuery: false, isSQLQuery: true, data: data };
30
+ const login = Support.login;
31
+ const result = await Support.sendRequest({ node, msg, config, axios, login, options });
32
+ msg.payload = VerifyErrorSL(node, msg, result.data);//result.data;
33
+ msg.nextLink = result.data['odata.nextLink'] || result.data['@odata.nextLink'];
34
+ msg.statusCode = result.status;
35
+ if(msg.payload) {
36
+ node.status({ fill: 'green', shape: 'dot', text: 'success' });
37
+ node.send(msg);
38
+ }
39
+ } catch (error) {
40
+ node.status({ fill: 'red', shape: 'dot', text: 'Error' });
41
+ done(error);
42
+ }
43
+ });
44
+ }
45
+ RED.nodes.registerType('SQLQuery', SQLQuery, {});
46
+ };