// Type definitions for node-red 1.2 // Project: https://github.com/node-red/node-red/tree/master/packages/node_modules/node-red, https://nodered.org/ // Definitions by: Anders E. Andersen // Thomas B. Mørch // Bernardo Belchior // Alex Kaul // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.1 // tslint:disable:no-empty-interface import { Express } from 'express'; import { EventEmitter } from 'events'; import { Server as HttpServer } from 'http'; import * as editorAPI from '@node-red/editor-api'; import * as editorClient from '@node-red/editor-client'; import * as registry from '@node-red/registry'; import * as runtime from '@node-red/runtime'; import * as util from '@node-red/util'; declare const nodeRed: nodeRed.NodeRedApp; export = nodeRed; declare namespace nodeRed { interface NodeRedApp { /** * Initialise the Node-RED application. * @param httpServer - the HTTP server object to use * @param userSettings - an object containing the runtime settings */ init: (httpServer: HttpServer, userSettings: runtime.LocalSettings) => void; /** * Start the Node-RED application. */ start: () => Promise; /** * Stop the Node-RED application. */ stop: () => Promise; /** * Logging utilities */ log: util.Log; /** * General utilities */ util: util.Util; /** * This provides access to the internal nodes module of the * runtime. The details of this API remain undocumented as they should not * be used directly. * * Most administrative actions should be performed use the runtime api * under @node-red/runtime. */ readonly nodes: runtime.InternalNodesModule; /** * Runtime events emitter */ events: EventEmitter; /** * Runtime hooks engine */ hooks: util.Hooks; /** * This provides access to the internal settings module of the * runtime. */ readonly settings: runtime.PersistentSettings; /** * Get the version of the runtime */ readonly version: string; /** * The express application for the Editor Admin API */ readonly httpAdmin: Express; /** * The express application for HTTP Nodes */ readonly httpNode: Express; /** * The HTTP Server used by the runtime */ readonly server: HttpServer; /** * The runtime api */ runtime: runtime.RuntimeModule; /** * The editor authentication api. */ auth: editorAPI.Auth; } /******************************************************************* * Type shortcuts for writing the runtime side of nodes (.js file) *******************************************************************/ /** * Type def for the functions that should be exported * by the node .js files. */ interface NodeInitializer extends registry.NodeInitializer {} interface NodeConstructor, TNodeDef extends NodeDef, TCreds extends {}> extends registry.NodeConstructor {} interface NodeAPISettingsWithData extends registry.NodeAPISettingsWithData {} interface NodeSetting extends registry.NodeSetting {} type NodeSettings = registry.NodeSettings; interface NodeCredential extends registry.NodeCredential {} type NodeCredentials = registry.NodeCredentials; interface NodeMessage extends registry.NodeMessage {} interface NodeMessageParts extends registry.NodeMessageParts {} interface NodeMessageInFlow extends registry.NodeMessageInFlow {} interface NodeAPI extends registry.NodeAPI {} interface Node extends registry.Node {} type NodeStatusFill = registry.NodeStatusFill; type NodeStatusShape = registry.NodeStatusShape; interface NodeStatus extends registry.NodeStatus {} interface NodeDef extends registry.NodeDef {} interface NodeContextData extends registry.NodeContextData {} interface NodeContext extends registry.NodeContext {} /******************************************************************** * Type shortcuts for writing the editor side of nodes (.html file) ********************************************************************/ /** * Property definition * Read more: https://nodered.org/docs/creating-nodes/properties#property-definitions */ interface EditorNodePropertyDef extends editorClient.NodePropertyDef {} /** * Properties definitions (`defaults` object) * Read more: https://nodered.org/docs/creating-nodes/properties */ type EditorNodePropertiesDef< TProps extends EditorNodeProperties, TInstProps extends TProps = TProps > = editorClient.NodePropertiesDef; /** * Node properties * Read more: https://nodered.org/docs/creating-nodes/properties */ interface EditorNodeProperties extends editorClient.NodeProperties {} type EditorNodeInstance = editorClient.NodeInstance< TProps >; type EditorNodeCredentials = editorClient.NodeCredentials; interface EditorNodeCredential extends editorClient.NodeCredential {} /** * Node Definition * Read more: https://nodered.org/docs/creating-nodes/node-html#node-definition */ interface EditorNodeDef< TProps extends EditorNodeProperties = EditorNodeProperties, TCreds = undefined, TInstProps extends TProps = TProps > extends editorClient.NodeDef {} /** * Type def for the global `RED` in the node .html files. * Should be used to access `RED.nodes.registerType` function * registering a node with the editor. * * Example: * ``` * declare const RED: EditorRED; * * RED.nodes.registerType< * MyNodeProps * >("my-node", { * ... * }) * ``` * */ interface EditorRED extends editorClient.RED {} /** * WIDGETS */ interface EditorWidgetEditableListOptions extends editorClient.WidgetEditableListOptions {} interface EditorWidgetEditableList extends editorClient.WidgetEditableList {} interface EditorWidgetTypedInputOptions extends editorClient.WidgetTypedInputOptions {} type EditorWidgetTypedInputType = editorClient.WidgetTypedInputType; interface EditorWidgetTypedInputTypeDefinition extends editorClient.WidgetTypedInputTypeDefinition {} interface EditorWidgetTypedInput extends editorClient.WidgetTypedInput {} }