mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3169f93cc2 | ||
|
|
c1a1a73599 | ||
|
|
db1b0ccb79 | ||
|
|
d373105b32 | ||
|
|
28b311b7ed | ||
|
|
dcda513901 | ||
|
|
72c400794c |
@@ -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
|
||||||
|
|||||||
@@ -881,7 +881,6 @@ RED.diff = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))});
|
var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))});
|
||||||
if (def.defaults) {
|
if (def.defaults) {
|
||||||
properties = properties.concat(Object.keys(def.defaults));
|
properties = properties.concat(Object.keys(def.defaults));
|
||||||
@@ -889,6 +888,13 @@ RED.diff = (function() {
|
|||||||
if (node.type !== 'tab') {
|
if (node.type !== 'tab') {
|
||||||
properties = properties.concat(['inputLabels','outputLabels']);
|
properties = properties.concat(['inputLabels','outputLabels']);
|
||||||
}
|
}
|
||||||
|
if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) &&
|
||||||
|
properties.indexOf('icon') === -1
|
||||||
|
) {
|
||||||
|
properties.unshift('icon');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
properties.forEach(function(d) {
|
properties.forEach(function(d) {
|
||||||
localChanged = false;
|
localChanged = false;
|
||||||
remoteChanged = false;
|
remoteChanged = false;
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ RED.editor = (function() {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (icon !== defaultIcon) {
|
if (icon !== "" && icon !== defaultIcon) {
|
||||||
changes.icon = editing_node.icon;
|
changes.icon = editing_node.icon;
|
||||||
editing_node.icon = icon;
|
editing_node.icon = icon;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|||||||
@@ -800,8 +800,9 @@ 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];
|
||||||
if (themeRule.hasOwnProperty('category')) {
|
if (themeRule.hasOwnProperty('category')) {
|
||||||
if (!themeRule.hasOwnProperty('_category')) {
|
if (!themeRule.hasOwnProperty('_category')) {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -283,6 +283,9 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function applyRules(msg, currentRule) {
|
function applyRules(msg, currentRule) {
|
||||||
|
if (currentRule >= node.rules.length) {
|
||||||
|
return Promise.resolve(msg);
|
||||||
|
}
|
||||||
var r = node.rules[currentRule];
|
var r = node.rules[currentRule];
|
||||||
var rulePromise;
|
var rulePromise;
|
||||||
if (r.t === "move") {
|
if (r.t === "move") {
|
||||||
|
|||||||
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red",
|
"name": "node-red",
|
||||||
"version": "0.19.1",
|
"version": "0.19.2",
|
||||||
"description": "A visual tool for wiring the Internet of Things",
|
"description": "A visual tool for wiring the Internet of Things",
|
||||||
"homepage": "http://nodered.org",
|
"homepage": "http://nodered.org",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"flow"
|
"flow"
|
||||||
],
|
],
|
||||||
"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",
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
"jsonata": "1.5.4",
|
"jsonata": "1.5.4",
|
||||||
"media-typer": "0.3.0",
|
"media-typer": "0.3.0",
|
||||||
"memorystore": "1.6.0",
|
"memorystore": "1.6.0",
|
||||||
"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.*",
|
||||||
@@ -71,9 +71,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"
|
||||||
@@ -103,6 +103,7 @@
|
|||||||
"http-proxy": "^1.16.2",
|
"http-proxy": "^1.16.2",
|
||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
|
"node-red-node-test-helper": "0.1.7",
|
||||||
"should": "^8.4.0",
|
"should": "^8.4.0",
|
||||||
"sinon": "1.17.7",
|
"sinon": "1.17.7",
|
||||||
"stoppable": "^1.0.6",
|
"stoppable": "^1.0.6",
|
||||||
@@ -110,8 +111,7 @@
|
|||||||
"wdio-chromedriver-service": "^0.1.3",
|
"wdio-chromedriver-service": "^0.1.3",
|
||||||
"wdio-mocha-framework": "^0.6.2",
|
"wdio-mocha-framework": "^0.6.2",
|
||||||
"wdio-spec-reporter": "^0.1.5",
|
"wdio-spec-reporter": "^0.1.5",
|
||||||
"webdriverio": "^4.13.1",
|
"webdriverio": "^4.13.1"
|
||||||
"node-red-node-test-helper": "^0.1.7"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
|
|||||||
@@ -162,12 +162,10 @@ function start() {
|
|||||||
if (settings.httpStatic) {
|
if (settings.httpStatic) {
|
||||||
log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)}));
|
log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)}));
|
||||||
}
|
}
|
||||||
redNodes.loadContextsPlugin().then(function () {
|
return redNodes.loadContextsPlugin().then(function () {
|
||||||
redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {});
|
redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {});
|
||||||
started = true;
|
started = true;
|
||||||
});
|
});
|
||||||
}).catch(function(err) {
|
|
||||||
console.log(err);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,12 @@
|
|||||||
"error-module-not-defined": "Context store '__storage__' missing 'module' option",
|
"error-module-not-defined": "Context store '__storage__' missing 'module' option",
|
||||||
"error-invalid-module-name": "Invalid context store name: '__name__'",
|
"error-invalid-module-name": "Invalid context store name: '__name__'",
|
||||||
"error-invalid-default-module": "Default context store unknown: '__storage__'",
|
"error-invalid-default-module": "Default context store unknown: '__storage__'",
|
||||||
"unknown-store": "Unknown context store '__name__' specified. Using default store."
|
"unknown-store": "Unknown context store '__name__' specified. Using default store.",
|
||||||
|
"error-loading-module": "Error loading context store: __message__",
|
||||||
|
"localfilesystem": {
|
||||||
|
"error-circular": "Context __scope__ contains a circular reference that cannot be persisted",
|
||||||
|
"error-write": "Error writing context: __message__"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ function load() {
|
|||||||
defaultStore = "memory";
|
defaultStore = "memory";
|
||||||
}
|
}
|
||||||
return resolve(Promise.all(promises));
|
return resolve(Promise.all(promises));
|
||||||
|
}).catch(function(err) {
|
||||||
|
throw new Error(log._("context.error-loading-module",{message:err.toString()}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,6 @@ function loadFile(storagePath){
|
|||||||
}else{
|
}else{
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
}).catch(function(err){
|
|
||||||
throw Promise.reject(err);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,9 +111,21 @@ function listFiles(storagePath) {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
return fs.readdir(storagePath).then(function(files) {
|
return fs.readdir(storagePath).then(function(files) {
|
||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
promises.push(fs.readdir(path.join(storagePath,file)).then(function(subdirFiles) {
|
if (!/^\./.test(file)) {
|
||||||
return subdirFiles.map(subfile => path.join(file,subfile));
|
var fullPath = path.join(storagePath,file);
|
||||||
}))
|
var stats = fs.statSync(fullPath);
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
promises.push(fs.readdir(fullPath).then(function(subdirFiles) {
|
||||||
|
var result = [];
|
||||||
|
subdirFiles.forEach(subfile => {
|
||||||
|
if (/\.json$/.test(subfile)) {
|
||||||
|
result.push(path.join(file,subfile))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}).then(dirs => dirs.reduce((acc, val) => acc.concat(val), []));
|
}).then(dirs => dirs.reduce((acc, val) => acc.concat(val), []));
|
||||||
@@ -172,7 +182,7 @@ LocalFileSystem.prototype.open = function(){
|
|||||||
if(err.code == 'ENOENT') {
|
if(err.code == 'ENOENT') {
|
||||||
return fs.ensureDir(self.storageBaseDir);
|
return fs.ensureDir(self.storageBaseDir);
|
||||||
}else{
|
}else{
|
||||||
return Promise.reject(err);
|
throw err;
|
||||||
}
|
}
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
self._flushPendingWrites = function() {
|
self._flushPendingWrites = function() {
|
||||||
@@ -185,7 +195,7 @@ LocalFileSystem.prototype.open = function(){
|
|||||||
var context = newContext[scope];
|
var context = newContext[scope];
|
||||||
var stringifiedContext = stringify(context);
|
var stringifiedContext = stringify(context);
|
||||||
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
|
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
|
||||||
log.warn("Context "+scope+" contains a circular reference that cannot be persisted");
|
log.warn(log._("error-circular",{scope:scope}));
|
||||||
self.knownCircularRefs[scope] = true;
|
self.knownCircularRefs[scope] = true;
|
||||||
} else {
|
} else {
|
||||||
delete self.knownCircularRefs[scope];
|
delete self.knownCircularRefs[scope];
|
||||||
@@ -249,7 +259,11 @@ LocalFileSystem.prototype.set = function(scope, key, value, callback) {
|
|||||||
// there's a pending write which will handle this
|
// there's a pending write which will handle this
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this._pendingWriteTimeout = setTimeout(function() { self._flushPendingWrites.call(self)}, this.flushInterval);
|
this._pendingWriteTimeout = setTimeout(function() {
|
||||||
|
self._flushPendingWrites.call(self).catch(function(err) {
|
||||||
|
log.error(log._("context.localfilesystem.error-write",{message:err.toString()}))
|
||||||
|
});
|
||||||
|
}, this.flushInterval);
|
||||||
}
|
}
|
||||||
} else if (callback && typeof callback !== 'function') {
|
} else if (callback && typeof callback !== 'function') {
|
||||||
throw new Error("Callback must be a function");
|
throw new Error("Callback must be a function");
|
||||||
@@ -272,7 +286,7 @@ LocalFileSystem.prototype.set = function(scope, key, value, callback) {
|
|||||||
}
|
}
|
||||||
var stringifiedContext = stringify(obj);
|
var stringifiedContext = stringify(obj);
|
||||||
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
|
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
|
||||||
log.warn("Context "+scope+" contains a circular reference that cannot be persisted");
|
log.warn(log._("error-circular",{scope:scope}));
|
||||||
self.knownCircularRefs[scope] = true;
|
self.knownCircularRefs[scope] = true;
|
||||||
} else {
|
} else {
|
||||||
delete self.knownCircularRefs[scope];
|
delete self.knownCircularRefs[scope];
|
||||||
|
|||||||
@@ -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 {
|
||||||
msg.should.have.property('payload', Buffer(val1));
|
if (typeof val1 === 'object') {
|
||||||
|
msg.should.have.properties(Object.assign({}, val1, {payload: Buffer(val1.payload)}));
|
||||||
|
} else {
|
||||||
|
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 {
|
||||||
msg.should.have.property('payload', Buffer(result));
|
if (typeof result === 'object') {
|
||||||
|
msg.should.have.properties(Object.assign({}, result, {payload: Buffer(result.payload)}));
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,6 +78,24 @@ describe('change Node', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should no-op if there are no rules', function(done) {
|
||||||
|
var flow = [{"id":"changeNode1","type":"change","rules":[],"action":"","property":"","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
|
||||||
|
{id:"helperNode1", type:"helper", wires:[]}];
|
||||||
|
helper.load(changeNode, flow, function() {
|
||||||
|
var changeNode1 = helper.getNode("changeNode1");
|
||||||
|
var helperNode1 = helper.getNode("helperNode1");
|
||||||
|
helperNode1.on("input", function(msg) {
|
||||||
|
try {
|
||||||
|
msg.should.eql(sentMsg);
|
||||||
|
done();
|
||||||
|
} catch(err) {
|
||||||
|
done(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var sentMsg = {payload:"leaveMeAlong"};
|
||||||
|
changeNode1.receive(sentMsg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#set' , function() {
|
describe('#set' , function() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user