1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into repackage

This commit is contained in:
Nick O'Leary 2018-08-24 14:13:09 +01:00
commit 79e004a040
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 169 additions and 31 deletions

View File

@ -1,3 +1,12 @@
#### 0.19.2: Maintenance Release
- Ensure node default colour is used if palette.theme has no match
- fix lost messages / properties in TCPRequest Node; closes #1863 (#1864)
- Fix typo in template.html
- Improve error reporting from context plugin loading
- Prevent no-op edit of node marking as changed due to icon
- Change node must handle empty rule set
#### 0.19.1: Maintenance Release #### 0.19.1: Maintenance Release
- Pull in latest twitter node - Pull in latest twitter node

View File

@ -24,7 +24,7 @@
} }
], ],
"dependencies": { "dependencies": {
"ajv": "6.5.2", "ajv": "6.5.3",
"basic-auth": "2.0.0", "basic-auth": "2.0.0",
"bcryptjs": "2.4.3", "bcryptjs": "2.4.3",
"body-parser": "1.18.3", "body-parser": "1.18.3",
@ -48,7 +48,7 @@
"media-typer": "0.3.0", "media-typer": "0.3.0",
"memorystore": "1.6.0", "memorystore": "1.6.0",
"mime": "1.4.1", "mime": "1.4.1",
"mqtt": "2.18.3", "mqtt": "2.18.5",
"multer": "1.3.1", "multer": "1.3.1",
"mustache": "2.3.1", "mustache": "2.3.1",
"node-red-node-email": "0.1.*", "node-red-node-email": "0.1.*",
@ -63,9 +63,9 @@
"passport-oauth2-client-password": "0.1.2", "passport-oauth2-client-password": "0.1.2",
"raw-body": "2.3.3", "raw-body": "2.3.3",
"request": "2.88.0", "request": "2.88.0",
"semver": "5.5.0", "semver": "5.5.1",
"sentiment": "2.1.0", "sentiment": "2.1.0",
"uglify-js": "3.4.7", "uglify-js": "3.4.8",
"when": "3.7.8", "when": "3.7.8",
"ws": "1.1.5", "ws": "1.1.5",
"xml2js": "0.4.19" "xml2js": "0.4.19"

View File

@ -800,6 +800,7 @@ RED.utils = (function() {
var paletteTheme = RED.settings.theme('palette.theme') || []; var paletteTheme = RED.settings.theme('palette.theme') || [];
if (paletteTheme.length > 0) { if (paletteTheme.length > 0) {
if (!nodeColorCache.hasOwnProperty(type)) { if (!nodeColorCache.hasOwnProperty(type)) {
nodeColorCache[type] = def.color;
var l = paletteTheme.length; var l = paletteTheme.length;
for (var i = 0; i < l; i++ ){ for (var i = 0; i < l; i++ ){
var themeRule = paletteTheme[i]; var themeRule = paletteTheme[i];

View File

@ -77,7 +77,9 @@
}</pre> }</pre>
<p>The resulting property will be: <p>The resulting property will be:
<pre>Hello Fred. Today is Monday</pre> <pre>Hello Fred. Today is Monday</pre>
<p>It is possible to use a property from the flow context or global context. Just use <code>{{flow.name}}</code> or <code>{{global.name}}</code>, or for persistable store <code>store</code> use <code>{{flow[store].name}}</code> or <code>{{flobal[store].name}}</code>. <p>It is possible to use a property from the flow context or global context. Just use <code>{{flow.name}}</code> or
<code>{{global.name}}</code>, or for persistable store <code>store</code> use <code>{{flow[store].name}}</code> or
<code>{{global[store].name}}</code>.
<p><b>Note: </b>By default, <i>mustache</i> will escape any HTML entities in the values it substitutes. <p><b>Note: </b>By default, <i>mustache</i> will escape any HTML entities in the values it substitutes.
To prevent this, use <code>{{{triple}}}</code> braces. To prevent this, use <code>{{{triple}}}</code> braces.
</script> </script>

View File

@ -467,6 +467,7 @@ module.exports = function(RED) {
connecting: false connecting: false
}; };
enqueue(clients[connection_id].msgQueue, msg); enqueue(clients[connection_id].msgQueue, msg);
clients[connection_id].lastMsg = msg;
if (!clients[connection_id].connecting && !clients[connection_id].connected) { if (!clients[connection_id].connecting && !clients[connection_id].connected) {
var buf; var buf;
@ -507,8 +508,7 @@ module.exports = function(RED) {
clients[connection_id].client.on('data', function(data) { clients[connection_id].client.on('data', function(data) {
if (node.out === "sit") { // if we are staying connected just send the buffer if (node.out === "sit") { // if we are staying connected just send the buffer
if (clients[connection_id]) { if (clients[connection_id]) {
let msg = dequeue(clients[connection_id].msgQueue) || {}; const msg = clients[connection_id].lastMsg || {};
clients[connection_id].msgQueue.unshift(msg);
msg.payload = data; msg.payload = data;
node.send(RED.util.cloneMessage(msg)); node.send(RED.util.cloneMessage(msg));
} }
@ -530,8 +530,7 @@ module.exports = function(RED) {
clients[connection_id].timeout = setTimeout(function () { clients[connection_id].timeout = setTimeout(function () {
if (clients[connection_id]) { if (clients[connection_id]) {
clients[connection_id].timeout = null; clients[connection_id].timeout = null;
let msg = dequeue(clients[connection_id].msgQueue) || {}; const msg = clients[connection_id].lastMsg || {};
clients[connection_id].msgQueue.unshift(msg);
msg.payload = Buffer.alloc(i+1); msg.payload = Buffer.alloc(i+1);
buf.copy(msg.payload,0,0,i+1); buf.copy(msg.payload,0,0,i+1);
node.send(msg); node.send(msg);
@ -553,8 +552,7 @@ module.exports = function(RED) {
i += 1; i += 1;
if ( i >= node.splitc) { if ( i >= node.splitc) {
if (clients[connection_id]) { if (clients[connection_id]) {
let msg = dequeue(clients[connection_id].msgQueue) || {}; const msg = clients[connection_id].lastMsg || {};
clients[connection_id].msgQueue.unshift(msg);
msg.payload = Buffer.alloc(i); msg.payload = Buffer.alloc(i);
buf.copy(msg.payload,0,0,i); buf.copy(msg.payload,0,0,i);
node.send(msg); node.send(msg);
@ -573,8 +571,7 @@ module.exports = function(RED) {
i += 1; i += 1;
if (data[j] == node.splitc) { if (data[j] == node.splitc) {
if (clients[connection_id]) { if (clients[connection_id]) {
let msg = dequeue(clients[connection_id].msgQueue) || {}; const msg = clients[connection_id].lastMsg || {};
clients[connection_id].msgQueue.unshift(msg);
msg.payload = Buffer.alloc(i); msg.payload = Buffer.alloc(i);
buf.copy(msg.payload,0,0,i); buf.copy(msg.payload,0,0,i);
node.send(msg); node.send(msg);

View File

@ -59,7 +59,11 @@ describe('TCP Request Node', function() {
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
n2.on("input", function(msg) { n2.on("input", function(msg) {
try { try {
if (typeof val1 === 'object') {
msg.should.have.properties(Object.assign({}, val1, {payload: Buffer(val1.payload)}));
} else {
msg.should.have.property('payload', Buffer(val1)); msg.should.have.property('payload', Buffer(val1));
}
done(); done();
} catch(err) { } catch(err) {
done(err); done(err);
@ -79,7 +83,11 @@ describe('TCP Request Node', function() {
const n2 = helper.getNode("n2"); const n2 = helper.getNode("n2");
n2.on("input", msg => { n2.on("input", msg => {
try { try {
if (typeof result === 'object') {
msg.should.have.properties(Object.assign({}, result, {payload: Buffer(result.payload)}));
} else {
msg.should.have.property('payload', Buffer(result)); msg.should.have.property('payload', Buffer(result));
}
done(); done();
} catch(err) { } catch(err) {
done(err); done(err);
@ -95,31 +103,75 @@ describe('TCP Request Node', function() {
it('should send & recv data', function(done) { it('should send & recv data', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCP(flow, "foo", "ACK:foo", done) testTCP(flow, {
payload: 'foo',
topic: 'bar'
}, {
payload: 'ACK:foo',
topic: 'bar'
}, done);
});
it('should retain complete message', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCP(flow, {
payload: 'foo',
topic: 'bar'
}, {
payload: 'ACK:foo',
topic: 'bar'
}, done);
}); });
it('should send & recv data when specified character received', function(done) { it('should send & recv data when specified character received', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"char", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"char", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCP(flow, "foo0bar0", "ACK:foo0", done); testTCP(flow, {
payload: 'foo0bar0',
topic: 'bar'
}, {
payload: 'ACK:foo0',
topic: 'bar'
}, done);
}); });
it('should send & recv data after fixed number of chars received', function(done) { it('should send & recv data after fixed number of chars received', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"count", splitc: "7", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"count", splitc: "7", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCP(flow, "foo bar", "ACK:foo", done); testTCP(flow, {
payload: 'foo bar',
topic: 'bar'
}, {
payload: 'ACK:foo',
topic: 'bar'
}, done);
}); });
it('should send & receive, then keep connection', function(done) { it('should send & receive, then keep connection', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", splitc: "5", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", splitc: "5", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCP(flow, "foo", "ACK:foo", done); testTCP(flow, {
payload: 'foo',
topic: 'bar'
}, {
payload: 'ACK:foo',
topic: 'bar'
}, done);
}); });
it('should send & recv data to/from server:port from msg', function(done) { it('should send & recv data to/from server:port from msg', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"", port:"", out:"time", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"", port:"", out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCP(flow, {payload:"foo", host:"localhost", port:port}, "ACK:foo", done) testTCP(flow, {
payload: "foo",
host: "localhost",
port: port
}, {
payload: "ACK:foo",
host: 'localhost',
port: port
}, done);
}); });
}); });
@ -127,36 +179,95 @@ describe('TCP Request Node', function() {
it('should send & recv data', function(done) { it('should send & recv data', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCPMany(flow, [{
testTCPMany(flow, ['f', 'o', 'o'], 'ACK:foo', done); payload: 'f',
topic: 'bar'
}, {
payload: 'o',
topic: 'bar'
}, {
payload: 'o',
topic: 'bar'
}], {
payload: 'ACK:foo',
topic: 'bar'
}, done);
}); });
it('should send & recv data when specified character received', function(done) { it('should send & recv data when specified character received', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"char", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"char", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCPMany(flow, ["foo0","bar0"], "ACK:foo0", done); testTCPMany(flow, [{
payload: "foo0",
topic: 'bar'
}, {
payload: "bar0",
topic: 'bar'
}], {
payload: "ACK:foo0",
topic: 'bar'
}, done);
}); });
it('should send & recv data after fixed number of chars received', function(done) { it('should send & recv data after fixed number of chars received', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"count", splitc: "7", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"count", splitc: "7", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCPMany(flow, ["fo", "ob", "ar"], "ACK:foo", done); testTCPMany(flow, [{
payload: "fo",
topic: 'bar'
}, {
payload: "ob",
topic: 'bar'
}, {
payload: "ar",
topic: 'bar'
}], {
payload: "ACK:foo",
topic: 'bar'
}, done);
}); });
it('should send & receive, then keep connection', function(done) { it('should send & receive, then keep connection', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", splitc: "5", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", splitc: "5", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCPMany(flow, ["foo", "bar", "baz"], "ACK:foobarbaz", done); testTCPMany(flow, [{
payload: "foo",
topic: 'bar'
}, {
payload: "bar",
topic: 'bar'
}, {
payload: "baz",
topic: 'bar'
}], {
payload: "ACK:foobarbaz",
topic: 'bar'
}, done);
}); });
it('should send & recv data to/from server:port from msg', function(done) { it('should send & recv data to/from server:port from msg', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"", port:"", out:"time", splitc: "0", wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp request", server:"", port:"", out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];
testTCPMany(flow, [ testTCPMany(flow, [{
{payload:"f", host:"localhost", port:port}, payload: "f",
{payload:"o", host:"localhost", port:port}, host: "localhost",
{payload:"o", host:"localhost", port:port}], "ACK:foo", done); port: port
},
{
payload: "o",
host: "localhost",
port: port
},
{
payload: "o",
host: "localhost",
port: port
}
], {
payload: "ACK:foo",
host: 'localhost',
port: port
}, done);
}); });
it('should limit the queue size', function (done) { it('should limit the queue size', function (done) {
@ -168,5 +279,23 @@ describe('TCP Request Node', function() {
const expected = msgs.slice(0, -1); const expected = msgs.slice(0, -1);
testTCPMany(flow, msgs, "ACK:" + expected.join(''), done); testTCPMany(flow, msgs, "ACK:" + expected.join(''), done);
}); });
it('should only retain the latest message', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCPMany(flow, [{
payload: 'f',
topic: 'bar'
}, {
payload: 'o',
topic: 'baz'
}, {
payload: 'o',
topic: 'quux'
}], {
payload: 'ACK:foo',
topic: 'quux'
}, done);
});
}); });
}); });