1 | // Type definitions for node-red 1.3
|
2 | // Project: https://github.com/node-red/node-red/tree/master/packages/node_modules/node-red, https://nodered.org/
|
3 | // Definitions by: Anders E. Andersen <https://github.com/andersea>
|
4 | // Thomas B. Mørch <https://github.com/tbowmo>
|
5 | // Bernardo Belchior <https://github.com/bernardobelchior>
|
6 | // Alex Kaul <https://github.com/alexk111>
|
7 | // Tadeusz Wyrzykowski <https://github.com/Shaquu>
|
8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
9 | // Minimum TypeScript Version: 4.7
|
10 |
|
11 | // tslint:disable:no-empty-interface
|
12 |
|
13 | import { Express } from 'express';
|
14 | import { EventEmitter } from 'events';
|
15 | import { Server as HttpServer } from 'http';
|
16 |
|
17 | import * as editorAPI from '@node-red/editor-api';
|
18 | import * as editorClient from '@node-red/editor-client';
|
19 | import * as registry from '@node-red/registry';
|
20 | import * as runtime from '@node-red/runtime';
|
21 | import * as util from '@node-red/util';
|
22 |
|
23 | declare const nodeRed: nodeRed.NodeRedApp;
|
24 |
|
25 | export = nodeRed;
|
26 |
|
27 | declare namespace nodeRed {
|
28 | interface NodeRedApp {
|
29 | /**
|
30 | * Initialise the Node-RED application.
|
31 | * @param httpServer - the HTTP server object to use
|
32 | * @param userSettings - an object containing the runtime settings
|
33 | */
|
34 | init: (httpServer: HttpServer, userSettings: runtime.LocalSettings) => void;
|
35 |
|
36 | /**
|
37 | * Start the Node-RED application.
|
38 | */
|
39 | start: () => Promise<void>;
|
40 |
|
41 | /**
|
42 | * Stop the Node-RED application.
|
43 | */
|
44 | stop: () => Promise<void>;
|
45 |
|
46 | /**
|
47 | * Logging utilities
|
48 | */
|
49 | log: util.Log;
|
50 |
|
51 | /**
|
52 | * General utilities
|
53 | */
|
54 | util: util.Util;
|
55 |
|
56 | /**
|
57 | * This provides access to the internal nodes module of the
|
58 | * runtime. The details of this API remain undocumented as they should not
|
59 | * be used directly.
|
60 | *
|
61 | * Most administrative actions should be performed use the runtime api
|
62 | * under @node-red/runtime.
|
63 | */
|
64 | readonly nodes: runtime.InternalNodesModule;
|
65 |
|
66 | /**
|
67 | * This provides access to the internal plugins module of the
|
68 | * runtime. The details of this API remain undocumented as they should not
|
69 | * be used directly.
|
70 | *
|
71 | * Most administrative actions should be performed use the runtime api
|
72 | * under @node-red/runtime.
|
73 | */
|
74 | readonly plugins: runtime.InternalPluginsModule;
|
75 |
|
76 | /**
|
77 | * Runtime events emitter
|
78 | */
|
79 | events: EventEmitter;
|
80 |
|
81 | /**
|
82 | * Runtime hooks engine
|
83 | */
|
84 | hooks: util.Hooks;
|
85 |
|
86 | /**
|
87 | * This provides access to the internal settings module of the
|
88 | * runtime.
|
89 | */
|
90 | readonly settings: runtime.PersistentSettings;
|
91 |
|
92 | /**
|
93 | * Get the version of the runtime
|
94 | */
|
95 | readonly version: string;
|
96 |
|
97 | /**
|
98 | * The express application for the Editor Admin API
|
99 | */
|
100 | readonly httpAdmin: Express;
|
101 |
|
102 | /**
|
103 | * The express application for HTTP Nodes
|
104 | */
|
105 | readonly httpNode: Express;
|
106 |
|
107 | /**
|
108 | * The HTTP Server used by the runtime
|
109 | */
|
110 | readonly server: HttpServer;
|
111 |
|
112 | /**
|
113 | * The runtime api
|
114 | */
|
115 | runtime: runtime.RuntimeModule;
|
116 |
|
117 | /**
|
118 | * The editor authentication api.
|
119 | */
|
120 | auth: editorAPI.Auth;
|
121 | }
|
122 |
|
123 | /*******************************************************************
|
124 | * Type shortcuts for writing the runtime side of nodes (.js file)
|
125 | *******************************************************************/
|
126 |
|
127 | /**
|
128 | * Type def for the functions that should be exported
|
129 | * by the node .js files.
|
130 | */
|
131 | interface NodeInitializer<TSets extends NodeAPISettingsWithData = NodeAPISettingsWithData>
|
132 | extends registry.NodeInitializer<TSets> {}
|
133 |
|
134 | interface NodeConstructor<TNode extends Node<TCreds>, TNodeDef extends NodeDef, TCreds extends {}>
|
135 | extends registry.NodeConstructor<TNode, TNodeDef, TCreds> {}
|
136 |
|
137 | interface NodeAPISettingsWithData extends registry.NodeAPISettingsWithData {}
|
138 |
|
139 | interface NodeSetting<T> extends registry.NodeSetting<T> {}
|
140 |
|
141 | type NodeSettings<TSets> = registry.NodeSettings<TSets>;
|
142 |
|
143 | interface NodeCredential extends registry.NodeCredential {}
|
144 |
|
145 | type NodeCredentials<TCreds> = registry.NodeCredentials<TCreds>;
|
146 |
|
147 | interface NodeMessage extends registry.NodeMessage {}
|
148 |
|
149 | interface NodeMessageParts extends registry.NodeMessageParts {}
|
150 |
|
151 | interface NodeMessageInFlow extends registry.NodeMessageInFlow {}
|
152 |
|
153 | interface NodeAPI<TSets extends NodeAPISettingsWithData = NodeAPISettingsWithData>
|
154 | extends registry.NodeAPI<TSets> {}
|
155 |
|
156 | interface Node<TCreds extends {} = {}> extends registry.Node<TCreds> {}
|
157 |
|
158 | type NodeStatusFill = registry.NodeStatusFill;
|
159 |
|
160 | type NodeStatusShape = registry.NodeStatusShape;
|
161 |
|
162 | interface NodeStatus extends registry.NodeStatus {}
|
163 |
|
164 | interface NodeDef extends registry.NodeDef {}
|
165 |
|
166 | interface NodeContextData extends registry.NodeContextData {}
|
167 |
|
168 | interface NodeContext extends registry.NodeContext {}
|
169 |
|
170 | /********************************************************************
|
171 | * Type shortcuts for writing the editor side of nodes (.html file)
|
172 | ********************************************************************/
|
173 |
|
174 | /**
|
175 | * Property definition
|
176 | * Read more: https://nodered.org/docs/creating-nodes/properties#property-definitions
|
177 | */
|
178 | interface EditorNodePropertyDef<TVal, TInstProps extends EditorNodeProperties = EditorNodeProperties>
|
179 | extends editorClient.NodePropertyDef<TVal, TInstProps> {}
|
180 |
|
181 | /**
|
182 | * Properties definitions (`defaults` object)
|
183 | * Read more: https://nodered.org/docs/creating-nodes/properties
|
184 | */
|
185 | type EditorNodePropertiesDef<
|
186 | TProps extends EditorNodeProperties,
|
187 | TInstProps extends TProps = TProps,
|
188 | > = editorClient.NodePropertiesDef<TProps, TInstProps>;
|
189 |
|
190 | /**
|
191 | * Node properties
|
192 | * Read more: https://nodered.org/docs/creating-nodes/properties
|
193 | */
|
194 | interface EditorNodeProperties extends editorClient.NodeProperties {}
|
195 |
|
196 | type EditorNodeInstance<TProps extends EditorNodeProperties = EditorNodeProperties> =
|
197 | editorClient.NodeInstance<TProps>;
|
198 |
|
199 | type EditorNodeCredentials<T> = editorClient.NodeCredentials<T>;
|
200 |
|
201 | interface EditorNodeCredential extends editorClient.NodeCredential {}
|
202 |
|
203 | /**
|
204 | * Node Definition
|
205 | * Read more: https://nodered.org/docs/creating-nodes/node-html#node-definition
|
206 | */
|
207 | interface EditorNodeDef<
|
208 | TProps extends EditorNodeProperties = EditorNodeProperties,
|
209 | TCreds = undefined,
|
210 | TInstProps extends TProps = TProps,
|
211 | > extends editorClient.NodeDef<TProps, TCreds, TInstProps> {}
|
212 |
|
213 | /**
|
214 | * Type def for the global `RED` in the node .html files.
|
215 | * Should be used to access `RED.nodes.registerType` function
|
216 | * registering a node with the editor.
|
217 | *
|
218 | * Example:
|
219 | * ```
|
220 | * declare const RED: EditorRED;
|
221 | *
|
222 | * RED.nodes.registerType<
|
223 | * MyNodeProps
|
224 | * >("my-node", {
|
225 | * ...
|
226 | * })
|
227 | * ```
|
228 | *
|
229 | */
|
230 | interface EditorRED extends editorClient.RED {}
|
231 |
|
232 | /**
|
233 | * WIDGETS
|
234 | */
|
235 |
|
236 | interface EditorWidgetEditableListOptions<T> extends editorClient.WidgetEditableListOptions<T> {}
|
237 |
|
238 | interface EditorWidgetEditableList extends editorClient.WidgetEditableList {}
|
239 |
|
240 | interface EditorWidgetTypedInputOptions extends editorClient.WidgetTypedInputOptions {}
|
241 |
|
242 | type EditorWidgetTypedInputType = editorClient.WidgetTypedInputType;
|
243 |
|
244 | interface EditorWidgetTypedInputTypeDefinition extends editorClient.WidgetTypedInputTypeDefinition {}
|
245 |
|
246 | interface EditorWidgetTypedInput extends editorClient.WidgetTypedInput {}
|
247 | }
|