@bonsae/nrg 0.22.1 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/types/client.d.ts +266 -1
- package/types/server.d.ts +941 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonsae/nrg",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "NRG framework — build Node-RED nodes with Vue 3, TypeScript, and JSON Schema",
|
|
5
5
|
"author": "Allan Oricil <allanoricil@duck.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"@bonsae/nrg-runtime": "0.22.
|
|
122
|
+
"@bonsae/nrg-runtime": "0.22.2",
|
|
123
123
|
"@clack/prompts": "^1.0.1",
|
|
124
124
|
"@sinclair/typebox": "^0.34.33",
|
|
125
125
|
"@vitejs/plugin-vue": "^5.2.3",
|
package/types/client.d.ts
CHANGED
|
@@ -1 +1,266 @@
|
|
|
1
|
-
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { Static, TSchema } from '@sinclair/typebox';
|
|
4
|
+
import { SchemaObject } from 'ajv';
|
|
5
|
+
import { App, Component } from 'vue';
|
|
6
|
+
|
|
7
|
+
interface NodeRefResolved<T = any> {
|
|
8
|
+
readonly __nrg_node_ref: true;
|
|
9
|
+
readonly __instance: T;
|
|
10
|
+
}
|
|
11
|
+
interface TypedInputResolved {
|
|
12
|
+
resolve(...args: any[]): any;
|
|
13
|
+
value: unknown;
|
|
14
|
+
type: string;
|
|
15
|
+
}
|
|
16
|
+
interface JsonSchemaObjectExtensions {
|
|
17
|
+
format?: "node-id" | "flow-id" | "topic-path" | (string & {});
|
|
18
|
+
/** expose this settings property to the editor via RED.settings */
|
|
19
|
+
exportable?: boolean;
|
|
20
|
+
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
21
|
+
"x-nrg-node-type"?: string;
|
|
22
|
+
/** set by SchemaType.TypedInput — marks a TypedInput value/type pair */
|
|
23
|
+
"x-nrg-typed-input"?: boolean;
|
|
24
|
+
/** set by markNonValidatable — ajv skips this property */
|
|
25
|
+
"x-nrg-skip-validation"?: boolean;
|
|
26
|
+
/** form rendering hints consumed by the auto-generated editor form */
|
|
27
|
+
"x-nrg-form"?: {
|
|
28
|
+
icon?: string;
|
|
29
|
+
typedInputTypes?: string[];
|
|
30
|
+
editorLanguage?: string;
|
|
31
|
+
toggle?: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface NodeStateCredentials {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
export interface NodeState {
|
|
38
|
+
credentials: NodeStateCredentials;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
export interface NodeButtonDefinition {
|
|
42
|
+
toggle: string;
|
|
43
|
+
onClick: () => void;
|
|
44
|
+
enabled?: () => boolean;
|
|
45
|
+
visible?: () => boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface NodeRedNodeButtonDefinition {
|
|
48
|
+
toggle: string;
|
|
49
|
+
onclick: () => void;
|
|
50
|
+
enabled?: () => boolean;
|
|
51
|
+
visible?: () => boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface NodeFormDefinition {
|
|
54
|
+
component?: Component;
|
|
55
|
+
}
|
|
56
|
+
export interface NodeRedNode {
|
|
57
|
+
id: string;
|
|
58
|
+
type: string;
|
|
59
|
+
name: string;
|
|
60
|
+
category: string;
|
|
61
|
+
x: string;
|
|
62
|
+
y: string;
|
|
63
|
+
g: string;
|
|
64
|
+
z: string;
|
|
65
|
+
credentials: Record<string, any>;
|
|
66
|
+
_def: {
|
|
67
|
+
defaults: Record<string, {
|
|
68
|
+
value: string;
|
|
69
|
+
type?: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
credentials: Record<string, {
|
|
74
|
+
value: string;
|
|
75
|
+
type?: "password" | "text";
|
|
76
|
+
label?: string;
|
|
77
|
+
required?: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
category: string;
|
|
80
|
+
color?: string;
|
|
81
|
+
icon?: string;
|
|
82
|
+
label?: ((this: NodeRedNode) => string) | string;
|
|
83
|
+
inputs?: number;
|
|
84
|
+
outputs?: number;
|
|
85
|
+
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
86
|
+
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
87
|
+
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
88
|
+
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
89
|
+
align?: "left" | "right";
|
|
90
|
+
button?: NodeRedNodeButtonDefinition;
|
|
91
|
+
};
|
|
92
|
+
_newState?: NodeRedNode;
|
|
93
|
+
_app?: App | null;
|
|
94
|
+
_: (str: string) => string;
|
|
95
|
+
/** dynamic port count (base outputs + enabled built-in ports) */
|
|
96
|
+
outputs?: number;
|
|
97
|
+
/** injected when the node has an inputSchema */
|
|
98
|
+
validateInput?: boolean;
|
|
99
|
+
/** built-in port toggles, present when declared in the configSchema */
|
|
100
|
+
errorPort?: boolean;
|
|
101
|
+
completePort?: boolean;
|
|
102
|
+
statusPort?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Per-port output settings, indexed by base-output port. `validateOutputs` is
|
|
105
|
+
* injected (empty) when the node has an outputsSchema; `outputReturnProperties`
|
|
106
|
+
* and `outputContextModes` are author-declared (SchemaType.*) — present only
|
|
107
|
+
* when the node opts into per-port return keys / context modes. Read at
|
|
108
|
+
* runtime by IONode.
|
|
109
|
+
*/
|
|
110
|
+
validateOutputs?: Record<number, boolean>;
|
|
111
|
+
outputContextModes?: Record<number, "carry" | "trace" | "reset">;
|
|
112
|
+
outputReturnProperties?: Record<number, string>;
|
|
113
|
+
[key: string]: any;
|
|
114
|
+
}
|
|
115
|
+
export interface NodeDefinition {
|
|
116
|
+
type: string;
|
|
117
|
+
category?: string;
|
|
118
|
+
color?: string;
|
|
119
|
+
icon?: ((this: NodeRedNode) => string) | string;
|
|
120
|
+
label?: ((this: NodeRedNode) => string) | string;
|
|
121
|
+
inputs?: number;
|
|
122
|
+
outputs?: number;
|
|
123
|
+
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
124
|
+
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
125
|
+
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
126
|
+
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
127
|
+
align?: "left" | "right";
|
|
128
|
+
button?: NodeButtonDefinition;
|
|
129
|
+
onEditResize?: (this: NodeRedNode, size: {
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
}) => void;
|
|
133
|
+
onPaletteAdd?: (this: NodeRedNode) => void;
|
|
134
|
+
onPaletteRemove?: (this: NodeRedNode) => void;
|
|
135
|
+
form?: NodeFormDefinition;
|
|
136
|
+
}
|
|
137
|
+
/** Form rendering hints carried by the `x-nrg-form` schema keyword. */
|
|
138
|
+
export type NrgFormOptions = NonNullable<JsonSchemaObjectExtensions["x-nrg-form"]>;
|
|
139
|
+
/**
|
|
140
|
+
* A serialized property schema inside {@link JsonSchemaObject} `properties`,
|
|
141
|
+
* including NRG's custom keywords (shared vocabulary in core/schema-options)
|
|
142
|
+
* that drive form rendering and NodeRef/TypedInput identification.
|
|
143
|
+
*/
|
|
144
|
+
export interface JsonPropertySchema extends JsonSchemaObjectExtensions {
|
|
145
|
+
type?: string | string[];
|
|
146
|
+
properties?: Record<string, JsonPropertySchema>;
|
|
147
|
+
required?: string[];
|
|
148
|
+
enum?: unknown[];
|
|
149
|
+
anyOf?: JsonPropertySchema[];
|
|
150
|
+
const?: unknown;
|
|
151
|
+
items?: JsonPropertySchema;
|
|
152
|
+
title?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
default?: unknown;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A serialized JSON Schema object as the build pipeline emits it (never a
|
|
158
|
+
* live TypeBox instance). Extends ajv's `SchemaObject` so it flows into
|
|
159
|
+
* validator APIs without casts, while keeping the `type: "object"`
|
|
160
|
+
* discriminant and structured `properties`/`required` that ajv's open
|
|
161
|
+
* `[x: string]: any` shape does not provide.
|
|
162
|
+
*/
|
|
163
|
+
export interface JsonSchemaObject extends SchemaObject {
|
|
164
|
+
type: "object";
|
|
165
|
+
properties?: Record<string, JsonPropertySchema>;
|
|
166
|
+
required?: string[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A node definition as it exists at editor runtime, after the build pipeline
|
|
170
|
+
* merged in the schema-derived artifacts (defaults, credentials, serialized
|
|
171
|
+
* schemas). Authors write {@link NodeDefinition}; the inliner provides the
|
|
172
|
+
* rest.
|
|
173
|
+
*/
|
|
174
|
+
export interface RuntimeNodeDefinition extends NodeDefinition {
|
|
175
|
+
defaults?: NodeDefaults;
|
|
176
|
+
credentials?: NodeCredentials;
|
|
177
|
+
/**
|
|
178
|
+
* Names of the base output ports when `outputsSchema` is a record of named
|
|
179
|
+
* ports, in declaration order; absent for single/positional outputs. Resolved
|
|
180
|
+
* server-side by the inliner so the editor never guesses port names from the
|
|
181
|
+
* serialized schema.
|
|
182
|
+
*/
|
|
183
|
+
outputPortNames?: string[];
|
|
184
|
+
configSchema?: JsonSchemaObject;
|
|
185
|
+
credentialsSchema?: JsonSchemaObject;
|
|
186
|
+
inputSchema?: JsonSchemaObject;
|
|
187
|
+
/**
|
|
188
|
+
* Single port, positional ports, or named ports (key = port name).
|
|
189
|
+
* Not constrained to object schemas: with returnProperty the raw sent
|
|
190
|
+
* value is validated, so results may be any schema shape.
|
|
191
|
+
*/
|
|
192
|
+
outputsSchema?: JsonPropertySchema | JsonPropertySchema[] | Record<string, JsonPropertySchema>;
|
|
193
|
+
}
|
|
194
|
+
export interface NodeDefaults {
|
|
195
|
+
[key: string]: {
|
|
196
|
+
value: any;
|
|
197
|
+
type?: string;
|
|
198
|
+
label?: string;
|
|
199
|
+
required?: boolean;
|
|
200
|
+
validate?: (this: NodeRedNode, value: any, opt: any) => any;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
export interface NodeCredentials {
|
|
204
|
+
[key: string]: {
|
|
205
|
+
value?: string;
|
|
206
|
+
type?: "password" | "text";
|
|
207
|
+
label?: string;
|
|
208
|
+
required?: boolean;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export interface NodeFeatures {
|
|
212
|
+
hasInputSchema: boolean;
|
|
213
|
+
hasOutputSchema: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Base output ports (excludes built-in error/complete/status), in port-index
|
|
216
|
+
* order. Drives the per-port context-mode rows in the Outputs subsection.
|
|
217
|
+
*/
|
|
218
|
+
outputPorts: {
|
|
219
|
+
index: number;
|
|
220
|
+
label: string;
|
|
221
|
+
}[];
|
|
222
|
+
}
|
|
223
|
+
/** Client-side representation of a TypedInput field: the raw value string and its type selector. */
|
|
224
|
+
export interface TypedInputValue {
|
|
225
|
+
value: string;
|
|
226
|
+
type: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Maps a schema's static type to the raw values the editor form holds.
|
|
230
|
+
* The server counterpart (`ResolvedStatic` in server/schemas/types) maps the
|
|
231
|
+
* same brands — shared via core/brands — to resolved runtime values instead.
|
|
232
|
+
* - `NodeRef<T>` → `string` (the referenced node's id)
|
|
233
|
+
* - `TypedInput<T>` → `TypedInputValue` (raw value + type pair)
|
|
234
|
+
* - Functions pass through, arrays and objects map recursively
|
|
235
|
+
*/
|
|
236
|
+
export type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extends TypedInputResolved ? TypedInputValue : T extends (...args: any[]) => any ? T : T extends Array<infer I> ? EditorStatic<I>[] : T extends object ? {
|
|
237
|
+
[K in keyof T]: EditorStatic<T[K]>;
|
|
238
|
+
} : T;
|
|
239
|
+
/**
|
|
240
|
+
* Infers the client-side TypeScript type from a TypeBox schema.
|
|
241
|
+
*
|
|
242
|
+
* Resolves schema types to their client form representations:
|
|
243
|
+
* - `NodeRef<T>` → `string` (node ID in the editor)
|
|
244
|
+
* - `TypedInput<T>` → `{ value: string; type: string }`
|
|
245
|
+
* - All other types resolve via TypeBox's `Static<T>`
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* import type { Infer } from "@bonsae/nrg/client";
|
|
250
|
+
* import type { ConfigSchema } from "../schemas/my-node";
|
|
251
|
+
*
|
|
252
|
+
* type Config = Infer<typeof ConfigSchema>;
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export type Infer<T extends TSchema> = EditorStatic<Static<T>>;
|
|
256
|
+
|
|
257
|
+
export {};
|
|
258
|
+
|
|
259
|
+
export declare function defineNode<T extends NodeDefinition>(options: T): T;
|
|
260
|
+
export declare function registerType(definition: NodeDefinition): Promise<void>;
|
|
261
|
+
export declare function registerTypes(nodes: NodeDefinition[]): Promise<void>;
|
|
262
|
+
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): {
|
|
263
|
+
node: NodeRedNode & Infer<TConfig> & { credentials: Infer<TCredentials> & Record<string, any> };
|
|
264
|
+
schema: Record<string, any>;
|
|
265
|
+
errors: Record<string, string>;
|
|
266
|
+
};
|
package/types/server.d.ts
CHANGED
|
@@ -1 +1,941 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./shims/typebox.d.ts" />
|
|
2
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
3
|
+
|
|
4
|
+
import { Kind, ObjectOptions, SchemaOptions, Static, TArray, TBoolean, TConst, TEnum, TFunction, TInteger, TIntersect, TLiteral, TNull, TNumber, TObject, TOptional, TProperties, TRecord, TRef, TSchema, TString, TTuple, TUnion } from '@sinclair/typebox';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { Express as Express$1 } from 'express';
|
|
7
|
+
import { Http2ServerRequest } from 'http2';
|
|
8
|
+
|
|
9
|
+
declare const TYPED_INPUT_TYPES: readonly [
|
|
10
|
+
"msg",
|
|
11
|
+
"flow",
|
|
12
|
+
"global",
|
|
13
|
+
"str",
|
|
14
|
+
"num",
|
|
15
|
+
"bool",
|
|
16
|
+
"json",
|
|
17
|
+
"bin",
|
|
18
|
+
"re",
|
|
19
|
+
"jsonata",
|
|
20
|
+
"date",
|
|
21
|
+
"env",
|
|
22
|
+
"node",
|
|
23
|
+
"cred"
|
|
24
|
+
];
|
|
25
|
+
declare const BUILTIN_PORT_KEYS: readonly [
|
|
26
|
+
"errorPort",
|
|
27
|
+
"completePort",
|
|
28
|
+
"statusPort"
|
|
29
|
+
];
|
|
30
|
+
export interface NodeRedRuntimeSettings {
|
|
31
|
+
userDir?: string;
|
|
32
|
+
nodesDir?: string | string[];
|
|
33
|
+
flowFile?: string;
|
|
34
|
+
flowFilePretty?: boolean;
|
|
35
|
+
credentialSecret?: string | false;
|
|
36
|
+
requireHttps?: boolean;
|
|
37
|
+
https?: {
|
|
38
|
+
key: string;
|
|
39
|
+
cert: string;
|
|
40
|
+
} | (() => Promise<{
|
|
41
|
+
key: string;
|
|
42
|
+
cert: string;
|
|
43
|
+
}> | {
|
|
44
|
+
key: string;
|
|
45
|
+
cert: string;
|
|
46
|
+
});
|
|
47
|
+
httpsRefreshInterval?: number;
|
|
48
|
+
httpAdminRoot?: string;
|
|
49
|
+
httpNodeRoot?: string;
|
|
50
|
+
httpNodeCors?: {
|
|
51
|
+
origin: string;
|
|
52
|
+
methods: string;
|
|
53
|
+
};
|
|
54
|
+
httpStatic?: string | {
|
|
55
|
+
path: string;
|
|
56
|
+
root: string;
|
|
57
|
+
}[];
|
|
58
|
+
httpStaticRoot?: string;
|
|
59
|
+
httpAdminMiddleware?: (req: unknown, res: unknown, next: () => void) => void;
|
|
60
|
+
httpNodeMiddleware?: (req: unknown, res: unknown, next: () => void) => void;
|
|
61
|
+
httpServerOptions?: Record<string, unknown>;
|
|
62
|
+
adminAuth?: {
|
|
63
|
+
type?: "credentials" | "strategy";
|
|
64
|
+
users?: {
|
|
65
|
+
username: string;
|
|
66
|
+
password: string;
|
|
67
|
+
permissions?: string | string[];
|
|
68
|
+
}[];
|
|
69
|
+
default?: {
|
|
70
|
+
permissions?: string | string[];
|
|
71
|
+
};
|
|
72
|
+
tokens?: (token: string) => Promise<{
|
|
73
|
+
user: string;
|
|
74
|
+
permissions: string | string[];
|
|
75
|
+
} | null>;
|
|
76
|
+
tokenHeader: "string";
|
|
77
|
+
sessionExpiryTime?: number;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
};
|
|
80
|
+
httpNodeAuth?: {
|
|
81
|
+
user?: string;
|
|
82
|
+
pass?: string;
|
|
83
|
+
};
|
|
84
|
+
httpStaticAuth?: {
|
|
85
|
+
user?: string;
|
|
86
|
+
pass?: string;
|
|
87
|
+
};
|
|
88
|
+
lang?: "en-US" | "de" | "es-ES" | "fr" | "ko" | "pt-BR" | "ru" | "ja" | "zh-CN" | "zh-TW";
|
|
89
|
+
diagnostics?: {
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
ui?: boolean;
|
|
92
|
+
};
|
|
93
|
+
runtimeState?: {
|
|
94
|
+
enabled?: boolean;
|
|
95
|
+
ui?: boolean;
|
|
96
|
+
};
|
|
97
|
+
disableEditor?: boolean;
|
|
98
|
+
editorTheme?: {
|
|
99
|
+
page?: {
|
|
100
|
+
title?: string;
|
|
101
|
+
favicon?: string;
|
|
102
|
+
css?: string | string[];
|
|
103
|
+
scripts?: string | string[];
|
|
104
|
+
};
|
|
105
|
+
header?: {
|
|
106
|
+
title?: string;
|
|
107
|
+
image?: string;
|
|
108
|
+
url?: string;
|
|
109
|
+
};
|
|
110
|
+
deployButton?: {
|
|
111
|
+
type?: "simple" | "default";
|
|
112
|
+
label?: string;
|
|
113
|
+
icon?: string;
|
|
114
|
+
};
|
|
115
|
+
menu?: {
|
|
116
|
+
"menu-item-import-library"?: boolean;
|
|
117
|
+
"menu-item-export-library"?: boolean;
|
|
118
|
+
"menu-item-keyboard-shortcuts"?: boolean;
|
|
119
|
+
"menu-item-help"?: {
|
|
120
|
+
label?: string;
|
|
121
|
+
url?: string;
|
|
122
|
+
};
|
|
123
|
+
[menuItem: string]: boolean | {
|
|
124
|
+
label?: string;
|
|
125
|
+
url?: string;
|
|
126
|
+
} | undefined;
|
|
127
|
+
};
|
|
128
|
+
userMenu?: boolean;
|
|
129
|
+
login?: {
|
|
130
|
+
image?: string;
|
|
131
|
+
};
|
|
132
|
+
logout?: {
|
|
133
|
+
redirect?: string;
|
|
134
|
+
};
|
|
135
|
+
palette?: {
|
|
136
|
+
catalogues?: string[];
|
|
137
|
+
categories?: string[];
|
|
138
|
+
theme?: {
|
|
139
|
+
category: string;
|
|
140
|
+
type: string;
|
|
141
|
+
color: string;
|
|
142
|
+
}[];
|
|
143
|
+
};
|
|
144
|
+
projects?: {
|
|
145
|
+
enabled?: boolean;
|
|
146
|
+
workflow?: {
|
|
147
|
+
mode: "manual" | "auto";
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
codeEditor?: {
|
|
151
|
+
lib?: "monaco" | "ace";
|
|
152
|
+
options?: Record<string, unknown>;
|
|
153
|
+
};
|
|
154
|
+
mermaid?: {
|
|
155
|
+
theme?: string;
|
|
156
|
+
};
|
|
157
|
+
tours?: boolean;
|
|
158
|
+
theme?: string;
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
contextStorage?: {
|
|
162
|
+
default?: {
|
|
163
|
+
module?: "memory" | "localfilesystem" | object;
|
|
164
|
+
config?: Record<string, unknown>;
|
|
165
|
+
};
|
|
166
|
+
[store: string]: {
|
|
167
|
+
module?: "memory" | "localfilesystem" | object;
|
|
168
|
+
config?: Record<string, unknown>;
|
|
169
|
+
} | undefined;
|
|
170
|
+
};
|
|
171
|
+
exportGlobalContextKeys?: boolean;
|
|
172
|
+
logging?: {
|
|
173
|
+
console?: {
|
|
174
|
+
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "off";
|
|
175
|
+
metrics?: boolean;
|
|
176
|
+
audit?: boolean;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
fileWorkingDirectory?: string;
|
|
180
|
+
functionExternalModules?: boolean;
|
|
181
|
+
functionGlobalContext?: Record<string, unknown>;
|
|
182
|
+
nodeMessageBufferMaxLength?: number;
|
|
183
|
+
functionTimeout?: number;
|
|
184
|
+
externalModules?: {
|
|
185
|
+
autoInstall?: boolean;
|
|
186
|
+
autoInstallRetry?: number;
|
|
187
|
+
palette?: {
|
|
188
|
+
allowInstall?: boolean;
|
|
189
|
+
allowUpdate?: boolean;
|
|
190
|
+
allowUpload?: boolean;
|
|
191
|
+
allowList?: string[];
|
|
192
|
+
denyList?: string[];
|
|
193
|
+
allowUpdateList?: string[];
|
|
194
|
+
denyUpdateList?: string[];
|
|
195
|
+
};
|
|
196
|
+
modules?: {
|
|
197
|
+
allowInstall?: boolean;
|
|
198
|
+
allowList?: string[];
|
|
199
|
+
denyList?: string[];
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
execMaxBufferSize?: number;
|
|
203
|
+
debugMaxLength?: number;
|
|
204
|
+
debugUseColors?: boolean;
|
|
205
|
+
httpRequestTimeout?: number;
|
|
206
|
+
mqttReconnectTime?: number;
|
|
207
|
+
serialReconnectTime?: number;
|
|
208
|
+
socketReconnectTime?: number;
|
|
209
|
+
socketTimeout?: number;
|
|
210
|
+
tcpMsgQueueSize?: number;
|
|
211
|
+
inboundWebSocketTimeout?: number;
|
|
212
|
+
tlsConfigDisableLocalFiles?: boolean;
|
|
213
|
+
webSocketNodeVerifyClient?: (info: {
|
|
214
|
+
origin: string;
|
|
215
|
+
req: Http2ServerRequest;
|
|
216
|
+
secure: boolean;
|
|
217
|
+
}) => boolean;
|
|
218
|
+
apiMaxLength?: string;
|
|
219
|
+
[key: string]: unknown;
|
|
220
|
+
}
|
|
221
|
+
interface NodeRedLog {
|
|
222
|
+
info(msg: any): void;
|
|
223
|
+
warn(msg: any): void;
|
|
224
|
+
error(msg: any, error?: any): void;
|
|
225
|
+
debug(msg: any): void;
|
|
226
|
+
trace(msg: any): void;
|
|
227
|
+
log(msg: {
|
|
228
|
+
level: number;
|
|
229
|
+
msg: string;
|
|
230
|
+
}): void;
|
|
231
|
+
metric(): boolean;
|
|
232
|
+
audit(msg: Record<string, any>, req?: any): void;
|
|
233
|
+
addHandler(handler: (msg: any) => void): void;
|
|
234
|
+
removeHandler(handler: (msg: any) => void): void;
|
|
235
|
+
FATAL: 10;
|
|
236
|
+
ERROR: 20;
|
|
237
|
+
WARN: 30;
|
|
238
|
+
INFO: 40;
|
|
239
|
+
DEBUG: 50;
|
|
240
|
+
TRACE: 60;
|
|
241
|
+
AUDIT: 98;
|
|
242
|
+
METRIC: 99;
|
|
243
|
+
}
|
|
244
|
+
interface NodeRedNode {
|
|
245
|
+
id: string;
|
|
246
|
+
type: string;
|
|
247
|
+
name?: string;
|
|
248
|
+
z?: string;
|
|
249
|
+
x: number;
|
|
250
|
+
y: number;
|
|
251
|
+
g?: string;
|
|
252
|
+
wires: string[][];
|
|
253
|
+
credentials: any;
|
|
254
|
+
_node?: INode;
|
|
255
|
+
send(msg: any): void;
|
|
256
|
+
receive(msg: any): void;
|
|
257
|
+
status(status: string | {
|
|
258
|
+
fill?: string;
|
|
259
|
+
shape?: string;
|
|
260
|
+
text?: string;
|
|
261
|
+
}): void;
|
|
262
|
+
updateWires(wires: string[][]): void;
|
|
263
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
264
|
+
log(msg: any): void;
|
|
265
|
+
warn(msg: any): void;
|
|
266
|
+
error(msg: any, errorMsg?: any): void;
|
|
267
|
+
context(): NodeRedNodeContext;
|
|
268
|
+
[key: string]: any;
|
|
269
|
+
}
|
|
270
|
+
interface NodeRedNodeContext extends NodeRedContextStore {
|
|
271
|
+
flow: NodeRedContextStore;
|
|
272
|
+
global: NodeRedContextStore;
|
|
273
|
+
}
|
|
274
|
+
interface NodeRedNodes {
|
|
275
|
+
registerType(type: string, constructor: any, opts?: any): void;
|
|
276
|
+
getNode(id: string): (NodeRedNode & {
|
|
277
|
+
_node?: INode;
|
|
278
|
+
}) | undefined;
|
|
279
|
+
createNode(node: NodeRedNode, config: Record<string, any>): void;
|
|
280
|
+
getCredentials(id: string): Record<string, any> | undefined;
|
|
281
|
+
/** Merge credentials into a node's stored credential set (runtime API). */
|
|
282
|
+
addCredentials(id: string, credentials: Record<string, any>): void;
|
|
283
|
+
eachNode(callback: (node: any) => void): void;
|
|
284
|
+
getType(type: string): any;
|
|
285
|
+
getNodeInfo(type: string): any;
|
|
286
|
+
getNodeList(filter?: any): any[];
|
|
287
|
+
getModuleInfo(module: string): any;
|
|
288
|
+
installModule(module: string, version?: string): Promise<any>;
|
|
289
|
+
uninstallModule(module: string): Promise<any>;
|
|
290
|
+
enableNode(id: string): Promise<any>;
|
|
291
|
+
disableNode(id: string): Promise<any>;
|
|
292
|
+
}
|
|
293
|
+
interface NodeRedUtil {
|
|
294
|
+
evaluateNodeProperty(value: any, type: string, node: any, msg: Record<string, any> | undefined, callback: (err: Error | null, result: any) => void): void;
|
|
295
|
+
generateId(): string;
|
|
296
|
+
cloneMessage<T = any>(msg: T): T;
|
|
297
|
+
ensureString(o: any): string;
|
|
298
|
+
ensureBuffer(o: any): Buffer;
|
|
299
|
+
compareObjects(obj1: any, obj2: any): boolean;
|
|
300
|
+
getMessageProperty(msg: any, expr: string): any;
|
|
301
|
+
setMessageProperty(msg: any, prop: string, value: any, createMissing?: boolean): void;
|
|
302
|
+
getObjectProperty(obj: any, expr: string): any;
|
|
303
|
+
setObjectProperty(obj: any, prop: string, value: any, createMissing?: boolean): void;
|
|
304
|
+
normalisePropertyExpression(str: string, msg?: any, toString?: boolean): string[];
|
|
305
|
+
normaliseNodeTypeName(name: string): string;
|
|
306
|
+
prepareJSONataExpression(value: string, node: any): any;
|
|
307
|
+
evaluateJSONataExpression(expr: any, msg: any, callback: (err: Error | null, result: any) => void): void;
|
|
308
|
+
parseContextStore(key: string): {
|
|
309
|
+
store: string | undefined;
|
|
310
|
+
key: string;
|
|
311
|
+
};
|
|
312
|
+
getSetting(node: any, name: string, flow?: any): any;
|
|
313
|
+
encodeObject(obj: any): any;
|
|
314
|
+
}
|
|
315
|
+
interface NodeRedHooks {
|
|
316
|
+
add(hookId: string, callback: (event: any) => void | Promise<void>): void;
|
|
317
|
+
remove(hookId: string): void;
|
|
318
|
+
trigger(hookId: string, event: any, callback?: (err?: Error) => void): void | Promise<void>;
|
|
319
|
+
has(hookId: string): boolean;
|
|
320
|
+
clear(): void;
|
|
321
|
+
}
|
|
322
|
+
type NodeRedExpressApp = Express;
|
|
323
|
+
export interface RED {
|
|
324
|
+
/** Internationalization function */
|
|
325
|
+
_(key: string, substitutions?: Record<string, string>): string;
|
|
326
|
+
/** Logging API */
|
|
327
|
+
log: NodeRedLog;
|
|
328
|
+
/** Node registry and management */
|
|
329
|
+
nodes: NodeRedNodes;
|
|
330
|
+
/** Utility functions */
|
|
331
|
+
util: NodeRedUtil;
|
|
332
|
+
/** Hook system for message lifecycle and module events */
|
|
333
|
+
hooks: NodeRedHooks;
|
|
334
|
+
/** Runtime event emitter */
|
|
335
|
+
events: EventEmitter;
|
|
336
|
+
/** Express app for admin HTTP endpoints */
|
|
337
|
+
httpAdmin: NodeRedExpressApp;
|
|
338
|
+
/** Express app for node HTTP endpoints */
|
|
339
|
+
httpNode: NodeRedExpressApp;
|
|
340
|
+
/** Runtime settings (user-provided settings plus node-registered settings) */
|
|
341
|
+
settings: NodeRedRuntimeSettings & Record<string, any>;
|
|
342
|
+
/** Node-RED version string */
|
|
343
|
+
version(): string;
|
|
344
|
+
}
|
|
345
|
+
interface NodeRedContextStore {
|
|
346
|
+
get(key: string, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
347
|
+
set(key: string, value: any, store: string | undefined, callback: (err: Error | null) => void): void;
|
|
348
|
+
keys(store: string | undefined, callback: (err: Error | null, keys: string[]) => void): void;
|
|
349
|
+
/**
|
|
350
|
+
* Optional atomic add — provided by context stores that support it (e.g.
|
|
351
|
+
* DynamoDB `ADD` / Redis `INCR`). When absent, nrg serializes in-process.
|
|
352
|
+
*/
|
|
353
|
+
increment?(key: string, by: number, store: string | undefined, callback: (err: Error | null, value: number) => void): void;
|
|
354
|
+
/**
|
|
355
|
+
* Optional atomic read-modify-write — provided by stores that support it
|
|
356
|
+
* (e.g. a DynamoDB conditional write). When absent, nrg serializes in-process.
|
|
357
|
+
*/
|
|
358
|
+
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
359
|
+
}
|
|
360
|
+
declare class TypedInput<T = unknown> {
|
|
361
|
+
private readonly RED;
|
|
362
|
+
private readonly node;
|
|
363
|
+
private readonly input;
|
|
364
|
+
private readonly resolvers;
|
|
365
|
+
constructor(RED: RED, node: NodeRedNode, input: {
|
|
366
|
+
value: unknown;
|
|
367
|
+
type: TypedInputType;
|
|
368
|
+
});
|
|
369
|
+
get type(): TypedInputType;
|
|
370
|
+
get value(): unknown;
|
|
371
|
+
resolve(msg?: Record<string, any>): Promise<T>;
|
|
372
|
+
}
|
|
373
|
+
interface JsonSchemaObjectExtensions {
|
|
374
|
+
format?: "node-id" | "flow-id" | "topic-path" | (string & {});
|
|
375
|
+
/** expose this settings property to the editor via RED.settings */
|
|
376
|
+
exportable?: boolean;
|
|
377
|
+
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
378
|
+
"x-nrg-node-type"?: string;
|
|
379
|
+
/** set by SchemaType.TypedInput — marks a TypedInput value/type pair */
|
|
380
|
+
"x-nrg-typed-input"?: boolean;
|
|
381
|
+
/** set by markNonValidatable — ajv skips this property */
|
|
382
|
+
"x-nrg-skip-validation"?: boolean;
|
|
383
|
+
/** form rendering hints consumed by the auto-generated editor form */
|
|
384
|
+
"x-nrg-form"?: {
|
|
385
|
+
icon?: string;
|
|
386
|
+
typedInputTypes?: string[];
|
|
387
|
+
editorLanguage?: string;
|
|
388
|
+
toggle?: boolean;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
declare const NodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
392
|
+
id: import("@sinclair/typebox").TString;
|
|
393
|
+
type: import("@sinclair/typebox").TString;
|
|
394
|
+
name: import("@sinclair/typebox").TString;
|
|
395
|
+
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
396
|
+
}>;
|
|
397
|
+
declare const ConfigNodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
398
|
+
_users: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
399
|
+
id: import("@sinclair/typebox").TString;
|
|
400
|
+
type: import("@sinclair/typebox").TString;
|
|
401
|
+
name: import("@sinclair/typebox").TString;
|
|
402
|
+
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
403
|
+
}>;
|
|
404
|
+
declare const IONodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
405
|
+
wires: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
406
|
+
x: import("@sinclair/typebox").TNumber;
|
|
407
|
+
y: import("@sinclair/typebox").TNumber;
|
|
408
|
+
g: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
409
|
+
id: import("@sinclair/typebox").TString;
|
|
410
|
+
type: import("@sinclair/typebox").TString;
|
|
411
|
+
name: import("@sinclair/typebox").TString;
|
|
412
|
+
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
413
|
+
}>;
|
|
414
|
+
export declare const NodeSourceSchema: import("@sinclair/typebox").TObject<{
|
|
415
|
+
id: import("@sinclair/typebox").TString;
|
|
416
|
+
type: import("@sinclair/typebox").TString;
|
|
417
|
+
name: import("@sinclair/typebox").TString;
|
|
418
|
+
}>;
|
|
419
|
+
export declare const ErrorPortSchema: import("@sinclair/typebox").TObject<{
|
|
420
|
+
error: import("@sinclair/typebox").TObject<{
|
|
421
|
+
message: import("@sinclair/typebox").TString;
|
|
422
|
+
source: import("@sinclair/typebox").TObject<{
|
|
423
|
+
id: import("@sinclair/typebox").TString;
|
|
424
|
+
type: import("@sinclair/typebox").TString;
|
|
425
|
+
name: import("@sinclair/typebox").TString;
|
|
426
|
+
}>;
|
|
427
|
+
}>;
|
|
428
|
+
}>;
|
|
429
|
+
export declare const CompletePortSchema: import("@sinclair/typebox").TObject<{
|
|
430
|
+
complete: import("@sinclair/typebox").TObject<{
|
|
431
|
+
source: import("@sinclair/typebox").TObject<{
|
|
432
|
+
id: import("@sinclair/typebox").TString;
|
|
433
|
+
type: import("@sinclair/typebox").TString;
|
|
434
|
+
name: import("@sinclair/typebox").TString;
|
|
435
|
+
}>;
|
|
436
|
+
}>;
|
|
437
|
+
}>;
|
|
438
|
+
export declare const StatusPortSchema: import("@sinclair/typebox").TObject<{
|
|
439
|
+
status: import("@sinclair/typebox").TUnion<[
|
|
440
|
+
import("@sinclair/typebox").TObject<{
|
|
441
|
+
fill: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[
|
|
442
|
+
import("@sinclair/typebox").TLiteral<"red">,
|
|
443
|
+
import("@sinclair/typebox").TLiteral<"green">
|
|
444
|
+
]>>;
|
|
445
|
+
shape: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[
|
|
446
|
+
import("@sinclair/typebox").TLiteral<"dot">,
|
|
447
|
+
import("@sinclair/typebox").TLiteral<"string">
|
|
448
|
+
]>>;
|
|
449
|
+
text: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
450
|
+
}>,
|
|
451
|
+
import("@sinclair/typebox").TString
|
|
452
|
+
]>;
|
|
453
|
+
source: import("@sinclair/typebox").TObject<{
|
|
454
|
+
id: import("@sinclair/typebox").TString;
|
|
455
|
+
type: import("@sinclair/typebox").TString;
|
|
456
|
+
name: import("@sinclair/typebox").TString;
|
|
457
|
+
}>;
|
|
458
|
+
}>;
|
|
459
|
+
interface NodeRefResolved<T = any> {
|
|
460
|
+
readonly __nrg_node_ref: true;
|
|
461
|
+
readonly __instance: T;
|
|
462
|
+
}
|
|
463
|
+
/** Schema type representing a reference to a config node. Resolves to the node instance at runtime. */
|
|
464
|
+
export interface TNodeRef<T = any> extends TSchema {
|
|
465
|
+
[Kind]: "NodeRef";
|
|
466
|
+
static: NodeRefResolved<T>;
|
|
467
|
+
type: "string";
|
|
468
|
+
format: "node-id";
|
|
469
|
+
"x-nrg-node-type"?: string;
|
|
470
|
+
}
|
|
471
|
+
type ResolvedStatic<T> = T extends NodeRefResolved<infer I> ? I : T extends TypedInput<any> ? T : T extends (...args: any[]) => any ? T : T extends Array<infer Item> ? ResolvedStatic<Item>[] : T extends object ? {
|
|
472
|
+
[K in keyof T]: ResolvedStatic<T[K]>;
|
|
473
|
+
} : T;
|
|
474
|
+
/**
|
|
475
|
+
* Infers the TypeScript type from a schema or a record of schemas.
|
|
476
|
+
*
|
|
477
|
+
* - Single schema: `Infer<typeof MySchema>` → the inferred message type
|
|
478
|
+
* - Record of schemas: `Infer<typeof outputsSchema>` → `{ portName: InferredType }` port map
|
|
479
|
+
*
|
|
480
|
+
* The record form produces a simple mapped type that resolves eagerly,
|
|
481
|
+
* giving `sendToPort()` proper autocomplete in class-based nodes.
|
|
482
|
+
*/
|
|
483
|
+
export type Infer<T extends TSchema | Record<string, TSchema>> = T extends TSchema ? ResolvedStatic<Static<T>> : {
|
|
484
|
+
[K in keyof T & string]: T[K] extends TSchema ? ResolvedStatic<Static<T[K]>> : never;
|
|
485
|
+
};
|
|
486
|
+
type TypedInputType = (typeof TYPED_INPUT_TYPES)[number];
|
|
487
|
+
/** Schema type representing a Node-RED TypedInput (value + type pair). */
|
|
488
|
+
export interface TTypedInput<T = unknown> extends TSchema {
|
|
489
|
+
[Kind]: "TypedInput";
|
|
490
|
+
static: TypedInput<T>;
|
|
491
|
+
"x-nrg-typed-input": true;
|
|
492
|
+
}
|
|
493
|
+
interface NrgSchemaOptions extends SchemaOptions, JsonSchemaObjectExtensions {
|
|
494
|
+
}
|
|
495
|
+
/** An NRG object schema created by {@link defineSchema}. */
|
|
496
|
+
export type Schema<T extends TProperties = TProperties> = TObject<T>;
|
|
497
|
+
export type NodeSource = Static<typeof NodeSourceSchema>;
|
|
498
|
+
export type ErrorPortMessage = Static<typeof ErrorPortSchema>;
|
|
499
|
+
export type CompletePortMessage = Static<typeof CompletePortSchema>;
|
|
500
|
+
export type StatusPortMessage = Static<typeof StatusPortSchema>;
|
|
501
|
+
type InferOr<T, Fallback> = T extends TSchema ? Infer<T> : Fallback;
|
|
502
|
+
type InferOutputs<T> = T extends readonly TSchema[] ? {
|
|
503
|
+
[K in keyof T]: T[K] extends TSchema ? Infer<T[K]> : never;
|
|
504
|
+
} : T extends TSchema ? Infer<T> : T extends Record<string, TSchema> ? {
|
|
505
|
+
[K in keyof T & string]: Infer<T[K]>;
|
|
506
|
+
} : any;
|
|
507
|
+
declare function NodeRef<T extends (new (...args: any[]) => any) & {
|
|
508
|
+
type: string;
|
|
509
|
+
}>(nodeClass: T, options?: NrgSchemaOptions): TNodeRef<InstanceType<T>>;
|
|
510
|
+
declare function TypedInput$1<T = unknown>(options?: NrgSchemaOptions): TTypedInput<T>;
|
|
511
|
+
declare function OutputReturnProperties(options?: NrgSchemaOptions & {
|
|
512
|
+
default?: Record<number, string>;
|
|
513
|
+
}): import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TString>;
|
|
514
|
+
declare function OutputContextModes(options?: NrgSchemaOptions & {
|
|
515
|
+
default?: Record<number, "carry" | "trace" | "reset">;
|
|
516
|
+
}): import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnion<[
|
|
517
|
+
import("@sinclair/typebox").TLiteral<"carry">,
|
|
518
|
+
import("@sinclair/typebox").TLiteral<"trace">,
|
|
519
|
+
import("@sinclair/typebox").TLiteral<"reset">
|
|
520
|
+
]>>;
|
|
521
|
+
/**
|
|
522
|
+
* Extended TypeBox type builder with NRG-specific schema types.
|
|
523
|
+
* Includes all standard TypeBox types plus {@link NodeRef}, {@link TypedInput},
|
|
524
|
+
* {@link OutputReturnProperties} and {@link OutputContextModes}.
|
|
525
|
+
*
|
|
526
|
+
* For ports or config fields that carry non-data values (functions, class
|
|
527
|
+
* instances, Buffers, streams, connections), use `Unsafe<T>()` to get the
|
|
528
|
+
* TypeScript type without runtime validation — `Any()`/`Unknown()` skip
|
|
529
|
+
* validation too but lose the type. For config-node references and typed inputs
|
|
530
|
+
* use {@link NodeRef} / {@link TypedInput} instead. See the Schemas guide.
|
|
531
|
+
*/
|
|
532
|
+
export declare const SchemaType: import("@sinclair/typebox").JavaScriptTypeBuilder & {
|
|
533
|
+
NodeRef: typeof NodeRef;
|
|
534
|
+
TypedInput: typeof TypedInput$1;
|
|
535
|
+
OutputReturnProperties: typeof OutputReturnProperties;
|
|
536
|
+
OutputContextModes: typeof OutputContextModes;
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* Creates a validated object schema from a set of properties. Automatically
|
|
540
|
+
* marks non-JSON types (e.g., Function) as non-validatable.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```ts
|
|
544
|
+
* const ConfigsSchema = defineSchema({
|
|
545
|
+
* name: SchemaType.String({ default: "" }),
|
|
546
|
+
* timeout: SchemaType.Number({ default: 5000 }),
|
|
547
|
+
* }, { $id: "my-node:configs" });
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
export declare function defineSchema<T extends TProperties>(properties: T, options?: ObjectOptions & {
|
|
551
|
+
$id?: string;
|
|
552
|
+
}): Schema<T>;
|
|
553
|
+
type NodeContextScope = "node" | "flow" | "global";
|
|
554
|
+
interface NodeContextStore {
|
|
555
|
+
get<T = any>(key: string): Promise<T>;
|
|
556
|
+
set<T = any>(key: string, value: T): Promise<void>;
|
|
557
|
+
keys(): Promise<string[]>;
|
|
558
|
+
/**
|
|
559
|
+
* Atomically add `by` (default 1) to a numeric key and return the new value.
|
|
560
|
+
* Prefer this over `get`+`set` for counters: it's atomic across instances when
|
|
561
|
+
* the context store supports it (e.g. a DynamoDB `ADD` or Redis `INCR` store),
|
|
562
|
+
* and serialized within the process otherwise — so concurrent messages never
|
|
563
|
+
* lose updates.
|
|
564
|
+
*/
|
|
565
|
+
increment(key: string, by?: number): Promise<number>;
|
|
566
|
+
/**
|
|
567
|
+
* Atomic read-modify-write: `fn(current)` returns the next value, applied
|
|
568
|
+
* atomically (a conditional write + retry on a capable store, a per-key lock
|
|
569
|
+
* otherwise). `fn` MAY run more than once on a write conflict, so keep it pure
|
|
570
|
+
* (no side effects).
|
|
571
|
+
*/
|
|
572
|
+
update<T = any>(key: string, fn: (current: T) => T | Promise<T>): Promise<T>;
|
|
573
|
+
}
|
|
574
|
+
export interface NodeConstructor<T = any, TConfig = any, TCredentials = any> {
|
|
575
|
+
readonly type: string;
|
|
576
|
+
readonly category: string;
|
|
577
|
+
readonly color?: string;
|
|
578
|
+
readonly align?: "left" | "right";
|
|
579
|
+
readonly inputs?: number;
|
|
580
|
+
readonly outputs?: number;
|
|
581
|
+
readonly configSchema?: Schema;
|
|
582
|
+
readonly credentialsSchema?: Schema;
|
|
583
|
+
readonly settingsSchema?: Schema;
|
|
584
|
+
readonly inputSchema?: Schema;
|
|
585
|
+
readonly outputsSchema?: TSchema | TSchema[] | Record<string, TSchema>;
|
|
586
|
+
readonly validateInput?: boolean;
|
|
587
|
+
readonly validateOutput?: boolean;
|
|
588
|
+
readonly name: string;
|
|
589
|
+
registered?(RED: RED): void | Promise<void>;
|
|
590
|
+
register(RED: RED): void | Promise<void>;
|
|
591
|
+
validateSettings(RED: RED): void;
|
|
592
|
+
new (RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>): T;
|
|
593
|
+
}
|
|
594
|
+
type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
|
|
595
|
+
type NodeCredentials<TCredentials = any> = TCredentials;
|
|
596
|
+
/** Public instance interface for all NRG nodes. Implemented by {@link Node}. */
|
|
597
|
+
export interface INode<TConfig = any, TCredentials = any, TSettings = any> {
|
|
598
|
+
readonly config: NodeConfig<TConfig>;
|
|
599
|
+
readonly id: string;
|
|
600
|
+
readonly name: string | undefined;
|
|
601
|
+
readonly z: string | undefined;
|
|
602
|
+
readonly credentials: NodeCredentials<TCredentials> | undefined;
|
|
603
|
+
readonly settings: TSettings;
|
|
604
|
+
i18n(key: string, substitutions?: Record<string, string>): string;
|
|
605
|
+
setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
|
|
606
|
+
setInterval(fn: () => void, ms: number): NodeJS.Timeout;
|
|
607
|
+
clearTimeout(timer: NodeJS.Timeout): void;
|
|
608
|
+
clearInterval(interval: NodeJS.Timeout): void;
|
|
609
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
610
|
+
log(msg: any): void;
|
|
611
|
+
warn(message: string): void;
|
|
612
|
+
error(message: string, msg?: any): void;
|
|
613
|
+
created?(): void | Promise<void>;
|
|
614
|
+
closed?(removed?: boolean): void | Promise<void>;
|
|
615
|
+
}
|
|
616
|
+
declare const WIRE_HANDLERS: unique symbol;
|
|
617
|
+
/**
|
|
618
|
+
* Abstract base class for all NRG nodes. Provides lifecycle hooks, config
|
|
619
|
+
* validation, logging, timers, i18n, and settings management.
|
|
620
|
+
*
|
|
621
|
+
* Extend {@link IONode} for message-processing nodes or {@link ConfigNode}
|
|
622
|
+
* for shared configuration nodes.
|
|
623
|
+
*/
|
|
624
|
+
declare abstract class Node$1<TConfig = any, TCredentials = any, TSettings = any> implements INode<TConfig, TCredentials, TSettings> {
|
|
625
|
+
#private;
|
|
626
|
+
static readonly type: string;
|
|
627
|
+
static readonly category: "config" | string;
|
|
628
|
+
static readonly configSchema?: Schema;
|
|
629
|
+
static readonly credentialsSchema?: Schema;
|
|
630
|
+
static readonly settingsSchema?: Schema;
|
|
631
|
+
static registered?(RED: RED): void | Promise<void>;
|
|
632
|
+
static validateSettings(RED: RED): void;
|
|
633
|
+
/**
|
|
634
|
+
* Registers this node class with Node-RED. Handles instance creation,
|
|
635
|
+
* event handler wiring, settings validation, and the user's registered() hook.
|
|
636
|
+
*/
|
|
637
|
+
static register(RED: RED): Promise<void>;
|
|
638
|
+
protected readonly RED: RED;
|
|
639
|
+
protected readonly node: NodeRedNode;
|
|
640
|
+
protected readonly context: ConfigNodeContext | IONodeContext;
|
|
641
|
+
readonly config: NodeConfig<TConfig>;
|
|
642
|
+
private readonly timers;
|
|
643
|
+
private readonly intervals;
|
|
644
|
+
constructor(RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>);
|
|
645
|
+
[WIRE_HANDLERS](nodeRedNode: NodeRedNode, createdPromise: Promise<void>): void;
|
|
646
|
+
i18n(key: string, substitutions?: Record<string, string>): string;
|
|
647
|
+
setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
|
|
648
|
+
setInterval(fn: () => void, ms: number): NodeJS.Timeout;
|
|
649
|
+
clearTimeout(timer: NodeJS.Timeout): void;
|
|
650
|
+
clearInterval(interval: NodeJS.Timeout): void;
|
|
651
|
+
created?(): void | Promise<void>;
|
|
652
|
+
closed?(removed?: boolean): void | Promise<void>;
|
|
653
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
654
|
+
log(msg: any): void;
|
|
655
|
+
warn(message: string): void;
|
|
656
|
+
error(message: string, msg?: any): void;
|
|
657
|
+
get id(): string;
|
|
658
|
+
get name(): string | undefined;
|
|
659
|
+
get z(): string | undefined;
|
|
660
|
+
get credentials(): NodeCredentials<TCredentials> | undefined;
|
|
661
|
+
get settings(): TSettings;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Controls how an outgoing message carries the incoming message's context:
|
|
665
|
+
* - `"carry"` (default): keep all incoming keys — including any upstream
|
|
666
|
+
* `input` — but do not record this node, so context flows through without the
|
|
667
|
+
* provenance chain growing. The safe default for loops and long chains.
|
|
668
|
+
* - `"trace"`: keep all incoming keys and also push the full input under
|
|
669
|
+
* `input`, so the prior message — including any value the result overwrites —
|
|
670
|
+
* stays recoverable (`msg.input.output`). The chain accumulates one frame per
|
|
671
|
+
* node, a provenance trail visible in the debug panel; opt in for linear
|
|
672
|
+
* flows that want full lineage.
|
|
673
|
+
* - `"reset"`: drop all inherited context; the outgoing message is only the
|
|
674
|
+
* result at the return key.
|
|
675
|
+
*/
|
|
676
|
+
export type ContextMode = "carry" | "trace" | "reset";
|
|
677
|
+
/**
|
|
678
|
+
* Base class for nodes that process messages. Provides input/output handling,
|
|
679
|
+
* schema validation, status updates, and emit port management.
|
|
680
|
+
*
|
|
681
|
+
* Every node has a return key (`"output"` by default): the value passed to
|
|
682
|
+
* `send()` is merged into the incoming message at that key
|
|
683
|
+
* (`{ ...msg, [returnKey]: result }`), so upstream properties propagate. By
|
|
684
|
+
* default the context is carried without growing; declaring
|
|
685
|
+
* `outputContextModes` in the `configSchema` lets the flow author pick `trace`
|
|
686
|
+
* (keep the full prior message under `input` as a recoverable provenance chain)
|
|
687
|
+
* or `reset` per port. The return key, output validation, and context mode all
|
|
688
|
+
* resolve per output port; declaring `outputReturnProperties` in the
|
|
689
|
+
* `configSchema` sets per-port default keys and lets the flow author pick a key
|
|
690
|
+
* other than `output` per port — it does not change that a return key always
|
|
691
|
+
* exists. `this.send(x)` always means "x is the result", never "x is the whole
|
|
692
|
+
* message".
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* ```ts
|
|
696
|
+
* export default class MyNode extends IONode<Config, any, Input, Output> {
|
|
697
|
+
* static readonly type = "my-node";
|
|
698
|
+
* static readonly category = "function";
|
|
699
|
+
* static readonly color = "#ffffff" as const;
|
|
700
|
+
*
|
|
701
|
+
* async input(msg: Input) {
|
|
702
|
+
* // sends { ...msg, output: <result> }
|
|
703
|
+
* this.send(msg.output.toUpperCase());
|
|
704
|
+
* }
|
|
705
|
+
* }
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
export declare abstract class IONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> implements IIONode<TConfig, TCredentials, TInput, TOutput, TSettings> {
|
|
709
|
+
#private;
|
|
710
|
+
static readonly align?: "left" | "right";
|
|
711
|
+
static readonly color: HexColor;
|
|
712
|
+
static readonly inputSchema?: Schema;
|
|
713
|
+
static readonly outputsSchema?: TSchema | TSchema[] | Record<string, TSchema>;
|
|
714
|
+
static readonly validateInput: boolean;
|
|
715
|
+
static readonly validateOutput: boolean;
|
|
716
|
+
static get inputs(): 0 | 1;
|
|
717
|
+
static get outputs(): number;
|
|
718
|
+
/**
|
|
719
|
+
* The names of the base output ports when `outputsSchema` is a record of
|
|
720
|
+
* named ports (`{ success, failure }`), in declaration order — otherwise
|
|
721
|
+
* `undefined` (a single schema or a positional array). Resolved here, where
|
|
722
|
+
* TypeBox's `Kind` symbol is intact, so the editor reads the names directly
|
|
723
|
+
* instead of guessing them from a serialized (symbol-stripped) schema.
|
|
724
|
+
*/
|
|
725
|
+
static get outputPortNames(): string[] | undefined;
|
|
726
|
+
readonly config: IONodeConfig<TConfig>;
|
|
727
|
+
protected readonly context: IONodeContext;
|
|
728
|
+
constructor(RED: RED, node: NodeRedNode, config: IONodeConfig<TConfig>, credentials: IONodeCredentials<TCredentials>);
|
|
729
|
+
[WIRE_HANDLERS](nodeRedNode: NodeRedNode, createdPromise: Promise<void>): void;
|
|
730
|
+
input(msg: TInput): void | Promise<void>;
|
|
731
|
+
send(msg: TOutput): void;
|
|
732
|
+
get baseOutputs(): number;
|
|
733
|
+
get totalOutputs(): number;
|
|
734
|
+
/**
|
|
735
|
+
* Send a message to a specific output port by index or name.
|
|
736
|
+
* Custom named ports are resolved from `outputsSchema` when it is a record.
|
|
737
|
+
* Numeric indices refer to the base output ports (0-based).
|
|
738
|
+
*
|
|
739
|
+
* Built-in ports (`"error"`, `"complete"`, `"status"`) are managed by the
|
|
740
|
+
* framework and cannot be sent to directly. Use `this.status()` for status,
|
|
741
|
+
* throw an error or call `this.error()` for the error port, and the complete
|
|
742
|
+
* port is sent automatically on successful input processing.
|
|
743
|
+
*/
|
|
744
|
+
sendToPort<P extends (TOutput extends Record<string, Record<string, any>> ? keyof TOutput & string : never) | number>(port: P, msg: P extends keyof TOutput ? TOutput[P] : unknown): void;
|
|
745
|
+
status(status: IONodeStatus): void;
|
|
746
|
+
error(message: string, msg?: any): void;
|
|
747
|
+
updateWires(wires: string[][]): void;
|
|
748
|
+
receive(msg: TInput): void;
|
|
749
|
+
get x(): number;
|
|
750
|
+
get y(): number;
|
|
751
|
+
get g(): string | undefined;
|
|
752
|
+
get wires(): string[][];
|
|
753
|
+
get credentials(): IONodeCredentials<TCredentials> | undefined;
|
|
754
|
+
}
|
|
755
|
+
type IONodeContextScope = NodeContextScope;
|
|
756
|
+
type BuiltinPortFlags = {
|
|
757
|
+
[K in (typeof BUILTIN_PORT_KEYS)[number]]?: boolean;
|
|
758
|
+
};
|
|
759
|
+
type IONodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof IONodeConfigSchema> & BuiltinPortFlags & {
|
|
760
|
+
validateInput?: boolean;
|
|
761
|
+
/** Per-port output-validation flags, keyed by base-output port index. */
|
|
762
|
+
validateOutputs?: Record<number, boolean>;
|
|
763
|
+
/** Per-port return properties, keyed by base-output port index. */
|
|
764
|
+
outputReturnProperties?: Record<number, string>;
|
|
765
|
+
/** Per-port context modes, keyed by base-output port index. */
|
|
766
|
+
outputContextModes?: Record<number, "carry" | "trace" | "reset">;
|
|
767
|
+
};
|
|
768
|
+
type IONodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
|
|
769
|
+
type IONodeStatus = {
|
|
770
|
+
fill?: "red" | "green" | "yellow" | "blue" | "grey" | "gray";
|
|
771
|
+
shape?: "ring" | "dot";
|
|
772
|
+
text?: string;
|
|
773
|
+
} | string;
|
|
774
|
+
type IONodeContext = {
|
|
775
|
+
(scope: IONodeContextScope, store?: string): NodeContextStore;
|
|
776
|
+
node: NodeContextStore;
|
|
777
|
+
flow: NodeContextStore;
|
|
778
|
+
global: NodeContextStore;
|
|
779
|
+
};
|
|
780
|
+
type HexColor = `#${string}`;
|
|
781
|
+
type BoundIONode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined, TIn extends TSchema | undefined, TOut extends TSchema | readonly TSchema[] | Record<string, TSchema> | undefined> = IONode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TIn, any>, InferOutputs<TOut>, InferOr<TS, any>>;
|
|
782
|
+
/** Public instance interface for IO nodes. Implemented by {@link IONode}. */
|
|
783
|
+
export interface IIONode<TConfig = any, TCredentials = any, TInput = any, TOutput = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings> {
|
|
784
|
+
readonly config: IONodeConfig<TConfig>;
|
|
785
|
+
readonly credentials: IONodeCredentials<TCredentials> | undefined;
|
|
786
|
+
readonly x: number;
|
|
787
|
+
readonly y: number;
|
|
788
|
+
readonly g: string | undefined;
|
|
789
|
+
readonly wires: string[][];
|
|
790
|
+
input(msg: TInput): void | Promise<void>;
|
|
791
|
+
send(msg: TOutput): void;
|
|
792
|
+
status(status: IONodeStatus): void;
|
|
793
|
+
updateWires(wires: string[][]): void;
|
|
794
|
+
receive(msg: TInput): void;
|
|
795
|
+
readonly baseOutputs: number;
|
|
796
|
+
readonly totalOutputs: number;
|
|
797
|
+
sendToPort<P extends (TOutput extends Record<string, Record<string, any>> ? keyof TOutput & string : never) | number>(port: P, msg: P extends keyof TOutput ? TOutput[P] : unknown): void;
|
|
798
|
+
}
|
|
799
|
+
interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | Record<string, TSchema> | undefined = undefined> {
|
|
800
|
+
type: string;
|
|
801
|
+
category?: string;
|
|
802
|
+
color?: HexColor;
|
|
803
|
+
align?: "left" | "right";
|
|
804
|
+
configSchema?: TConfigSchema;
|
|
805
|
+
credentialsSchema?: TCredsSchema;
|
|
806
|
+
settingsSchema?: TSettingsSchema;
|
|
807
|
+
inputSchema?: TInputSchema;
|
|
808
|
+
outputsSchema?: TOutputsSchema;
|
|
809
|
+
validateInput?: boolean;
|
|
810
|
+
validateOutput?: boolean;
|
|
811
|
+
registered?(RED: RED): void | Promise<void>;
|
|
812
|
+
created?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): void | Promise<void>;
|
|
813
|
+
closed?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, removed?: boolean): void | Promise<void>;
|
|
814
|
+
input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>): void | Promise<void>;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Base class for configuration nodes that are shared across multiple nodes
|
|
818
|
+
* (e.g., server connections, credentials). Registered with `category: "config"`.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```ts
|
|
822
|
+
* export default class MyServer extends ConfigNode<Config> {
|
|
823
|
+
* static readonly type = "my-server";
|
|
824
|
+
* }
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
export declare abstract class ConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> implements IConfigNode<TConfig, TCredentials, TSettings> {
|
|
828
|
+
static readonly category: string;
|
|
829
|
+
readonly config: ConfigNodeConfig<TConfig>;
|
|
830
|
+
protected readonly context: ConfigNodeContext;
|
|
831
|
+
constructor(RED: RED, node: NodeRedNode, config: ConfigNodeConfig<TConfig>, credentials: ConfigNodeCredentials<TCredentials>);
|
|
832
|
+
get userIds(): string[];
|
|
833
|
+
get users(): INode[];
|
|
834
|
+
getUser<T extends INode = INode>(index: number): T | undefined;
|
|
835
|
+
get credentials(): ConfigNodeCredentials<TCredentials> | undefined;
|
|
836
|
+
}
|
|
837
|
+
type ConfigNodeContextScope = Exclude<NodeContextScope, "flow">;
|
|
838
|
+
type ConfigNodeConfig<TConfig = any> = NodeConfig<TConfig> & Static<typeof ConfigNodeConfigSchema>;
|
|
839
|
+
type ConfigNodeCredentials<TCredentials = any> = NodeCredentials<TCredentials>;
|
|
840
|
+
type ConfigNodeContext = {
|
|
841
|
+
(scope: ConfigNodeContextScope, store?: string): NodeContextStore;
|
|
842
|
+
node: NodeContextStore;
|
|
843
|
+
global: NodeContextStore;
|
|
844
|
+
};
|
|
845
|
+
type BoundConfigNode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined> = ConfigNode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TS, any>>;
|
|
846
|
+
/** Public instance interface for config nodes. Implemented by {@link ConfigNode}. */
|
|
847
|
+
export interface IConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings> {
|
|
848
|
+
readonly config: ConfigNodeConfig<TConfig>;
|
|
849
|
+
readonly credentials: ConfigNodeCredentials<TCredentials> | undefined;
|
|
850
|
+
readonly userIds: string[];
|
|
851
|
+
readonly users: INode[];
|
|
852
|
+
getUser<T extends INode = INode>(index: number): T | undefined;
|
|
853
|
+
}
|
|
854
|
+
interface ConfigNodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined> {
|
|
855
|
+
type: string;
|
|
856
|
+
configSchema?: TConfigSchema;
|
|
857
|
+
credentialsSchema?: TCredsSchema;
|
|
858
|
+
settingsSchema?: TSettingsSchema;
|
|
859
|
+
registered?(RED: RED): void | Promise<void>;
|
|
860
|
+
created?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>): void | Promise<void>;
|
|
861
|
+
closed?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>, removed?: boolean): void | Promise<void>;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Registers a custom node with Node-RED.
|
|
865
|
+
*
|
|
866
|
+
* @param RED - The Node-RED runtime API object
|
|
867
|
+
* @param NodeClass - A node class extending Node, IONode, or ConfigNode
|
|
868
|
+
* @throws If NodeClass does not extend Node
|
|
869
|
+
* @throws If NodeClass.type is not defined
|
|
870
|
+
*/
|
|
871
|
+
export declare function registerType(RED: RED, NodeClass: NodeConstructor): Promise<void>;
|
|
872
|
+
type RegistrationFunction = ((RED: RED) => Promise<void>) & {
|
|
873
|
+
nodes: NodeConstructor[];
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* Registers multiple node classes with Node-RED.
|
|
877
|
+
*
|
|
878
|
+
* Returns a Node-RED package function that Node-RED calls with the RED
|
|
879
|
+
* runtime object when loading the package.
|
|
880
|
+
*
|
|
881
|
+
* @param nodes - Array of node classes to register
|
|
882
|
+
*/
|
|
883
|
+
export declare function registerTypes(nodes: NodeConstructor[]): RegistrationFunction;
|
|
884
|
+
/**
|
|
885
|
+
* Creates an IO node class from a definition object. Provides automatic type
|
|
886
|
+
* inference from schemas, reducing boilerplate compared to the class-based API.
|
|
887
|
+
*
|
|
888
|
+
* @example
|
|
889
|
+
* ```ts
|
|
890
|
+
* export default defineIONode({
|
|
891
|
+
* type: "my-node",
|
|
892
|
+
* color: "#ffffff",
|
|
893
|
+
* configSchema: ConfigsSchema,
|
|
894
|
+
* inputSchema: InputSchema,
|
|
895
|
+
* outputsSchema: OutputSchema,
|
|
896
|
+
* async input(msg) {
|
|
897
|
+
* this.send({ payload: msg.payload.toUpperCase() });
|
|
898
|
+
* },
|
|
899
|
+
* });
|
|
900
|
+
* ```
|
|
901
|
+
*/
|
|
902
|
+
export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | Record<string, TSchema> | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeConstructor<IIONode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
|
|
903
|
+
/**
|
|
904
|
+
* Creates a config node class from a definition object.
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* ```ts
|
|
908
|
+
* export default defineConfigNode({
|
|
909
|
+
* type: "my-server",
|
|
910
|
+
* configSchema: ConfigsSchema,
|
|
911
|
+
* credentialsSchema: CredsSchema,
|
|
912
|
+
* });
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
export declare function defineConfigNode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined>(def: ConfigNodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema>): NodeConstructor<IConfigNode<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>>>;
|
|
916
|
+
/** Error class for NRG framework errors (validation failures, registration errors, etc.). */
|
|
917
|
+
export declare class NrgError extends Error {
|
|
918
|
+
constructor(message: string);
|
|
919
|
+
}
|
|
920
|
+
/** Defines the set of nodes exported by a Node-RED package. */
|
|
921
|
+
export interface ModuleDefinition {
|
|
922
|
+
nodes: NodeConstructor[];
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Declares the nodes that make up a Node-RED module. The returned object
|
|
926
|
+
* is used as the default export of `src/server/index.ts`.
|
|
927
|
+
*
|
|
928
|
+
* @example
|
|
929
|
+
* ```ts
|
|
930
|
+
* export default defineModule({
|
|
931
|
+
* nodes: [MyNode, MyConfigNode],
|
|
932
|
+
* });
|
|
933
|
+
* ```
|
|
934
|
+
*/
|
|
935
|
+
export declare function defineModule(definition: ModuleDefinition): ModuleDefinition;
|
|
936
|
+
|
|
937
|
+
export {
|
|
938
|
+
Node$1 as Node,
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
export {};
|