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