@bonsae/nrg 0.22.0 → 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/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,227 @@
|
|
|
1
|
+
import type { Component, App } from "vue";
|
|
2
|
+
import type { TSchema, Static } from "@sinclair/typebox";
|
|
3
|
+
import type { SchemaObject } from "ajv";
|
|
4
|
+
import type { NodeRefResolved, TypedInputResolved } from "../brands";
|
|
5
|
+
import type { JsonSchemaObjectExtensions } from "../schema-options";
|
|
6
|
+
export interface NodeStateCredentials {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface NodeState {
|
|
10
|
+
credentials: NodeStateCredentials;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface NodeButtonDefinition {
|
|
14
|
+
toggle: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
enabled?: () => boolean;
|
|
17
|
+
visible?: () => boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface NodeRedNodeButtonDefinition {
|
|
20
|
+
toggle: string;
|
|
21
|
+
onclick: () => void;
|
|
22
|
+
enabled?: () => boolean;
|
|
23
|
+
visible?: () => boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface NodeFormDefinition {
|
|
26
|
+
component?: Component;
|
|
27
|
+
}
|
|
28
|
+
export interface NodeRedNode {
|
|
29
|
+
id: string;
|
|
30
|
+
type: string;
|
|
31
|
+
name: string;
|
|
32
|
+
category: string;
|
|
33
|
+
x: string;
|
|
34
|
+
y: string;
|
|
35
|
+
g: string;
|
|
36
|
+
z: string;
|
|
37
|
+
credentials: Record<string, any>;
|
|
38
|
+
_def: {
|
|
39
|
+
defaults: Record<string, {
|
|
40
|
+
value: string;
|
|
41
|
+
type?: string;
|
|
42
|
+
label?: string;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
credentials: Record<string, {
|
|
46
|
+
value: string;
|
|
47
|
+
type?: "password" | "text";
|
|
48
|
+
label?: string;
|
|
49
|
+
required?: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
category: string;
|
|
52
|
+
color?: string;
|
|
53
|
+
icon?: string;
|
|
54
|
+
label?: ((this: NodeRedNode) => string) | string;
|
|
55
|
+
inputs?: number;
|
|
56
|
+
outputs?: number;
|
|
57
|
+
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
58
|
+
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
59
|
+
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
60
|
+
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
61
|
+
align?: "left" | "right";
|
|
62
|
+
button?: NodeRedNodeButtonDefinition;
|
|
63
|
+
};
|
|
64
|
+
_newState?: NodeRedNode;
|
|
65
|
+
_app?: App | null;
|
|
66
|
+
_: (str: string) => string;
|
|
67
|
+
/** dynamic port count (base outputs + enabled built-in ports) */
|
|
68
|
+
outputs?: number;
|
|
69
|
+
/** injected when the node has an inputSchema */
|
|
70
|
+
validateInput?: boolean;
|
|
71
|
+
/** built-in port toggles, present when declared in the configSchema */
|
|
72
|
+
errorPort?: boolean;
|
|
73
|
+
completePort?: boolean;
|
|
74
|
+
statusPort?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Per-port output settings, indexed by base-output port. `validateOutputs` is
|
|
77
|
+
* injected (empty) when the node has an outputsSchema; `outputReturnProperties`
|
|
78
|
+
* and `outputContextModes` are author-declared (SchemaType.*) — present only
|
|
79
|
+
* when the node opts into per-port return keys / context modes. Read at
|
|
80
|
+
* runtime by IONode.
|
|
81
|
+
*/
|
|
82
|
+
validateOutputs?: Record<number, boolean>;
|
|
83
|
+
outputContextModes?: Record<number, "carry" | "trace" | "reset">;
|
|
84
|
+
outputReturnProperties?: Record<number, string>;
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}
|
|
87
|
+
export interface NodeDefinition {
|
|
88
|
+
type: string;
|
|
89
|
+
category?: string;
|
|
90
|
+
color?: string;
|
|
91
|
+
icon?: ((this: NodeRedNode) => string) | string;
|
|
92
|
+
label?: ((this: NodeRedNode) => string) | string;
|
|
93
|
+
inputs?: number;
|
|
94
|
+
outputs?: number;
|
|
95
|
+
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
96
|
+
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
97
|
+
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
98
|
+
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
99
|
+
align?: "left" | "right";
|
|
100
|
+
button?: NodeButtonDefinition;
|
|
101
|
+
onEditResize?: (this: NodeRedNode, size: {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
}) => void;
|
|
105
|
+
onPaletteAdd?: (this: NodeRedNode) => void;
|
|
106
|
+
onPaletteRemove?: (this: NodeRedNode) => void;
|
|
107
|
+
form?: NodeFormDefinition;
|
|
108
|
+
}
|
|
109
|
+
/** Form rendering hints carried by the `x-nrg-form` schema keyword. */
|
|
110
|
+
export type NrgFormOptions = NonNullable<JsonSchemaObjectExtensions["x-nrg-form"]>;
|
|
111
|
+
/**
|
|
112
|
+
* A serialized property schema inside {@link JsonSchemaObject} `properties`,
|
|
113
|
+
* including NRG's custom keywords (shared vocabulary in core/schema-options)
|
|
114
|
+
* that drive form rendering and NodeRef/TypedInput identification.
|
|
115
|
+
*/
|
|
116
|
+
export interface JsonPropertySchema extends JsonSchemaObjectExtensions {
|
|
117
|
+
type?: string | string[];
|
|
118
|
+
properties?: Record<string, JsonPropertySchema>;
|
|
119
|
+
required?: string[];
|
|
120
|
+
enum?: unknown[];
|
|
121
|
+
anyOf?: JsonPropertySchema[];
|
|
122
|
+
const?: unknown;
|
|
123
|
+
items?: JsonPropertySchema;
|
|
124
|
+
title?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
default?: unknown;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A serialized JSON Schema object as the build pipeline emits it (never a
|
|
130
|
+
* live TypeBox instance). Extends ajv's `SchemaObject` so it flows into
|
|
131
|
+
* validator APIs without casts, while keeping the `type: "object"`
|
|
132
|
+
* discriminant and structured `properties`/`required` that ajv's open
|
|
133
|
+
* `[x: string]: any` shape does not provide.
|
|
134
|
+
*/
|
|
135
|
+
export interface JsonSchemaObject extends SchemaObject {
|
|
136
|
+
type: "object";
|
|
137
|
+
properties?: Record<string, JsonPropertySchema>;
|
|
138
|
+
required?: string[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A node definition as it exists at editor runtime, after the build pipeline
|
|
142
|
+
* merged in the schema-derived artifacts (defaults, credentials, serialized
|
|
143
|
+
* schemas). Authors write {@link NodeDefinition}; the inliner provides the
|
|
144
|
+
* rest.
|
|
145
|
+
*/
|
|
146
|
+
export interface RuntimeNodeDefinition extends NodeDefinition {
|
|
147
|
+
defaults?: NodeDefaults;
|
|
148
|
+
credentials?: NodeCredentials;
|
|
149
|
+
/**
|
|
150
|
+
* Names of the base output ports when `outputsSchema` is a record of named
|
|
151
|
+
* ports, in declaration order; absent for single/positional outputs. Resolved
|
|
152
|
+
* server-side by the inliner so the editor never guesses port names from the
|
|
153
|
+
* serialized schema.
|
|
154
|
+
*/
|
|
155
|
+
outputPortNames?: string[];
|
|
156
|
+
configSchema?: JsonSchemaObject;
|
|
157
|
+
credentialsSchema?: JsonSchemaObject;
|
|
158
|
+
inputSchema?: JsonSchemaObject;
|
|
159
|
+
/**
|
|
160
|
+
* Single port, positional ports, or named ports (key = port name).
|
|
161
|
+
* Not constrained to object schemas: with returnProperty the raw sent
|
|
162
|
+
* value is validated, so results may be any schema shape.
|
|
163
|
+
*/
|
|
164
|
+
outputsSchema?: JsonPropertySchema | JsonPropertySchema[] | Record<string, JsonPropertySchema>;
|
|
165
|
+
}
|
|
166
|
+
export interface NodeDefaults {
|
|
167
|
+
[key: string]: {
|
|
168
|
+
value: any;
|
|
169
|
+
type?: string;
|
|
170
|
+
label?: string;
|
|
171
|
+
required?: boolean;
|
|
172
|
+
validate?: (this: NodeRedNode, value: any, opt: any) => any;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export interface NodeCredentials {
|
|
176
|
+
[key: string]: {
|
|
177
|
+
value?: string;
|
|
178
|
+
type?: "password" | "text";
|
|
179
|
+
label?: string;
|
|
180
|
+
required?: boolean;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export interface NodeFeatures {
|
|
184
|
+
hasInputSchema: boolean;
|
|
185
|
+
hasOutputSchema: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Base output ports (excludes built-in error/complete/status), in port-index
|
|
188
|
+
* order. Drives the per-port context-mode rows in the Outputs subsection.
|
|
189
|
+
*/
|
|
190
|
+
outputPorts: {
|
|
191
|
+
index: number;
|
|
192
|
+
label: string;
|
|
193
|
+
}[];
|
|
194
|
+
}
|
|
195
|
+
/** Client-side representation of a TypedInput field: the raw value string and its type selector. */
|
|
196
|
+
export interface TypedInputValue {
|
|
197
|
+
value: string;
|
|
198
|
+
type: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Maps a schema's static type to the raw values the editor form holds.
|
|
202
|
+
* The server counterpart (`ResolvedStatic` in server/schemas/types) maps the
|
|
203
|
+
* same brands — shared via core/brands — to resolved runtime values instead.
|
|
204
|
+
* - `NodeRef<T>` → `string` (the referenced node's id)
|
|
205
|
+
* - `TypedInput<T>` → `TypedInputValue` (raw value + type pair)
|
|
206
|
+
* - Functions pass through, arrays and objects map recursively
|
|
207
|
+
*/
|
|
208
|
+
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 ? {
|
|
209
|
+
[K in keyof T]: EditorStatic<T[K]>;
|
|
210
|
+
} : T;
|
|
211
|
+
/**
|
|
212
|
+
* Infers the client-side TypeScript type from a TypeBox schema.
|
|
213
|
+
*
|
|
214
|
+
* Resolves schema types to their client form representations:
|
|
215
|
+
* - `NodeRef<T>` → `string` (node ID in the editor)
|
|
216
|
+
* - `TypedInput<T>` → `{ value: string; type: string }`
|
|
217
|
+
* - All other types resolve via TypeBox's `Static<T>`
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import type { Infer } from "@bonsae/nrg/client";
|
|
222
|
+
* import type { ConfigSchema } from "../schemas/my-node";
|
|
223
|
+
*
|
|
224
|
+
* type Config = Infer<typeof ConfigSchema>;
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export type Infer<T extends TSchema> = EditorStatic<Static<T>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global component type declarations for Volar / Vue Language Server.
|
|
3
|
+
* Auto-generated during build — do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {};
|
|
7
|
+
|
|
8
|
+
declare module "vue" {
|
|
9
|
+
export interface ComponentCustomProperties {
|
|
10
|
+
$i18n: (label: string) => string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
NodeRedConfigInput: (typeof import("./client/form/components/node-red-config-input.vue"))["default"];
|
|
15
|
+
NodeRedEditorInput: (typeof import("./client/form/components/node-red-editor-input.vue"))["default"];
|
|
16
|
+
NodeRedInputLabel: (typeof import("./client/form/components/node-red-input-label.vue"))["default"];
|
|
17
|
+
NodeRedInput: (typeof import("./client/form/components/node-red-input.vue"))["default"];
|
|
18
|
+
NodeRedJsonSchemaForm: (typeof import("./client/form/components/node-red-json-schema-form.vue"))["default"];
|
|
19
|
+
NodeRedSelectInput: (typeof import("./client/form/components/node-red-select-input.vue"))["default"];
|
|
20
|
+
NodeRedToggle: (typeof import("./client/form/components/node-red-toggle.vue"))["default"];
|
|
21
|
+
NodeRedTypedInput: (typeof import("./client/form/components/node-red-typed-input.vue"))["default"];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const TYPED_INPUT_TYPES: readonly ["msg", "flow", "global", "str", "num", "bool", "json", "bin", "re", "jsonata", "date", "env", "node", "cred"];
|
|
2
|
+
/** Reserved config property names for built-in ports (error, complete, status) */
|
|
3
|
+
declare const BUILTIN_PORT_KEYS: readonly ["errorPort", "completePort", "statusPort"];
|
|
4
|
+
export { BUILTIN_PORT_KEYS, TYPED_INPUT_TYPES };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NRG's JSON Schema vocabulary — the custom keywords the server emits onto
|
|
3
|
+
* serialized schemas and the client consumes for form rendering and
|
|
4
|
+
* validation. Shared at the core root (like brands.ts) so both planes derive
|
|
5
|
+
* from one definition instead of drifting copies.
|
|
6
|
+
*/
|
|
7
|
+
export interface JsonSchemaObjectExtensions {
|
|
8
|
+
format?: "node-id" | "flow-id" | "topic-path" | (string & {});
|
|
9
|
+
/** expose this settings property to the editor via RED.settings */
|
|
10
|
+
exportable?: boolean;
|
|
11
|
+
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
12
|
+
"x-nrg-node-type"?: string;
|
|
13
|
+
/** set by SchemaType.TypedInput — marks a TypedInput value/type pair */
|
|
14
|
+
"x-nrg-typed-input"?: boolean;
|
|
15
|
+
/** set by markNonValidatable — ajv skips this property */
|
|
16
|
+
"x-nrg-skip-validation"?: boolean;
|
|
17
|
+
/** form rendering hints consumed by the auto-generated editor form */
|
|
18
|
+
"x-nrg-form"?: {
|
|
19
|
+
icon?: string;
|
|
20
|
+
typedInputTypes?: string[];
|
|
21
|
+
editorLanguage?: string;
|
|
22
|
+
toggle?: boolean;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This import makes the file a module, which is required for
|
|
2
|
+
// TypeScript module augmentation (declare module) to work correctly.
|
|
3
|
+
// Without it, the file is treated as a global script and the
|
|
4
|
+
// augmentation silently fails.
|
|
5
|
+
import type { JsonSchemaObjectExtensions } from "./schema-options";
|
|
6
|
+
|
|
7
|
+
declare module "@sinclair/typebox" {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
9
|
+
interface SchemaOptions extends JsonSchemaObjectExtensions {}
|
|
10
|
+
}
|