@node-red/registry

This module provides the node registry for the Node-RED runtime.

It is responsible for loading node modules and making them available to the runtime.

addModule(module) → {Promise.<Object>}

Loads a new module into the registry.

This will rescan the node module paths looking for this module.

Parameters:
Name Type Description
module String

the name of the module to add

Throws:

if the module has already been added or the runtime settings are unavailable

Returns:
Type:
Promise.<Object>

A promise that resolves with the module information once it has been added

cleanModuleList()

Update to internal list of available modules based on what has been actually loaded.

The externalModules.autoInstall (previously autoInstallModules) runtime option means the runtime may try to install missing modules after the initial load is complete. If that flag is not set this function is used to remove the modules from the registry's saved list.

disableNode(type) → {Promise}

Disables a node set, making it unavailable for use.

Parameters:
Name Type Description
type String

the node type or set identifier

Throws:

if the identifier is not recognised or runtime settings are unavailable

Returns:
Type:
Promise

A promise that resolves when the node set has been disabled

enableNode(type) → {Promise}

Enables a node set, making it available for use.

Parameters:
Name Type Description
type String

the node type or set identifier

Throws:

if the identifier is not recognised or runtime settings are unavailable

Returns:
Type:
Promise

A promise that resolves when the node set has been enabled

get(type) → {function}

Get a node constructor function.

Parameters:
Name Type Description
type String

the node type

Returns:
Type:
function

the node constructor function

getModuleInfo(type) → {Object}

Get a modules's information.

Parameters:
Name Type Description
type String

the module identifier

Returns:
Type:
Object

the module information

getModuleList() → {Object}

Get a list of all moduless in the registry.

Returns:
Type:
Object

the module list

getModuleResource(module, path) → {String}

Gets the full path to a module's resource file

Parameters:
Name Type Description
module String

the name of the module providing the resource file

path String

the relative path of the resource file

Returns:
Type:
String

the full path to the resource file

getNodeConfig(id, lang) → {String}

Get the HTML config for a single node set.

Parameters:
Name Type Description
id String

the node identifier

lang String

the language to return, default en-US

Returns:
Type:
String

the node config

getNodeConfigs(lang) → {String}

Get the HTML configs for all nodes in the registry.

Parameters:
Name Type Description
lang String

the language to return, default en-US

Returns:
Type:
String

the node configs

getNodeExampleFlowPath(module, path) → {String}

Gets the full path to a node example

Parameters:
Name Type Description
module String

the name of the module providing the example

path String

the relative path of the example

Returns:
Type:
String

the full path to the example

getNodeExampleFlows() → {Object}

Get a list of all example flows provided by nodes in the registry.

Returns:
Type:
Object

an object, indexed by module, listing all example flows

getNodeIconPath(module, icon) → {String}

Get the local path to a node's icon file.

Parameters:
Name Type Description
module String

the module that provides the icon

icon String

the name of the icon

Returns:
Type:
String

the local path to the icon

getNodeIcons() → {String}

Get the full list of all icons available.

Returns:
Type:
String

the icon list

getNodeInfo(type) → {Object}

Get a node's set information.

Parameters:
Name Type Description
type String

the node type or set identifier

Returns:
Type:
Object

the node set information

getNodeList() → {Object}

Get a list of all nodes in the registry.

Returns:
Type:
Object

the node list

init(runtime)

Initialise the registry with a reference to a runtime object

Parameters:
Name Type Description
runtime Object

a runtime object

installerEnabled() → {Boolean}

Check if the regisrty is able to install/remove modules.

This is based on whether it has found npm on the command-line.

Returns:
Type:
Boolean

whether the installer is enabled

installModule(module, version, url) → {Promise.<Array>}

Installs a new node module using npm and then add to the registry

Parameters:
Name Type Description
module String | Buffer

the name of the module to install, or a Buffer containing a module tar file

version String

the version of the module to install, default: latest

url String

(optional) a url to install the module from

Returns:
Type:
Promise.<Array>

A promise that resolves with the module information once it has been installed

load() → {Promise}

Triggers the intial discovery and loading of all Node-RED node modules. found on the node path.

Returns:
Type:
Promise
  • resolves when the registry has finised discovering node modules.

registerType(nodeSet, type, constructor)

Register a node constructor function.

Parameters:
Name Type Description
nodeSet Object

the Node Set object the constructor is for

type String

the node type

constructor function

the node constructor function

removeModule(module) → {Promise.<Array>}

Removes a module from the registry.

Parameters:
Name Type Description
module String

the name of the module to remove

Throws:

if the module is not found or the runtime settings are unavailable

Returns:
Type:
Promise.<Array>

A promise that resolves with the list of removed node sets

uninstallModule(module) → {Promise.<Array>}

Uninstalls a module using npm

Parameters:
Name Type Description
module String

the name of the module to uninstall

Returns:
Type:
Promise.<Array>

A promise that resolves when the module has been removed