Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createNodeInSubflow(subflowInstanceId, def) {
let node = clone(def);
let nid = redUtil.generateId();
// console.log("Create Node In subflow",node.id, "--->",nid, "(",node.type,")")
// node_map[node.id] = node;
node._alias = node.id;
node.id = nid;
node.z = subflowInstanceId;
return node;
}
Node.prototype.send = function(msg) {
var msgSent = false;
var node;
if (msg === null || typeof msg === "undefined") {
return;
} else if (!util.isArray(msg)) {
if (this._wire) {
// A single message and a single wire on output 0
// TODO: pre-load flows.get calls - cannot do in constructor
// as not all nodes are defined at that point
if (!msg._msgid) {
msg._msgid = redUtil.generateId();
}
this.metric("send",msg);
node = this._flow.getNode(this._wire);
/* istanbul ignore else */
if (node) {
node.receive(msg);
}
return;
} else {
msg = [msg];
}
}
var numOutputs = this.wires.length;
// Build a list of send events so that all cloning is done before
Node.prototype.send = function(msg) {
var msgSent = false;
var node;
if (msg === null || typeof msg === "undefined") {
return;
} else if (!util.isArray(msg)) {
if (this._wire) {
// A single message and a single wire on output 0
// TODO: pre-load flows.get calls - cannot do in constructor
// as not all nodes are defined at that point
if (!msg._msgid) {
msg._msgid = redUtil.generateId();
}
this.metric("send",msg);
node = this._flow.getNode(this._wire);
/* istanbul ignore else */
if (node) {
node.receive(msg);
}
return;
} else {
msg = [msg];
}
}
var numOutputs = this.wires.length;
// Build a list of send events so that all cloning is done before
var clonedmsg = redUtil.cloneMessage(m);
sendEvents.push({n:node,m:clonedmsg});
} else {
sendEvents.push({n:node,m:m});
msgSent = true;
}
}
}
}
}
}
}
}
/* istanbul ignore else */
if (!sentMessageId) {
sentMessageId = redUtil.generateId();
}
this.metric("send",{_msgid:sentMessageId});
for (i=0;i
var clonedmsg = redUtil.cloneMessage(m);
sendEvents.push({n:node,m:clonedmsg});
} else {
sendEvents.push({n:node,m:m});
msgSent = true;
}
}
}
}
}
}
}
}
/* istanbul ignore else */
if (!sentMessageId) {
sentMessageId = redUtil.generateId();
}
this.metric("send",{_msgid:sentMessageId});
for (i=0;i
Node.prototype.receive = function(msg) {
if (!msg) {
msg = {};
}
if (!msg._msgid) {
msg._msgid = redUtil.generateId();
}
this.metric("receive",msg);
this.emit("input",msg);
};
run: function(command: string, args: string[], options: any, emit: boolean): Promise {
if (status.npmCommandEnabled || (path.parse(command).name !== "npm")) {
return origExec.run(command,args,options,emit);
}
var invocationId = util.generateId();
const npmCliCommand= path.join(__dirname, "..", "node_modules", "npm", "bin", "npm-cli.js");
if (options) {
options.detached = false;
options.silent = true;
}
emit && events.emit("event-log", {ts: Date.now(),id:invocationId,payload:{ts: Date.now(),data:npmCliCommand+" "+args.join(" ")}});
return new Promise((resolve, reject) => {
let stdout = "";
let stderr = "";
const child = child_process.fork(npmCliCommand,args,options);
child.stdout.on('data', (data: any) => {
const str = ""+data;
stdout += str;
Node.prototype.receive = function(msg) {
if (!msg) {
msg = {};
}
if (!msg._msgid) {
msg._msgid = redUtil.generateId();
}
this.metric("receive",msg);
try {
this.emit("input", msg);
} catch(err) {
this.error(err,msg);
}
};
function addFlow(flow) {
var i,node;
if (!flow.hasOwnProperty('nodes')) {
throw new Error('missing nodes property');
}
flow.id = redUtil.generateId();
var tabNode = {
type:'tab',
label:flow.label,
id:flow.id
}
if (flow.hasOwnProperty('info')) {
tabNode.info = flow.info;
}
if (flow.hasOwnProperty('disabled')) {
tabNode.disabled = flow.disabled;
}
var nodes = [tabNode];
for (i=0;i