node-red-contrib-mobius-flow-base 3.2.0 → 3.3.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/dist/engine-api-calls.js +26 -6
- package/dist/nodes/common/mobsearch.js +7 -3
- package/dist/nodes/mobius-clear-resource.js +96 -65
- package/dist/nodes/mobius-discover.html +43 -19
- package/dist/nodes/mobius-discover.js +8 -0
- package/dist/nodes/mobius-filter-by-rid-value.js +51 -3
- package/dist/nodes/mobius-flow-inject.js +40 -12
- package/dist/nodes/mobius-get-multi-object.html +98 -76
- package/dist/nodes/mobius-get-multi-object.js +22 -19
- package/dist/nodes/mobius-get-multi-resource.html +99 -75
- package/dist/nodes/mobius-get-multi-resource.js +22 -19
- package/dist/nodes/mobius-get-object.js +39 -7
- package/dist/nodes/mobius-get-resource.js +39 -7
- package/dist/nodes/mobius-set-multi-resource.js +73 -53
- package/dist/nodes/mobius-set-resource.js +57 -11
- package/package.json +1 -1
|
@@ -38,6 +38,10 @@ module.exports = function (RED) {
|
|
|
38
38
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
39
39
|
var node = this;
|
|
40
40
|
|
|
41
|
+
const uriValidTest = new RegExp(
|
|
42
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}$`
|
|
43
|
+
);
|
|
44
|
+
|
|
41
45
|
if (node.serviceConn) {
|
|
42
46
|
node.status({
|
|
43
47
|
fill: 'red',
|
|
@@ -46,12 +50,28 @@ module.exports = function (RED) {
|
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
node.on('input', function (msg) {
|
|
49
|
-
let uri =
|
|
53
|
+
let uri = '';
|
|
54
|
+
if (msg.hasOwnProperty('topic') && uriValidTest.test(msg.topic)) {
|
|
55
|
+
uri = msg.topic;
|
|
56
|
+
}
|
|
57
|
+
if (uriValidTest.test(node.mobject)) {
|
|
58
|
+
uri = node.mobject;
|
|
59
|
+
}
|
|
50
60
|
if (
|
|
51
61
|
msg.hasOwnProperty('topic') &&
|
|
52
|
-
|
|
62
|
+
uriValidTest.test(msg.topic) &&
|
|
63
|
+
uriValidTest.test(node.mobject)
|
|
53
64
|
) {
|
|
54
|
-
|
|
65
|
+
node.warn('URI defined in config and input topic. Using config URI.');
|
|
66
|
+
}
|
|
67
|
+
if (uri === '') {
|
|
68
|
+
node.status({
|
|
69
|
+
fill: 'yellow',
|
|
70
|
+
shape: 'dot',
|
|
71
|
+
text: 'Error: URI invalid',
|
|
72
|
+
});
|
|
73
|
+
node.error('Error: URI invalid');
|
|
74
|
+
return;
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
node.status({
|
|
@@ -64,12 +84,24 @@ module.exports = function (RED) {
|
|
|
64
84
|
node.status({
|
|
65
85
|
fill: 'yellow',
|
|
66
86
|
shape: 'dot',
|
|
67
|
-
text:
|
|
87
|
+
text: (() => {
|
|
88
|
+
if (err.response.status === 404) {
|
|
89
|
+
return `Error: Object not found`;
|
|
90
|
+
} else {
|
|
91
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
92
|
+
}
|
|
93
|
+
})(),
|
|
68
94
|
});
|
|
69
95
|
node.error(
|
|
70
|
-
|
|
71
|
-
err.
|
|
72
|
-
|
|
96
|
+
(() => {
|
|
97
|
+
if (err.response.status === 404) {
|
|
98
|
+
return `Error: Object not found`;
|
|
99
|
+
} else {
|
|
100
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
101
|
+
err.message ? err.message : ''
|
|
102
|
+
}`;
|
|
103
|
+
}
|
|
104
|
+
})()
|
|
73
105
|
);
|
|
74
106
|
if (node.detailedOutput === true) {
|
|
75
107
|
node.send([
|
|
@@ -35,6 +35,10 @@ module.exports = function (RED) {
|
|
|
35
35
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
36
36
|
var node = this;
|
|
37
37
|
|
|
38
|
+
const uriValidTest = new RegExp(
|
|
39
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{2}$`
|
|
40
|
+
);
|
|
41
|
+
|
|
38
42
|
if (node.serviceConn) {
|
|
39
43
|
node.status({
|
|
40
44
|
fill: 'red',
|
|
@@ -43,12 +47,28 @@ module.exports = function (RED) {
|
|
|
43
47
|
});
|
|
44
48
|
|
|
45
49
|
node.on('input', function (msg) {
|
|
46
|
-
let uri =
|
|
50
|
+
let uri = '';
|
|
51
|
+
if (msg.hasOwnProperty('topic') && uriValidTest.test(msg.topic)) {
|
|
52
|
+
uri = msg.topic;
|
|
53
|
+
}
|
|
54
|
+
if (uriValidTest.test(node.resource)) {
|
|
55
|
+
uri = node.resource;
|
|
56
|
+
}
|
|
47
57
|
if (
|
|
48
58
|
msg.hasOwnProperty('topic') &&
|
|
49
|
-
|
|
59
|
+
uriValidTest.test(msg.topic) &&
|
|
60
|
+
uriValidTest.test(node.resource)
|
|
50
61
|
) {
|
|
51
|
-
|
|
62
|
+
node.warn('URI defined in config and input topic. Using config URI.');
|
|
63
|
+
}
|
|
64
|
+
if (uri === '') {
|
|
65
|
+
node.status({
|
|
66
|
+
fill: 'yellow',
|
|
67
|
+
shape: 'dot',
|
|
68
|
+
text: 'Error: URI invalid',
|
|
69
|
+
});
|
|
70
|
+
node.error('Error: URI invalid');
|
|
71
|
+
return;
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
node.status({
|
|
@@ -61,12 +81,24 @@ module.exports = function (RED) {
|
|
|
61
81
|
node.status({
|
|
62
82
|
fill: 'yellow',
|
|
63
83
|
shape: 'dot',
|
|
64
|
-
text:
|
|
84
|
+
text: (() => {
|
|
85
|
+
if (err.response.status === 404) {
|
|
86
|
+
return `Error: Resource not found`;
|
|
87
|
+
} else {
|
|
88
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
89
|
+
}
|
|
90
|
+
})(),
|
|
65
91
|
});
|
|
66
92
|
node.error(
|
|
67
|
-
|
|
68
|
-
err.
|
|
69
|
-
|
|
93
|
+
(() => {
|
|
94
|
+
if (err.response.status === 404) {
|
|
95
|
+
return `Error: Resource not found`;
|
|
96
|
+
} else {
|
|
97
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
98
|
+
err.message ? err.message : ''
|
|
99
|
+
}`;
|
|
100
|
+
}
|
|
101
|
+
})()
|
|
70
102
|
);
|
|
71
103
|
if (node.detailedOutput === true) {
|
|
72
104
|
node.send([
|
|
@@ -35,6 +35,10 @@ module.exports = function (RED) {
|
|
|
35
35
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
36
36
|
var node = this;
|
|
37
37
|
|
|
38
|
+
const uriValidTest = new RegExp(
|
|
39
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}$`
|
|
40
|
+
);
|
|
41
|
+
|
|
38
42
|
if (node.serviceConn) {
|
|
39
43
|
node.status({
|
|
40
44
|
fill: 'red',
|
|
@@ -43,71 +47,87 @@ module.exports = function (RED) {
|
|
|
43
47
|
});
|
|
44
48
|
|
|
45
49
|
node.on('input', function (msg) {
|
|
46
|
-
let uri = node.mobject;
|
|
47
50
|
let value = null;
|
|
51
|
+
|
|
52
|
+
let uri = '';
|
|
53
|
+
if (msg.hasOwnProperty('topic') && uriValidTest.test(msg.topic)) {
|
|
54
|
+
uri = msg.topic;
|
|
55
|
+
}
|
|
56
|
+
if (uriValidTest.test(node.mobject)) {
|
|
57
|
+
uri = node.mobject;
|
|
58
|
+
}
|
|
48
59
|
if (
|
|
49
60
|
msg.hasOwnProperty('topic') &&
|
|
50
|
-
|
|
61
|
+
uriValidTest.test(msg.topic) &&
|
|
62
|
+
uriValidTest.test(node.mobject)
|
|
51
63
|
) {
|
|
52
|
-
|
|
64
|
+
node.warn('URI defined in config and input topic. Using config URI.');
|
|
65
|
+
}
|
|
66
|
+
if (uri === '') {
|
|
67
|
+
node.status({
|
|
68
|
+
fill: 'yellow',
|
|
69
|
+
shape: 'dot',
|
|
70
|
+
text: 'Error: URI invalid',
|
|
71
|
+
});
|
|
72
|
+
node.error('Error: URI invalid');
|
|
73
|
+
return;
|
|
53
74
|
}
|
|
75
|
+
|
|
54
76
|
if (msg.hasOwnProperty('payload')) {
|
|
55
77
|
value = msg.payload;
|
|
56
78
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
79
|
+
node.status({
|
|
80
|
+
fill: 'green',
|
|
81
|
+
shape: 'ring',
|
|
82
|
+
text: 'Busy',
|
|
83
|
+
});
|
|
63
84
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
node.serviceConn.multiWriteResourceValue(
|
|
86
|
+
uri,
|
|
87
|
+
value,
|
|
88
|
+
(err, response) => {
|
|
89
|
+
if (err) {
|
|
90
|
+
node.status({
|
|
91
|
+
fill: 'yellow',
|
|
92
|
+
shape: 'dot',
|
|
93
|
+
text: `Error: ${err.code ? err.code : 'Unknown'}`,
|
|
94
|
+
});
|
|
95
|
+
node.error(
|
|
96
|
+
`Mobius error writing multiple resources: ${
|
|
97
|
+
err.code ? err.code : 'Unknown'
|
|
98
|
+
}, ${err.message ? err.message : ''}`
|
|
99
|
+
);
|
|
100
|
+
if (node.detailedOutput === true) {
|
|
101
|
+
node.send([
|
|
102
|
+
null,
|
|
103
|
+
{
|
|
104
|
+
...msg,
|
|
105
|
+
topic: uri,
|
|
106
|
+
payload: { error: true, response: err },
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
node.status({
|
|
112
|
+
fill: 'green',
|
|
113
|
+
shape: 'dot',
|
|
114
|
+
text: 'OK',
|
|
115
|
+
});
|
|
116
|
+
if (node.detailedOutput === true) {
|
|
117
|
+
node.send([
|
|
118
|
+
{ ...msg, topic: uri, payload: response.data },
|
|
119
|
+
{
|
|
120
|
+
...msg,
|
|
121
|
+
topic: uri,
|
|
122
|
+
payload: { error: false, response: response },
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
89
125
|
} else {
|
|
90
|
-
node.
|
|
91
|
-
fill: 'green',
|
|
92
|
-
shape: 'dot',
|
|
93
|
-
text: 'OK',
|
|
94
|
-
});
|
|
95
|
-
if (node.detailedOutput === true) {
|
|
96
|
-
node.send([
|
|
97
|
-
{ ...msg, topic: uri, payload: response.data },
|
|
98
|
-
{
|
|
99
|
-
...msg,
|
|
100
|
-
topic: uri,
|
|
101
|
-
payload: { error: false, response: response },
|
|
102
|
-
},
|
|
103
|
-
]);
|
|
104
|
-
} else {
|
|
105
|
-
node.send([{ ...msg, topic: uri, payload: response.data }]);
|
|
106
|
-
}
|
|
126
|
+
node.send([{ ...msg, topic: uri, payload: response.data }]);
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
}
|
|
130
|
+
);
|
|
111
131
|
});
|
|
112
132
|
|
|
113
133
|
node.serviceConn.register(node);
|
|
@@ -36,6 +36,10 @@ module.exports = function (RED) {
|
|
|
36
36
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
37
37
|
var node = this;
|
|
38
38
|
|
|
39
|
+
const uriValidTest = new RegExp(
|
|
40
|
+
`^[0-9A-Fa-f]{6}/[0-9A-Fa-f]{3}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{4}/[0-9A-Fa-f]{2}$`
|
|
41
|
+
);
|
|
42
|
+
|
|
39
43
|
if (node.serviceConn) {
|
|
40
44
|
node.status({
|
|
41
45
|
fill: 'red',
|
|
@@ -44,15 +48,33 @@ module.exports = function (RED) {
|
|
|
44
48
|
});
|
|
45
49
|
|
|
46
50
|
node.on('input', function (msg) {
|
|
47
|
-
let uri = node.resource;
|
|
48
51
|
let value = null;
|
|
49
52
|
let pri = parseInt(node.priority);
|
|
53
|
+
|
|
54
|
+
let uri = '';
|
|
55
|
+
if (msg.hasOwnProperty('topic') && uriValidTest.test(msg.topic)) {
|
|
56
|
+
uri = msg.topic;
|
|
57
|
+
}
|
|
58
|
+
if (uriValidTest.test(node.resource)) {
|
|
59
|
+
uri = node.resource;
|
|
60
|
+
}
|
|
50
61
|
if (
|
|
51
62
|
msg.hasOwnProperty('topic') &&
|
|
52
|
-
|
|
63
|
+
uriValidTest.test(msg.topic) &&
|
|
64
|
+
uriValidTest.test(node.resource)
|
|
53
65
|
) {
|
|
54
|
-
|
|
66
|
+
node.warn('URI defined in config and input topic. Using config URI.');
|
|
55
67
|
}
|
|
68
|
+
if (uri === '') {
|
|
69
|
+
node.status({
|
|
70
|
+
fill: 'yellow',
|
|
71
|
+
shape: 'dot',
|
|
72
|
+
text: 'Error: URI invalid',
|
|
73
|
+
});
|
|
74
|
+
node.error('Error: URI invalid');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
56
78
|
if (msg.hasOwnProperty('payload')) {
|
|
57
79
|
value = msg.payload;
|
|
58
80
|
}
|
|
@@ -75,12 +97,24 @@ module.exports = function (RED) {
|
|
|
75
97
|
node.status({
|
|
76
98
|
fill: 'yellow',
|
|
77
99
|
shape: 'dot',
|
|
78
|
-
text:
|
|
100
|
+
text: (() => {
|
|
101
|
+
if (err.response.status === 404) {
|
|
102
|
+
return `Error: Resource not found`;
|
|
103
|
+
} else {
|
|
104
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
105
|
+
}
|
|
106
|
+
})(),
|
|
79
107
|
});
|
|
80
108
|
node.error(
|
|
81
|
-
|
|
82
|
-
err.
|
|
83
|
-
|
|
109
|
+
(() => {
|
|
110
|
+
if (err.response.status === 404) {
|
|
111
|
+
return `Error: Resource not found`;
|
|
112
|
+
} else {
|
|
113
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
114
|
+
err.message ? err.message : ''
|
|
115
|
+
}`;
|
|
116
|
+
}
|
|
117
|
+
})()
|
|
84
118
|
);
|
|
85
119
|
if (node.detailedOutput === true) {
|
|
86
120
|
node.send([
|
|
@@ -144,12 +178,24 @@ module.exports = function (RED) {
|
|
|
144
178
|
node.status({
|
|
145
179
|
fill: 'yellow',
|
|
146
180
|
shape: 'dot',
|
|
147
|
-
text:
|
|
181
|
+
text: (() => {
|
|
182
|
+
if (err.response.status === 404) {
|
|
183
|
+
return `Error: Resource not found`;
|
|
184
|
+
} else {
|
|
185
|
+
return `Error: ${err.code ? err.code : 'Unknown'}`;
|
|
186
|
+
}
|
|
187
|
+
})(),
|
|
148
188
|
});
|
|
149
189
|
node.error(
|
|
150
|
-
|
|
151
|
-
err.
|
|
152
|
-
|
|
190
|
+
(() => {
|
|
191
|
+
if (err.response.status === 404) {
|
|
192
|
+
return `Error: Resource not found`;
|
|
193
|
+
} else {
|
|
194
|
+
return `Error: ${err.code ? err.code : 'Unknown'}, ${
|
|
195
|
+
err.message ? err.message : ''
|
|
196
|
+
}`;
|
|
197
|
+
}
|
|
198
|
+
})()
|
|
153
199
|
);
|
|
154
200
|
node.send([
|
|
155
201
|
null,
|