How to use the @node-red/util.util.generateId function in @node-red/util

To help you get started, we’ve selected a few @node-red/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / flows / Subflow.js View on Github external
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;
}
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
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
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
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
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
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
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
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
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
Node.prototype.receive = function(msg) {
    if (!msg) {
        msg = {};
    }
    if (!msg._msgid) {
        msg._msgid = redUtil.generateId();
    }
    this.metric("receive",msg);
    this.emit("input",msg);
};
github sakazuki / node-red-desktop / src / main / node-red-runtime-exec.ts View on Github external
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;
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / Node.js View on Github external
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);
    }
};
github node-red / node-red / packages / node_modules / @node-red / runtime / lib / nodes / flows / index.js View on Github external
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