@bonsae/nrg-runtime 0.22.0
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 +24 -0
- package/internal/README.md +30 -0
- package/internal/client/components.mjs +1287 -0
- package/internal/client/index.mjs +229 -0
- package/internal/server/index.cjs +298 -0
- package/package.json +67 -0
- package/server/index.cjs +1407 -0
- package/server/resources/nrg-client.js +7493 -0
- package/types/client.d.ts +266 -0
- package/types/internal/client/components.d.ts +9 -0
- package/types/internal/client/index.d.ts +9 -0
- package/types/internal/server/index.d.ts +422 -0
- package/types/server.d.ts +941 -0
- package/types/shims/brands.d.ts +32 -0
- package/types/shims/client/form/components/node-red-config-input.vue.d.ts +125 -0
- package/types/shims/client/form/components/node-red-editor-input.vue.d.ts +124 -0
- package/types/shims/client/form/components/node-red-input-label.vue.d.ts +34 -0
- package/types/shims/client/form/components/node-red-input.vue.d.ts +123 -0
- package/types/shims/client/form/components/node-red-json-schema-form.vue.d.ts +772 -0
- package/types/shims/client/form/components/node-red-select-input.vue.d.ts +132 -0
- package/types/shims/client/form/components/node-red-toggle.vue.d.ts +36 -0
- package/types/shims/client/form/components/node-red-typed-input.vue.d.ts +151 -0
- package/types/shims/client/globals.d.ts +320 -0
- package/types/shims/client/types.d.ts +227 -0
- package/types/shims/components.d.ts +23 -0
- package/types/shims/constants.d.ts +4 -0
- package/types/shims/schema-options.d.ts +24 -0
- package/types/shims/shims-vue.d.ts +5 -0
- package/types/shims/typebox.d.ts +10 -0
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DefineComponent } from "vue";
|
|
2
|
+
export declare const NodeRedInput: DefineComponent<{}, {}, any>;
|
|
3
|
+
export declare const NodeRedTypedInput: DefineComponent<{}, {}, any>;
|
|
4
|
+
export declare const NodeRedConfigInput: DefineComponent<{}, {}, any>;
|
|
5
|
+
export declare const NodeRedSelectInput: DefineComponent<{}, {}, any>;
|
|
6
|
+
export declare const NodeRedEditorInput: DefineComponent<{}, {}, any>;
|
|
7
|
+
export declare const NodeRedInputLabel: DefineComponent<{}, {}, any>;
|
|
8
|
+
export declare const NodeRedToggle: DefineComponent<{}, {}, any>;
|
|
9
|
+
export declare const NodeRedJsonSchemaForm: DefineComponent<{}, {}, any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSchema } from "@sinclair/typebox";
|
|
2
|
+
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): {
|
|
3
|
+
node: Record<string, any>;
|
|
4
|
+
schema: Record<string, any>;
|
|
5
|
+
errors: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function validateForm(schema: unknown, value: unknown): Record<string, string>;
|
|
8
|
+
export declare function composeValidationSchema(...schemas: unknown[]): unknown;
|
|
9
|
+
export type JsonSchemaObject = Record<string, any>;
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { SchemaOptions, Static, TObject, TOptional, TProperties, TSchema, TString } from '@sinclair/typebox';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { Express as Express$1 } from 'express';
|
|
6
|
+
import { Http2ServerRequest } from 'http2';
|
|
7
|
+
|
|
8
|
+
/** Symbol for the internal wireHandlers template method. Not exported from public API.
|
|
9
|
+
* Uses Symbol.for() so the symbol is shared across separate bundles (server + test). */
|
|
10
|
+
export declare const WIRE_HANDLERS: unique symbol;
|
|
11
|
+
interface NodeRedRuntimeSettings {
|
|
12
|
+
userDir?: string;
|
|
13
|
+
nodesDir?: string | string[];
|
|
14
|
+
flowFile?: string;
|
|
15
|
+
flowFilePretty?: boolean;
|
|
16
|
+
credentialSecret?: string | false;
|
|
17
|
+
requireHttps?: boolean;
|
|
18
|
+
https?: {
|
|
19
|
+
key: string;
|
|
20
|
+
cert: string;
|
|
21
|
+
} | (() => Promise<{
|
|
22
|
+
key: string;
|
|
23
|
+
cert: string;
|
|
24
|
+
}> | {
|
|
25
|
+
key: string;
|
|
26
|
+
cert: string;
|
|
27
|
+
});
|
|
28
|
+
httpsRefreshInterval?: number;
|
|
29
|
+
httpAdminRoot?: string;
|
|
30
|
+
httpNodeRoot?: string;
|
|
31
|
+
httpNodeCors?: {
|
|
32
|
+
origin: string;
|
|
33
|
+
methods: string;
|
|
34
|
+
};
|
|
35
|
+
httpStatic?: string | {
|
|
36
|
+
path: string;
|
|
37
|
+
root: string;
|
|
38
|
+
}[];
|
|
39
|
+
httpStaticRoot?: string;
|
|
40
|
+
httpAdminMiddleware?: (req: unknown, res: unknown, next: () => void) => void;
|
|
41
|
+
httpNodeMiddleware?: (req: unknown, res: unknown, next: () => void) => void;
|
|
42
|
+
httpServerOptions?: Record<string, unknown>;
|
|
43
|
+
adminAuth?: {
|
|
44
|
+
type?: "credentials" | "strategy";
|
|
45
|
+
users?: {
|
|
46
|
+
username: string;
|
|
47
|
+
password: string;
|
|
48
|
+
permissions?: string | string[];
|
|
49
|
+
}[];
|
|
50
|
+
default?: {
|
|
51
|
+
permissions?: string | string[];
|
|
52
|
+
};
|
|
53
|
+
tokens?: (token: string) => Promise<{
|
|
54
|
+
user: string;
|
|
55
|
+
permissions: string | string[];
|
|
56
|
+
} | null>;
|
|
57
|
+
tokenHeader: "string";
|
|
58
|
+
sessionExpiryTime?: number;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
httpNodeAuth?: {
|
|
62
|
+
user?: string;
|
|
63
|
+
pass?: string;
|
|
64
|
+
};
|
|
65
|
+
httpStaticAuth?: {
|
|
66
|
+
user?: string;
|
|
67
|
+
pass?: string;
|
|
68
|
+
};
|
|
69
|
+
lang?: "en-US" | "de" | "es-ES" | "fr" | "ko" | "pt-BR" | "ru" | "ja" | "zh-CN" | "zh-TW";
|
|
70
|
+
diagnostics?: {
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
ui?: boolean;
|
|
73
|
+
};
|
|
74
|
+
runtimeState?: {
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
ui?: boolean;
|
|
77
|
+
};
|
|
78
|
+
disableEditor?: boolean;
|
|
79
|
+
editorTheme?: {
|
|
80
|
+
page?: {
|
|
81
|
+
title?: string;
|
|
82
|
+
favicon?: string;
|
|
83
|
+
css?: string | string[];
|
|
84
|
+
scripts?: string | string[];
|
|
85
|
+
};
|
|
86
|
+
header?: {
|
|
87
|
+
title?: string;
|
|
88
|
+
image?: string;
|
|
89
|
+
url?: string;
|
|
90
|
+
};
|
|
91
|
+
deployButton?: {
|
|
92
|
+
type?: "simple" | "default";
|
|
93
|
+
label?: string;
|
|
94
|
+
icon?: string;
|
|
95
|
+
};
|
|
96
|
+
menu?: {
|
|
97
|
+
"menu-item-import-library"?: boolean;
|
|
98
|
+
"menu-item-export-library"?: boolean;
|
|
99
|
+
"menu-item-keyboard-shortcuts"?: boolean;
|
|
100
|
+
"menu-item-help"?: {
|
|
101
|
+
label?: string;
|
|
102
|
+
url?: string;
|
|
103
|
+
};
|
|
104
|
+
[menuItem: string]: boolean | {
|
|
105
|
+
label?: string;
|
|
106
|
+
url?: string;
|
|
107
|
+
} | undefined;
|
|
108
|
+
};
|
|
109
|
+
userMenu?: boolean;
|
|
110
|
+
login?: {
|
|
111
|
+
image?: string;
|
|
112
|
+
};
|
|
113
|
+
logout?: {
|
|
114
|
+
redirect?: string;
|
|
115
|
+
};
|
|
116
|
+
palette?: {
|
|
117
|
+
catalogues?: string[];
|
|
118
|
+
categories?: string[];
|
|
119
|
+
theme?: {
|
|
120
|
+
category: string;
|
|
121
|
+
type: string;
|
|
122
|
+
color: string;
|
|
123
|
+
}[];
|
|
124
|
+
};
|
|
125
|
+
projects?: {
|
|
126
|
+
enabled?: boolean;
|
|
127
|
+
workflow?: {
|
|
128
|
+
mode: "manual" | "auto";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
codeEditor?: {
|
|
132
|
+
lib?: "monaco" | "ace";
|
|
133
|
+
options?: Record<string, unknown>;
|
|
134
|
+
};
|
|
135
|
+
mermaid?: {
|
|
136
|
+
theme?: string;
|
|
137
|
+
};
|
|
138
|
+
tours?: boolean;
|
|
139
|
+
theme?: string;
|
|
140
|
+
[key: string]: unknown;
|
|
141
|
+
};
|
|
142
|
+
contextStorage?: {
|
|
143
|
+
default?: {
|
|
144
|
+
module?: "memory" | "localfilesystem" | object;
|
|
145
|
+
config?: Record<string, unknown>;
|
|
146
|
+
};
|
|
147
|
+
[store: string]: {
|
|
148
|
+
module?: "memory" | "localfilesystem" | object;
|
|
149
|
+
config?: Record<string, unknown>;
|
|
150
|
+
} | undefined;
|
|
151
|
+
};
|
|
152
|
+
exportGlobalContextKeys?: boolean;
|
|
153
|
+
logging?: {
|
|
154
|
+
console?: {
|
|
155
|
+
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "off";
|
|
156
|
+
metrics?: boolean;
|
|
157
|
+
audit?: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
fileWorkingDirectory?: string;
|
|
161
|
+
functionExternalModules?: boolean;
|
|
162
|
+
functionGlobalContext?: Record<string, unknown>;
|
|
163
|
+
nodeMessageBufferMaxLength?: number;
|
|
164
|
+
functionTimeout?: number;
|
|
165
|
+
externalModules?: {
|
|
166
|
+
autoInstall?: boolean;
|
|
167
|
+
autoInstallRetry?: number;
|
|
168
|
+
palette?: {
|
|
169
|
+
allowInstall?: boolean;
|
|
170
|
+
allowUpdate?: boolean;
|
|
171
|
+
allowUpload?: boolean;
|
|
172
|
+
allowList?: string[];
|
|
173
|
+
denyList?: string[];
|
|
174
|
+
allowUpdateList?: string[];
|
|
175
|
+
denyUpdateList?: string[];
|
|
176
|
+
};
|
|
177
|
+
modules?: {
|
|
178
|
+
allowInstall?: boolean;
|
|
179
|
+
allowList?: string[];
|
|
180
|
+
denyList?: string[];
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
execMaxBufferSize?: number;
|
|
184
|
+
debugMaxLength?: number;
|
|
185
|
+
debugUseColors?: boolean;
|
|
186
|
+
httpRequestTimeout?: number;
|
|
187
|
+
mqttReconnectTime?: number;
|
|
188
|
+
serialReconnectTime?: number;
|
|
189
|
+
socketReconnectTime?: number;
|
|
190
|
+
socketTimeout?: number;
|
|
191
|
+
tcpMsgQueueSize?: number;
|
|
192
|
+
inboundWebSocketTimeout?: number;
|
|
193
|
+
tlsConfigDisableLocalFiles?: boolean;
|
|
194
|
+
webSocketNodeVerifyClient?: (info: {
|
|
195
|
+
origin: string;
|
|
196
|
+
req: Http2ServerRequest;
|
|
197
|
+
secure: boolean;
|
|
198
|
+
}) => boolean;
|
|
199
|
+
apiMaxLength?: string;
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
}
|
|
202
|
+
declare const NodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
203
|
+
id: import("@sinclair/typebox").TString;
|
|
204
|
+
type: import("@sinclair/typebox").TString;
|
|
205
|
+
name: import("@sinclair/typebox").TString;
|
|
206
|
+
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
207
|
+
}>;
|
|
208
|
+
type Schema<T extends TProperties = TProperties> = TObject<T>;
|
|
209
|
+
export interface NodeContextStore {
|
|
210
|
+
get<T = any>(key: string): Promise<T>;
|
|
211
|
+
set<T = any>(key: string, value: T): Promise<void>;
|
|
212
|
+
keys(): Promise<string[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Atomically add `by` (default 1) to a numeric key and return the new value.
|
|
215
|
+
* Prefer this over `get`+`set` for counters: it's atomic across instances when
|
|
216
|
+
* the context store supports it (e.g. a DynamoDB `ADD` or Redis `INCR` store),
|
|
217
|
+
* and serialized within the process otherwise — so concurrent messages never
|
|
218
|
+
* lose updates.
|
|
219
|
+
*/
|
|
220
|
+
increment(key: string, by?: number): Promise<number>;
|
|
221
|
+
/**
|
|
222
|
+
* Atomic read-modify-write: `fn(current)` returns the next value, applied
|
|
223
|
+
* atomically (a conditional write + retry on a capable store, a per-key lock
|
|
224
|
+
* otherwise). `fn` MAY run more than once on a write conflict, so keep it pure
|
|
225
|
+
* (no side effects).
|
|
226
|
+
*/
|
|
227
|
+
update<T = any>(key: string, fn: (current: T) => T | Promise<T>): Promise<T>;
|
|
228
|
+
}
|
|
229
|
+
export interface NodeConstructor<T = any, TConfig = any, TCredentials = any> {
|
|
230
|
+
readonly type: string;
|
|
231
|
+
readonly category: string;
|
|
232
|
+
readonly color?: string;
|
|
233
|
+
readonly align?: "left" | "right";
|
|
234
|
+
readonly inputs?: number;
|
|
235
|
+
readonly outputs?: number;
|
|
236
|
+
readonly configSchema?: Schema;
|
|
237
|
+
readonly credentialsSchema?: Schema;
|
|
238
|
+
readonly settingsSchema?: Schema;
|
|
239
|
+
readonly inputSchema?: Schema;
|
|
240
|
+
readonly outputsSchema?: TSchema | TSchema[] | Record<string, TSchema>;
|
|
241
|
+
readonly validateInput?: boolean;
|
|
242
|
+
readonly validateOutput?: boolean;
|
|
243
|
+
readonly name: string;
|
|
244
|
+
registered?(RED: RED): void | Promise<void>;
|
|
245
|
+
register(RED: RED): void | Promise<void>;
|
|
246
|
+
validateSettings(RED: RED): void;
|
|
247
|
+
new (RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>): T;
|
|
248
|
+
}
|
|
249
|
+
type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
|
|
250
|
+
type NodeCredentials<TCredentials = any> = TCredentials;
|
|
251
|
+
/** Public instance interface for all NRG nodes. Implemented by {@link Node}. */
|
|
252
|
+
export interface INode<TConfig = any, TCredentials = any, TSettings = any> {
|
|
253
|
+
readonly config: NodeConfig<TConfig>;
|
|
254
|
+
readonly id: string;
|
|
255
|
+
readonly name: string | undefined;
|
|
256
|
+
readonly z: string | undefined;
|
|
257
|
+
readonly credentials: NodeCredentials<TCredentials> | undefined;
|
|
258
|
+
readonly settings: TSettings;
|
|
259
|
+
i18n(key: string, substitutions?: Record<string, string>): string;
|
|
260
|
+
setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
|
|
261
|
+
setInterval(fn: () => void, ms: number): NodeJS.Timeout;
|
|
262
|
+
clearTimeout(timer: NodeJS.Timeout): void;
|
|
263
|
+
clearInterval(interval: NodeJS.Timeout): void;
|
|
264
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
265
|
+
log(msg: any): void;
|
|
266
|
+
warn(message: string): void;
|
|
267
|
+
error(message: string, msg?: any): void;
|
|
268
|
+
created?(): void | Promise<void>;
|
|
269
|
+
closed?(removed?: boolean): void | Promise<void>;
|
|
270
|
+
}
|
|
271
|
+
interface NodeRedLog {
|
|
272
|
+
info(msg: any): void;
|
|
273
|
+
warn(msg: any): void;
|
|
274
|
+
error(msg: any, error?: any): void;
|
|
275
|
+
debug(msg: any): void;
|
|
276
|
+
trace(msg: any): void;
|
|
277
|
+
log(msg: {
|
|
278
|
+
level: number;
|
|
279
|
+
msg: string;
|
|
280
|
+
}): void;
|
|
281
|
+
metric(): boolean;
|
|
282
|
+
audit(msg: Record<string, any>, req?: any): void;
|
|
283
|
+
addHandler(handler: (msg: any) => void): void;
|
|
284
|
+
removeHandler(handler: (msg: any) => void): void;
|
|
285
|
+
FATAL: 10;
|
|
286
|
+
ERROR: 20;
|
|
287
|
+
WARN: 30;
|
|
288
|
+
INFO: 40;
|
|
289
|
+
DEBUG: 50;
|
|
290
|
+
TRACE: 60;
|
|
291
|
+
AUDIT: 98;
|
|
292
|
+
METRIC: 99;
|
|
293
|
+
}
|
|
294
|
+
export interface NodeRedNode {
|
|
295
|
+
id: string;
|
|
296
|
+
type: string;
|
|
297
|
+
name?: string;
|
|
298
|
+
z?: string;
|
|
299
|
+
x: number;
|
|
300
|
+
y: number;
|
|
301
|
+
g?: string;
|
|
302
|
+
wires: string[][];
|
|
303
|
+
credentials: any;
|
|
304
|
+
_node?: INode;
|
|
305
|
+
send(msg: any): void;
|
|
306
|
+
receive(msg: any): void;
|
|
307
|
+
status(status: string | {
|
|
308
|
+
fill?: string;
|
|
309
|
+
shape?: string;
|
|
310
|
+
text?: string;
|
|
311
|
+
}): void;
|
|
312
|
+
updateWires(wires: string[][]): void;
|
|
313
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
314
|
+
log(msg: any): void;
|
|
315
|
+
warn(msg: any): void;
|
|
316
|
+
error(msg: any, errorMsg?: any): void;
|
|
317
|
+
context(): NodeRedNodeContext;
|
|
318
|
+
[key: string]: any;
|
|
319
|
+
}
|
|
320
|
+
interface NodeRedNodeContext extends NodeRedContextStore {
|
|
321
|
+
flow: NodeRedContextStore;
|
|
322
|
+
global: NodeRedContextStore;
|
|
323
|
+
}
|
|
324
|
+
interface NodeRedNodes {
|
|
325
|
+
registerType(type: string, constructor: any, opts?: any): void;
|
|
326
|
+
getNode(id: string): (NodeRedNode & {
|
|
327
|
+
_node?: INode;
|
|
328
|
+
}) | undefined;
|
|
329
|
+
createNode(node: NodeRedNode, config: Record<string, any>): void;
|
|
330
|
+
getCredentials(id: string): Record<string, any> | undefined;
|
|
331
|
+
/** Merge credentials into a node's stored credential set (runtime API). */
|
|
332
|
+
addCredentials(id: string, credentials: Record<string, any>): void;
|
|
333
|
+
eachNode(callback: (node: any) => void): void;
|
|
334
|
+
getType(type: string): any;
|
|
335
|
+
getNodeInfo(type: string): any;
|
|
336
|
+
getNodeList(filter?: any): any[];
|
|
337
|
+
getModuleInfo(module: string): any;
|
|
338
|
+
installModule(module: string, version?: string): Promise<any>;
|
|
339
|
+
uninstallModule(module: string): Promise<any>;
|
|
340
|
+
enableNode(id: string): Promise<any>;
|
|
341
|
+
disableNode(id: string): Promise<any>;
|
|
342
|
+
}
|
|
343
|
+
interface NodeRedUtil {
|
|
344
|
+
evaluateNodeProperty(value: any, type: string, node: any, msg: Record<string, any> | undefined, callback: (err: Error | null, result: any) => void): void;
|
|
345
|
+
generateId(): string;
|
|
346
|
+
cloneMessage<T = any>(msg: T): T;
|
|
347
|
+
ensureString(o: any): string;
|
|
348
|
+
ensureBuffer(o: any): Buffer;
|
|
349
|
+
compareObjects(obj1: any, obj2: any): boolean;
|
|
350
|
+
getMessageProperty(msg: any, expr: string): any;
|
|
351
|
+
setMessageProperty(msg: any, prop: string, value: any, createMissing?: boolean): void;
|
|
352
|
+
getObjectProperty(obj: any, expr: string): any;
|
|
353
|
+
setObjectProperty(obj: any, prop: string, value: any, createMissing?: boolean): void;
|
|
354
|
+
normalisePropertyExpression(str: string, msg?: any, toString?: boolean): string[];
|
|
355
|
+
normaliseNodeTypeName(name: string): string;
|
|
356
|
+
prepareJSONataExpression(value: string, node: any): any;
|
|
357
|
+
evaluateJSONataExpression(expr: any, msg: any, callback: (err: Error | null, result: any) => void): void;
|
|
358
|
+
parseContextStore(key: string): {
|
|
359
|
+
store: string | undefined;
|
|
360
|
+
key: string;
|
|
361
|
+
};
|
|
362
|
+
getSetting(node: any, name: string, flow?: any): any;
|
|
363
|
+
encodeObject(obj: any): any;
|
|
364
|
+
}
|
|
365
|
+
interface NodeRedHooks {
|
|
366
|
+
add(hookId: string, callback: (event: any) => void | Promise<void>): void;
|
|
367
|
+
remove(hookId: string): void;
|
|
368
|
+
trigger(hookId: string, event: any, callback?: (err?: Error) => void): void | Promise<void>;
|
|
369
|
+
has(hookId: string): boolean;
|
|
370
|
+
clear(): void;
|
|
371
|
+
}
|
|
372
|
+
type NodeRedExpressApp = Express;
|
|
373
|
+
export interface RED {
|
|
374
|
+
/** Internationalization function */
|
|
375
|
+
_(key: string, substitutions?: Record<string, string>): string;
|
|
376
|
+
/** Logging API */
|
|
377
|
+
log: NodeRedLog;
|
|
378
|
+
/** Node registry and management */
|
|
379
|
+
nodes: NodeRedNodes;
|
|
380
|
+
/** Utility functions */
|
|
381
|
+
util: NodeRedUtil;
|
|
382
|
+
/** Hook system for message lifecycle and module events */
|
|
383
|
+
hooks: NodeRedHooks;
|
|
384
|
+
/** Runtime event emitter */
|
|
385
|
+
events: EventEmitter;
|
|
386
|
+
/** Express app for admin HTTP endpoints */
|
|
387
|
+
httpAdmin: NodeRedExpressApp;
|
|
388
|
+
/** Express app for node HTTP endpoints */
|
|
389
|
+
httpNode: NodeRedExpressApp;
|
|
390
|
+
/** Runtime settings (user-provided settings plus node-registered settings) */
|
|
391
|
+
settings: NodeRedRuntimeSettings & Record<string, any>;
|
|
392
|
+
/** Node-RED version string */
|
|
393
|
+
version(): string;
|
|
394
|
+
}
|
|
395
|
+
export interface NodeRedContextStore {
|
|
396
|
+
get(key: string, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
397
|
+
set(key: string, value: any, store: string | undefined, callback: (err: Error | null) => void): void;
|
|
398
|
+
keys(store: string | undefined, callback: (err: Error | null, keys: string[]) => void): void;
|
|
399
|
+
/**
|
|
400
|
+
* Optional atomic add — provided by context stores that support it (e.g.
|
|
401
|
+
* DynamoDB `ADD` / Redis `INCR`). When absent, nrg serializes in-process.
|
|
402
|
+
*/
|
|
403
|
+
increment?(key: string, by: number, store: string | undefined, callback: (err: Error | null, value: number) => void): void;
|
|
404
|
+
/**
|
|
405
|
+
* Optional atomic read-modify-write — provided by stores that support it
|
|
406
|
+
* (e.g. a DynamoDB conditional write). When absent, nrg serializes in-process.
|
|
407
|
+
*/
|
|
408
|
+
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Wrap Node-RED's callback-style context store as the promise-based
|
|
412
|
+
* {@link NodeContextStore} nrg nodes use (`this.context.node/flow/global`).
|
|
413
|
+
*
|
|
414
|
+
* `increment`/`update` are atomic: they delegate to the underlying store's
|
|
415
|
+
* native op when it provides one (the only way to be atomic across instances —
|
|
416
|
+
* e.g. a DynamoDB conditional write / Redis), and otherwise serialize per key
|
|
417
|
+
* in-process (atomic within this instance, best-effort across HA replicas).
|
|
418
|
+
*/
|
|
419
|
+
export declare function setupContext(context: NodeRedContextStore, store?: string): NodeContextStore;
|
|
420
|
+
export declare function initValidator(RED: RED): void;
|
|
421
|
+
|
|
422
|
+
export {};
|