@yousolution/node-red-contrib-you-sap-service-layer 0.0.4 → 0.1.0
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/CHANGELOG.md +11 -0
- package/data/package.json +1 -1
- package/nodes/SQLQuery.html +180 -0
- package/nodes/SQLQuery.js +43 -0
- package/nodes/closeSap.html +2 -2
- package/nodes/createSQLQuery.html +166 -0
- package/nodes/createSQLQuery.js +67 -0
- package/nodes/createSap.html +7 -7
- package/nodes/crossJoinSap.html +269 -263
- package/nodes/deleteSap.html +7 -7
- package/nodes/getSap.html +7 -7
- package/nodes/listSap.html +5 -5
- package/nodes/manipulateEntitySap.html +4 -4
- package/nodes/nextLink.html +10 -4
- package/nodes/nextLink.js +3 -3
- package/nodes/patchSap.html +6 -6
- package/nodes/serviceSap.html +9 -9
- package/nodes/support.js +23 -1
- package/package.json +4 -2
- package/test/authenticateSap.spec.js +46 -0
- package/test/createSQLQuery.spec.js +174 -0
- package/test/support.spec.js +205 -0
package/nodes/deleteSap.html
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
</div>
|
|
71
71
|
|
|
72
72
|
<div class="form-row">
|
|
73
|
-
<label for="node-input-type"><i class="fa fa-
|
|
73
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
74
74
|
<select name="node-input-entity" id="node-input-entity">
|
|
75
75
|
<option value="AccountCategory">AccountCategory</option>
|
|
76
76
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -276,35 +276,35 @@
|
|
|
276
276
|
</div>
|
|
277
277
|
|
|
278
278
|
<div class="form-row" style="display:none" id="container-udo">
|
|
279
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
279
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
280
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
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
284
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
285
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
|
-
<label for="node-input-type"><i class="fa fa-
|
|
289
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
290
290
|
<input type="text" id="node-input-entityId">
|
|
291
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
|
-
<label for="node-input-type"><i class="fa fa-
|
|
295
|
+
<label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
|
|
296
296
|
<input type="text" id="node-input-docEntry">
|
|
297
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
|
-
<label for="node-input-type"><i class="fa fa-
|
|
301
|
+
<label for="node-input-type"><i class="fa fa-key"></i> Code</label>
|
|
302
302
|
<input type="text" id="node-input-code">
|
|
303
303
|
<input type="hidden" id="node-input-code-type">
|
|
304
304
|
</div>
|
|
305
305
|
|
|
306
306
|
<div class="form-row">
|
|
307
|
-
<label for="node-input-type"><i class="fa fa-
|
|
307
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
308
308
|
<input type="text" id="node-input-headers">
|
|
309
309
|
<input type="hidden" id="node-input-headers-type">
|
|
310
310
|
</div>
|
package/nodes/getSap.html
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
</div>
|
|
96
96
|
|
|
97
97
|
<div class="form-row">
|
|
98
|
-
<label for="node-input-type"><i class="fa fa-
|
|
98
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
99
99
|
<select name="node-input-entity" id="node-input-entity">
|
|
100
100
|
<option value="AccountCategory">AccountCategory</option>
|
|
101
101
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -352,35 +352,35 @@
|
|
|
352
352
|
</div>
|
|
353
353
|
|
|
354
354
|
<div class="form-row" style="display:none" id="container-udo">
|
|
355
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
355
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
356
356
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
357
357
|
</div>
|
|
358
358
|
|
|
359
359
|
<div class="form-row" style="display:none" id="container-udt">
|
|
360
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
360
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
361
361
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
362
362
|
</div>
|
|
363
363
|
|
|
364
364
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
365
|
-
<label for="node-input-type"><i class="fa fa-
|
|
365
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
366
366
|
<input type="text" id="node-input-entityId">
|
|
367
367
|
<input type="hidden" id="node-input-entityId-type">
|
|
368
368
|
</div>
|
|
369
369
|
|
|
370
370
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
371
|
-
<label for="node-input-type"><i class="fa fa-
|
|
371
|
+
<label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
|
|
372
372
|
<input type="text" id="node-input-docEntry">
|
|
373
373
|
<input type="hidden" id="node-input-docEntry-type">
|
|
374
374
|
</div>
|
|
375
375
|
|
|
376
376
|
<div class="form-row" style="display:none" id="container-code">
|
|
377
|
-
<label for="node-input-type"><i class="fa fa-
|
|
377
|
+
<label for="node-input-type"><i class="fa fa-key"></i> Code</label>
|
|
378
378
|
<input type="text" id="node-input-code">
|
|
379
379
|
<input type="hidden" id="node-input-code-type">
|
|
380
380
|
</div>
|
|
381
381
|
|
|
382
382
|
<div class="form-row">
|
|
383
|
-
<label for="node-input-type"><i class="fa fa-
|
|
383
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
384
384
|
<input type="text" id="node-input-headers">
|
|
385
385
|
<input type="hidden" id="node-input-headers-type">
|
|
386
386
|
</div>
|
package/nodes/listSap.html
CHANGED
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
</div>
|
|
72
72
|
|
|
73
73
|
<div class="form-row">
|
|
74
|
-
<label for="node-input-type"><i class="fa fa-
|
|
74
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
75
75
|
<input type="text" id="node-input-headers">
|
|
76
76
|
<input type="hidden" id="node-input-headers-type">
|
|
77
77
|
</div>
|
|
78
78
|
|
|
79
79
|
<div class="form-row">
|
|
80
|
-
<label for="node-input-type"><i class="fa fa-
|
|
80
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> NextLink</label>
|
|
81
81
|
<input type="text" id="node-input-nextLink">
|
|
82
82
|
<input type="hidden" id="node-input-nextLink-type">
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
<div class="form-row">
|
|
86
|
-
<label for="node-input-type"><i class="fa fa-
|
|
86
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
87
87
|
<select name="node-input-entity" id="node-input-entity">
|
|
88
88
|
<option value="AccountCategory">AccountCategory</option>
|
|
89
89
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -338,12 +338,12 @@
|
|
|
338
338
|
</div>
|
|
339
339
|
|
|
340
340
|
<div class="form-row" style="display:none" id="container-udo">
|
|
341
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
341
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
342
342
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
343
343
|
</div>
|
|
344
344
|
|
|
345
345
|
<div class="form-row" style="display:none" id="container-udt">
|
|
346
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
346
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
347
347
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
348
348
|
</div>
|
|
349
349
|
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
</div>
|
|
93
93
|
|
|
94
94
|
<div class="form-row">
|
|
95
|
-
<label for="node-input-type"><i class="fa fa-
|
|
95
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
96
96
|
<select name="node-input-entity" id="node-input-entity">
|
|
97
97
|
<option></option>
|
|
98
98
|
</select>
|
|
@@ -105,19 +105,19 @@
|
|
|
105
105
|
</div>
|
|
106
106
|
|
|
107
107
|
<div class="form-row" id="container-entityId">
|
|
108
|
-
<label for="node-input-type"><i class="fa fa-
|
|
108
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
109
109
|
<input type="text" id="node-input-entityId">
|
|
110
110
|
<input type="hidden" id="node-input-entityId-type">
|
|
111
111
|
</div>
|
|
112
112
|
|
|
113
113
|
<div class="form-row">
|
|
114
|
-
<label for="node-input-type"><i class="fa fa-
|
|
114
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
115
115
|
<input type="text" id="node-input-headers">
|
|
116
116
|
<input type="hidden" id="node-input-headers-type">
|
|
117
117
|
</div>
|
|
118
118
|
|
|
119
119
|
<div class="form-row">
|
|
120
|
-
<label for="node-input-type"><i class="fa fa-
|
|
120
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPost</label>
|
|
121
121
|
<input type="text" id="node-input-bodyPost">
|
|
122
122
|
<input type="hidden" id="node-input-bodyPost-type">
|
|
123
123
|
</div>
|
package/nodes/nextLink.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
nextLink: {value: ''}
|
|
8
8
|
},
|
|
9
9
|
inputs:1,
|
|
10
|
-
outputs:
|
|
10
|
+
outputs:2,
|
|
11
11
|
icon: 'font-awesome/fa-arrows-h',
|
|
12
12
|
label: function() {
|
|
13
13
|
return this.name||"Next link";
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
35
|
<div class="form-row">
|
|
36
|
-
<label for="node-input-type"><i class="fa fa-
|
|
36
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> NextLink</label>
|
|
37
37
|
<input type="text" id="node-input-nextLink">
|
|
38
38
|
<input type="hidden" id="node-input-nextLink-type">
|
|
39
39
|
</div>
|
|
@@ -59,8 +59,14 @@
|
|
|
59
59
|
<ol class="node-ports">
|
|
60
60
|
<li>Standard output
|
|
61
61
|
<dl class="message-properties">
|
|
62
|
-
<dt>payload <span class="property-type">
|
|
63
|
-
<dd>the
|
|
62
|
+
<dt>payload <span class="property-type">msg</span></dt>
|
|
63
|
+
<dd>It returns the message with next link to the next page.</dd>
|
|
64
|
+
</dl>
|
|
65
|
+
</li>
|
|
66
|
+
<li>Standard output
|
|
67
|
+
<dl class="message-properties">
|
|
68
|
+
<dt>payload <span class="property-type">msg</span></dt>
|
|
69
|
+
<dd>It returns the message when the last page is reached.</dd>
|
|
64
70
|
</dl>
|
|
65
71
|
</li>
|
|
66
72
|
</ol>
|
package/nodes/nextLink.js
CHANGED
|
@@ -7,12 +7,12 @@ module.exports = function (RED) {
|
|
|
7
7
|
const nextLink = msg[config.nextLink];
|
|
8
8
|
|
|
9
9
|
if (!nextLink) {
|
|
10
|
+
node.send([null, msg]);
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
node.send(msg);
|
|
13
|
+
|
|
14
|
+
node.send([msg, null]);
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
RED.nodes.registerType('nextLink', NextLinkNode, {});
|
|
17
18
|
};
|
|
18
|
-
|
package/nodes/patchSap.html
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</div>
|
|
86
86
|
|
|
87
87
|
<div class="form-row">
|
|
88
|
-
<label for="node-input-type"><i class="fa fa-
|
|
88
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
89
89
|
<select name="node-input-entity" id="node-input-entity">
|
|
90
90
|
<option value="AccountCategory">AccountCategory</option>
|
|
91
91
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -341,31 +341,31 @@
|
|
|
341
341
|
</div>
|
|
342
342
|
|
|
343
343
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
344
|
-
<label for="node-input-type"><i class="fa fa-
|
|
344
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
345
345
|
<input type="text" id="node-input-entityId">
|
|
346
346
|
<input type="hidden" id="node-input-entityId-type">
|
|
347
347
|
</div>
|
|
348
348
|
|
|
349
349
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
350
|
-
<label for="node-input-type"><i class="fa fa-
|
|
350
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> DocEntry</label>
|
|
351
351
|
<input type="text" id="node-input-docEntry">
|
|
352
352
|
<input type="hidden" id="node-input-docEntry-type">
|
|
353
353
|
</div>
|
|
354
354
|
|
|
355
355
|
<div class="form-row" style="display:none" id="container-code">
|
|
356
|
-
<label for="node-input-type"><i class="fa fa-
|
|
356
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Code</label>
|
|
357
357
|
<input type="text" id="node-input-code">
|
|
358
358
|
<input type="hidden" id="node-input-code-type">
|
|
359
359
|
</div>
|
|
360
360
|
|
|
361
361
|
<div class="form-row">
|
|
362
|
-
<label for="node-input-type"><i class="fa fa-
|
|
362
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
363
363
|
<input type="text" id="node-input-headers">
|
|
364
364
|
<input type="hidden" id="node-input-headers-type">
|
|
365
365
|
</div>
|
|
366
366
|
|
|
367
367
|
<div class="form-row">
|
|
368
|
-
<label for="node-input-type"><i class="fa fa-
|
|
368
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPatch</label>
|
|
369
369
|
<input type="text" id="node-input-bodyPatch">
|
|
370
370
|
<input type="hidden" id="node-input-bodyPatch-type">
|
|
371
371
|
</div>
|
package/nodes/serviceSap.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// docEntry: {value: ''},
|
|
22
22
|
// code: {value: ''},
|
|
23
23
|
headers: {value: ''},
|
|
24
|
-
|
|
24
|
+
bodyPost: {value: ''}
|
|
25
25
|
},
|
|
26
26
|
inputs:1,
|
|
27
27
|
outputs:1,
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
value: 'headers'
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
$("#node-input-
|
|
61
|
+
$("#node-input-bodyPost").typedInput({
|
|
62
62
|
type:"msg",
|
|
63
63
|
types:["msg"],
|
|
64
|
-
typeField: "#node-input-
|
|
65
|
-
value: '
|
|
64
|
+
typeField: "#node-input-bodyPost-type",
|
|
65
|
+
value: 'bodyPost'
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
// jQuery("#node-input-entity").change(function() {
|
|
@@ -147,15 +147,15 @@
|
|
|
147
147
|
</div>
|
|
148
148
|
|
|
149
149
|
<div class="form-row">
|
|
150
|
-
<label for="node-input-type"><i class="fa fa-cog"></i>
|
|
151
|
-
<input type="text" id="node-input-
|
|
152
|
-
<input type="hidden" id="node-input-
|
|
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
153
|
</div>
|
|
154
154
|
</script>
|
|
155
155
|
|
|
156
156
|
<!-- Documentation -->
|
|
157
157
|
<script type="text/html" data-help-name="serviceSap">
|
|
158
|
-
<p>
|
|
158
|
+
<p>Post action</p>
|
|
159
159
|
|
|
160
160
|
<h3>Inputs</h3>
|
|
161
161
|
<dl class="message-properties">
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
<span class="property-type">number | string</span>
|
|
172
172
|
</dt>
|
|
173
173
|
<dd> the id of the entity of SAP </dd>
|
|
174
|
-
<dt>
|
|
174
|
+
<dt>bodyPost
|
|
175
175
|
<span class="property-type">object</span>
|
|
176
176
|
</dt>
|
|
177
177
|
<dd> data to update to the entity </dd>
|
package/nodes/support.js
CHANGED
|
@@ -164,6 +164,7 @@ function generateRequest(node, msg, config, options) {
|
|
|
164
164
|
options.isCrossJoin = options.isCrossJoin || false;
|
|
165
165
|
options.isManipulate = options.isManipulate || false;
|
|
166
166
|
options.isService = options.isService || false;
|
|
167
|
+
options.isCreateSQLQuery = options.isCreateSQLQuery || false;
|
|
167
168
|
options.service = options.service || null;
|
|
168
169
|
options.manipulateMethod = options.manipulateMethod || null;
|
|
169
170
|
|
|
@@ -171,6 +172,7 @@ function generateRequest(node, msg, config, options) {
|
|
|
171
172
|
|
|
172
173
|
let rawQuery = null;
|
|
173
174
|
let url;
|
|
175
|
+
|
|
174
176
|
if (options.hasRawQuery) {
|
|
175
177
|
try {
|
|
176
178
|
rawQuery = eval(config.query);
|
|
@@ -180,7 +182,7 @@ function generateRequest(node, msg, config, options) {
|
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
let entity = config.entity;
|
|
183
|
-
if (!entity && !options.isService) {
|
|
185
|
+
if (!entity && !options.isService && !options.isCreateSQLQuery && !options.isSQLQuery) {
|
|
184
186
|
throw new Error('Missing entity');
|
|
185
187
|
}
|
|
186
188
|
|
|
@@ -214,6 +216,13 @@ function generateRequest(node, msg, config, options) {
|
|
|
214
216
|
url = `https://${host}:${port}/b1s/${version}/$crossjoin(${entity})`;
|
|
215
217
|
}
|
|
216
218
|
|
|
219
|
+
if (options.isSQLQuery) {
|
|
220
|
+
if (!config.sqlCode) {
|
|
221
|
+
throw new Error('Missing sqlCode');
|
|
222
|
+
}
|
|
223
|
+
url = `https://${host}:${port}/b1s/${version}/SQLQueries('${msg[config.sqlCode]}')/List`;
|
|
224
|
+
}
|
|
225
|
+
|
|
217
226
|
if (odataNextLink) {
|
|
218
227
|
url = `https://${host}:${port}/b1s/${version}/${odataNextLink}`;
|
|
219
228
|
}
|
|
@@ -268,6 +277,19 @@ function generateRequest(node, msg, config, options) {
|
|
|
268
277
|
url = `https://${host}:${port}/b1s/${version}/${config.service}`;
|
|
269
278
|
}
|
|
270
279
|
|
|
280
|
+
if (options.isCreateSQLQuery) {
|
|
281
|
+
if (!config.sqlCode) {
|
|
282
|
+
throw new Error('Missing sqlCode');
|
|
283
|
+
}
|
|
284
|
+
if (!config.sqlName) {
|
|
285
|
+
throw new Error('Missing sqlName');
|
|
286
|
+
}
|
|
287
|
+
if (!config.sqlText) {
|
|
288
|
+
throw new Error('Missing sqlText');
|
|
289
|
+
}
|
|
290
|
+
url = `https://${host}:${port}/b1s/${version}/SQLQueries`;
|
|
291
|
+
}
|
|
292
|
+
|
|
271
293
|
if (rawQuery && !odataNextLink) {
|
|
272
294
|
const urlOdata = buildQuery(rawQuery);
|
|
273
295
|
msg.odata = urlOdata;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yousolution/node-red-contrib-you-sap-service-layer",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Unofficial module SAP Service Layer for NODE-RED",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"crossJoinSap": "/nodes/crossJoinSap.js",
|
|
31
31
|
"nextLink": "/nodes/nextLink.js",
|
|
32
32
|
"serviceSap": "/nodes/serviceSap.js",
|
|
33
|
-
"manipulateEntitySap": "/nodes/manipulateEntitySap.js"
|
|
33
|
+
"manipulateEntitySap": "/nodes/manipulateEntitySap.js",
|
|
34
|
+
"createSQLQuery": "/nodes/createSQLQuery.js",
|
|
35
|
+
"SQLQuery": "/nodes/SQLQuery.js"
|
|
34
36
|
}
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
@@ -144,6 +144,52 @@ describe('authenticateSap Node', () => {
|
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
+
it('should generic error ', (done) => {
|
|
148
|
+
const flow = [
|
|
149
|
+
{
|
|
150
|
+
id: 'n1',
|
|
151
|
+
type: 'authenticateSap',
|
|
152
|
+
name: 'authenticateSap',
|
|
153
|
+
wires: [['n2']],
|
|
154
|
+
z: 'flow',
|
|
155
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
156
|
+
},
|
|
157
|
+
{ id: 'n2', type: 'helper' },
|
|
158
|
+
];
|
|
159
|
+
helper.load(authenticateSap, flow, () => {
|
|
160
|
+
const n2 = helper.getNode('n2');
|
|
161
|
+
const n1 = helper.getNode('n1');
|
|
162
|
+
n1.credentials.user = 'user';
|
|
163
|
+
n1.credentials.password = 'password';
|
|
164
|
+
n1.credentials.company = 'company';
|
|
165
|
+
|
|
166
|
+
sinon.stub(Support, 'login').rejects(new Error('Custom error'));
|
|
167
|
+
|
|
168
|
+
// n1.context().flow.set(`_YOU_SapServiceLayer_${n1.id}.headers`, true, 'memory1', function (error) {
|
|
169
|
+
// // console.log(error);
|
|
170
|
+
// });
|
|
171
|
+
|
|
172
|
+
n1.receive({});
|
|
173
|
+
|
|
174
|
+
n2.on('input', (msg) => {
|
|
175
|
+
try {
|
|
176
|
+
msg.should.have.property('payload', new Error('Custom error'));
|
|
177
|
+
done();
|
|
178
|
+
} catch (err) {
|
|
179
|
+
done(err);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
n1.on('call:error', (error) => {
|
|
184
|
+
try {
|
|
185
|
+
error.should.have.property('firstArg', new Error('Custom error'));
|
|
186
|
+
} catch (err) {
|
|
187
|
+
done(err);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
147
193
|
it('should have without headers connected', (done) => {
|
|
148
194
|
const flow = [
|
|
149
195
|
{
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const should = require('should');
|
|
2
|
+
const helper = require('node-red-node-test-helper');
|
|
3
|
+
const createSQLQuery = require('../nodes/createSQLQuery');
|
|
4
|
+
const Context = require('../node_modules/./@node-red/runtime/lib/nodes/context/index');
|
|
5
|
+
const sinon = require('sinon');
|
|
6
|
+
const Support = require('../nodes/support');
|
|
7
|
+
|
|
8
|
+
helper.init(require.resolve('node-red'));
|
|
9
|
+
|
|
10
|
+
describe('createSQLQuery Node', () => {
|
|
11
|
+
beforeEach((done) => {
|
|
12
|
+
helper.startServer(done);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function initContext(done) {
|
|
16
|
+
Context.init({
|
|
17
|
+
contextStorage: {
|
|
18
|
+
memory0: {
|
|
19
|
+
module: 'memory',
|
|
20
|
+
},
|
|
21
|
+
memory1: {
|
|
22
|
+
module: 'memory',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
Context.load().then(function () {
|
|
27
|
+
done();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
afterEach((done) => {
|
|
32
|
+
helper
|
|
33
|
+
.unload()
|
|
34
|
+
.then(function () {
|
|
35
|
+
return Context.clean({ allNodes: {} });
|
|
36
|
+
})
|
|
37
|
+
.then(function () {
|
|
38
|
+
return Context.close();
|
|
39
|
+
})
|
|
40
|
+
.then(function () {
|
|
41
|
+
helper.stopServer(done);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Restore the default sandbox here
|
|
45
|
+
sinon.restore();
|
|
46
|
+
|
|
47
|
+
// helper.unload();
|
|
48
|
+
// helper.stopServer(done);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should be loaded', (done) => {
|
|
52
|
+
const flow = [
|
|
53
|
+
{
|
|
54
|
+
id: 'n1',
|
|
55
|
+
type: 'createSQLQuery',
|
|
56
|
+
name: 'createSQLQuery',
|
|
57
|
+
wires: [['n2']],
|
|
58
|
+
z: 'flow',
|
|
59
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
helper.load(createSQLQuery, flow, () => {
|
|
64
|
+
initContext(function () {
|
|
65
|
+
const n1 = helper.getNode('n1');
|
|
66
|
+
try {
|
|
67
|
+
n1.should.have.property('name', 'createSQLQuery');
|
|
68
|
+
done();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
done(err);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should have correct request with data', (done) => {
|
|
77
|
+
const flow = [
|
|
78
|
+
{
|
|
79
|
+
id: 'n1',
|
|
80
|
+
type: 'createSQLQuery',
|
|
81
|
+
name: 'createSQLQuery',
|
|
82
|
+
wires: [['n2']],
|
|
83
|
+
z: 'flow',
|
|
84
|
+
sqlCode: 'sqlCode',
|
|
85
|
+
sqlName: 'sqlName',
|
|
86
|
+
sqlText: 'sqlText',
|
|
87
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
88
|
+
},
|
|
89
|
+
{ id: 'n2', type: 'helper' },
|
|
90
|
+
];
|
|
91
|
+
helper.load(createSQLQuery, flow, () => {
|
|
92
|
+
const n2 = helper.getNode('n2');
|
|
93
|
+
const n1 = helper.getNode('n1');
|
|
94
|
+
|
|
95
|
+
sinon.stub(Support, 'sendRequest').resolves('ok');
|
|
96
|
+
|
|
97
|
+
n1.receive({ sqlCode: 'code', sqlName: 'name', sqlText: 'text' });
|
|
98
|
+
|
|
99
|
+
n2.on('input', (msg) => {
|
|
100
|
+
try {
|
|
101
|
+
msg.should.have.property('_msgid');
|
|
102
|
+
msg.should.have.property('payload', 'ok');
|
|
103
|
+
done();
|
|
104
|
+
} catch (err) {
|
|
105
|
+
done(err);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// it('should have request without data', (done) => {
|
|
112
|
+
// const flow = [
|
|
113
|
+
// {
|
|
114
|
+
// id: 'n1',
|
|
115
|
+
// type: 'serviceSap',
|
|
116
|
+
// name: 'serviceSap',
|
|
117
|
+
// wires: [['n2']],
|
|
118
|
+
// z: 'flow',
|
|
119
|
+
// bodyPost: 'data',
|
|
120
|
+
// rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
121
|
+
// },
|
|
122
|
+
// { id: 'n2', type: 'helper' },
|
|
123
|
+
// ];
|
|
124
|
+
// helper.load(serviceSap, flow, () => {
|
|
125
|
+
// const n2 = helper.getNode('n2');
|
|
126
|
+
// const n1 = helper.getNode('n1');
|
|
127
|
+
|
|
128
|
+
// sinon.stub(Support, 'sendRequest').resolves('ok');
|
|
129
|
+
// n1.receive({});
|
|
130
|
+
|
|
131
|
+
// n2.on('input', (msg) => {
|
|
132
|
+
// try {
|
|
133
|
+
// msg.should.have.property('_msgid');
|
|
134
|
+
// msg.should.have.property('payload', 'ok');
|
|
135
|
+
// done();
|
|
136
|
+
// } catch (err) {
|
|
137
|
+
// done(err);
|
|
138
|
+
// }
|
|
139
|
+
// });
|
|
140
|
+
// });
|
|
141
|
+
// });
|
|
142
|
+
|
|
143
|
+
it('should handle the error', (done) => {
|
|
144
|
+
const flow = [
|
|
145
|
+
{
|
|
146
|
+
id: 'n1',
|
|
147
|
+
type: 'createSQLQuery',
|
|
148
|
+
name: 'createSQLQuery',
|
|
149
|
+
wires: [['n2']],
|
|
150
|
+
z: 'flow',
|
|
151
|
+
sqlCode: 'sqlCode',
|
|
152
|
+
sqlName: 'sqlName',
|
|
153
|
+
sqlText: 'sqlText',
|
|
154
|
+
rules: [{ t: 'set', p: 'payload', to: '#:(memory1)::flowValue', tot: 'flow' }],
|
|
155
|
+
},
|
|
156
|
+
{ id: 'n2', type: 'helper' },
|
|
157
|
+
];
|
|
158
|
+
helper.load(createSQLQuery, flow, () => {
|
|
159
|
+
const n2 = helper.getNode('n2');
|
|
160
|
+
const n1 = helper.getNode('n1');
|
|
161
|
+
|
|
162
|
+
const expected = new Error('Missing mandatory params: SqlCode.');
|
|
163
|
+
|
|
164
|
+
sinon.stub(Support, 'sendRequest').rejects(expected);
|
|
165
|
+
|
|
166
|
+
n1.receive({ sqlName: 'name', sqlText: 'text' });
|
|
167
|
+
|
|
168
|
+
n1.on('call:error', (error) => {
|
|
169
|
+
should.deepEqual(error.args[0], expected);
|
|
170
|
+
done();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|