diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index a4cb79698..b66afc4fe 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -44,6 +44,51 @@ RED.nodes = (function() { var dirty = false; + const internalProperties = [ + "changed", + "dirty", + "id", + "inputLabels", + "moved", + "outputLabels", + "selected", + "type", + "users", + "valid", + "validationErrors", + "wires", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "_", + "_config", + "_def", + "_orig" + ]; + function setDirty(d) { dirty = d; if (!d) { @@ -231,7 +276,6 @@ RED.nodes = (function() { def.type = nt; nodeDefinitions[nt] = def; - if (def.defaults) { for (var d in def.defaults) { if (def.defaults.hasOwnProperty(d)) { @@ -242,6 +286,11 @@ RED.nodes = (function() { console.warn(err); } } + + if (internalProperties.includes(d)) { + console.warn(`registerType: ${nt}: the property "${d}" is internal and cannot be used.`); + delete def.defaults[d]; + } } } } diff --git a/packages/node_modules/@node-red/nodes/core/common/24-complete.js b/packages/node_modules/@node-red/nodes/core/common/24-complete.js index ea665a265..1ba43a423 100644 --- a/packages/node_modules/@node-red/nodes/core/common/24-complete.js +++ b/packages/node_modules/@node-red/nodes/core/common/24-complete.js @@ -20,7 +20,16 @@ module.exports = function(RED) { function CompleteNode(n) { RED.nodes.createNode(this,n); var node = this; - this.scope = n.scope; + this.scope = n.scope || []; + + // auto-filter out any directly connected nodes to avoid simple loopback + const w = this.wires.flat(); + for (let i=0; i < this.scope.length; i++) { + if (w.includes(this.scope[i])) { + this.scope.splice(i, 1); + } + } + this.on("input",function(msg, send, done) { send(msg); done(); diff --git a/packages/node_modules/@node-red/nodes/core/common/25-status.js b/packages/node_modules/@node-red/nodes/core/common/25-status.js index fc6ccbe29..8c56e2030 100644 --- a/packages/node_modules/@node-red/nodes/core/common/25-status.js +++ b/packages/node_modules/@node-red/nodes/core/common/25-status.js @@ -20,7 +20,16 @@ module.exports = function(RED) { function StatusNode(n) { RED.nodes.createNode(this,n); var node = this; - this.scope = n.scope; + this.scope = n.scope || []; + + // auto-filter out any directly connected nodes to avoid simple loopback + const w = this.wires.flat(); + for (let i=0; i < this.scope.length; i++) { + if (w.includes(this.scope[i])) { + this.scope.splice(i, 1); + } + } + this.on("input", function(msg, send, done) { send(msg); done(); diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js index afa0066f4..451035a74 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.js @@ -675,7 +675,7 @@ module.exports = function(RED) { node.options.password = node.password; node.options.keepalive = node.keepalive; node.options.clean = node.cleansession; - node.options.clientId = node.clientid || 'nodered_' + RED.util.generateId(); + node.options.clientId = node.clientid || 'nodered' + RED.util.generateId(); node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000; delete node.options.protocolId; //V4+ default delete node.options.protocolVersion; //V4 default diff --git a/packages/node_modules/@node-red/nodes/locales/de/network/21-httprequest.html b/packages/node_modules/@node-red/nodes/locales/de/network/21-httprequest.html index bb02eede0..72718d33f 100644 --- a/packages/node_modules/@node-red/nodes/locales/de/network/21-httprequest.html +++ b/packages/node_modules/@node-red/nodes/locales/de/network/21-httprequest.html @@ -81,7 +81,7 @@

Wenn msg.payload ein Objekt ist, setzt der Node automatisch den Inhaltstyp der Anforderung auf application/json und kodiert den Hauptteil als solchen.

Um die Anforderung als Formulardaten zu kodieren, sollte msg.headers["content-type"] auf - application/x-wwww-form-urlencoded gesetzt werden.

+ application/x-www-form-urlencoded gesetzt werden.

Datei-Upload

Um einen Datei-Upload umzusetzen, sollte msg.headers["content-type"] auf multipart/form-data gesetzt werden und das an den Node zu sendende msg.payload muss ein Objekt mit folgender Struktur sein:

diff --git a/test/nodes/core/common/24-complete_spec.js b/test/nodes/core/common/24-complete_spec.js new file mode 100644 index 000000000..15f27b43b --- /dev/null +++ b/test/nodes/core/common/24-complete_spec.js @@ -0,0 +1,39 @@ + +var should = require("should"); +var catchNode = require("nr-test-utils").require("@node-red/nodes/core/common/24-complete.js"); +var helper = require("node-red-node-test-helper"); + +describe('complete Node', function() { + + afterEach(function() { + helper.unload(); + }); + + it('should output a message when called', function(done) { + var flow = [ { id:"n1", type:"complete", name:"status", wires:[["n2"]], scope:[] }, + {id:"n2", type:"helper"} ]; + helper.load(catchNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n1.should.have.property('name', 'status'); + n2.on("input", function(msg) { + msg.text.should.equal("Oh dear"); + msg.should.have.property('source'); + msg.source.should.have.property('id',"12345"); + msg.source.should.have.property('type',"testnode"); + msg.source.should.have.property('name',"fred"); + done(); + }); + var mst = { + text: "Oh dear", + source: { + id: "12345", + type: "testnode", + name: "fred" + } + } + n1.emit("input", mst); + }); + }); + +}); diff --git a/test/nodes/core/common/25-status_spec.js b/test/nodes/core/common/25-status_spec.js index 41b0a79c8..9457d4372 100644 --- a/test/nodes/core/common/25-status_spec.js +++ b/test/nodes/core/common/25-status_spec.js @@ -25,7 +25,7 @@ describe('status Node', function() { }); it('should output a message when called', function(done) { - var flow = [ { id:"n1", type:"status", name:"status", wires:[["n2"]] }, + var flow = [ { id:"n1", type:"status", name:"status", wires:[["n2"]], scope:[] }, {id:"n2", type:"helper"} ]; helper.load(catchNode, flow, function() { var n1 = helper.getNode("n1"); diff --git a/test/nodes/core/network/21-mqtt_spec.js b/test/nodes/core/network/21-mqtt_spec.js index 16c38d2e5..0075831c9 100644 --- a/test/nodes/core/network/21-mqtt_spec.js +++ b/test/nodes/core/network/21-mqtt_spec.js @@ -58,7 +58,7 @@ describe('MQTT Nodes', function () { mqttBroker.should.have.property('options'); mqttBroker.options.should.have.property('clean', true); mqttBroker.options.should.have.property('clientId'); - mqttBroker.options.clientId.should.containEql('nodered_'); + mqttBroker.options.clientId.should.containEql('nodered'); mqttBroker.options.should.have.property('keepalive').type("number"); mqttBroker.options.should.have.property('reconnectPeriod').type("number"); //as this is not a v5 connection, ensure v5 properties are not present @@ -894,4 +894,4 @@ function nextTopic(topic) { return (base_topic + topic + String(topicNo)); } -//#endregion HELPERS \ No newline at end of file +//#endregion HELPERS