@bonsae/nrg 0.26.3 → 0.27.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/package.json +1 -1
- package/server/index.cjs +198 -151
- package/server/resources/nrg-client.js +9 -9
- package/test/client/component/index.js +107 -99
- package/test/client/component/nrg.css +1 -1
- package/test/client/component/setup.js +103 -75
- package/test/client/e2e/index.js +11 -5
- package/test/server/integration/config.js +0 -6
- package/test/server/integration/index.js +9 -13
- package/test/server/unit/config.js +0 -6
- package/test/server/unit/index.js +1 -9
- package/types/client.d.ts +15 -7
- package/types/server.d.ts +81 -72
- package/types/shims/core/client/form/components/node-red-json-schema-form.vue.d.ts +11 -1
- package/types/shims/core/client/form/components/node-red-toggle.vue.d.ts +15 -0
- package/types/shims/core/client/types.d.ts +8 -3
- package/types/shims/core/schema-options.d.ts +1 -1
- package/types/shims/core/types.d.ts +32 -8
- package/types/shims/schema-options.d.ts +1 -1
- package/types/test-client-component.d.ts +9 -6
- package/types/test-client-unit.d.ts +8 -5
- package/types/test-server-integration.d.ts +1 -1
- package/vite/index.js +12 -12
package/types/server.d.ts
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
/// <reference path="./shims/typebox.d.ts" />
|
|
2
2
|
// Generated by dts-bundle-generator v9.5.1
|
|
3
3
|
|
|
4
|
-
import { Kind, ObjectOptions, SchemaOptions, Static, StringFormatOption, StringOptions, TArray, TBoolean, TConst, TEnum, TFunction, TInteger, TIntersect, TLiteral, TNull, TNumber, TObject, TOptional, TProperties, TRecord, TRef, TSchema, TString, TTuple, TUnion } from '@sinclair/typebox';
|
|
4
|
+
import { Kind, ObjectOptions, SchemaOptions, Static, StringFormatOption, StringOptions, TArray, TBoolean, TConst, TEnum, TFunction, TInteger, TIntersect, TLiteral, TNull, TNumber, TObject, TOptional, TProperties, TRecord, TRef, TSchema, TString, TTuple, TUnion, TUnsafe, Type as BaseType } from '@sinclair/typebox';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import { Express as Express$1 } from 'express';
|
|
7
7
|
import { Http2ServerRequest } from 'http2';
|
|
8
8
|
|
|
9
|
-
declare const TYPED_INPUT_TYPES: readonly [
|
|
10
|
-
"msg",
|
|
11
|
-
"flow",
|
|
12
|
-
"global",
|
|
13
|
-
"str",
|
|
14
|
-
"num",
|
|
15
|
-
"bool",
|
|
16
|
-
"json",
|
|
17
|
-
"bin",
|
|
18
|
-
"re",
|
|
19
|
-
"jsonata",
|
|
20
|
-
"date",
|
|
21
|
-
"env",
|
|
22
|
-
"node",
|
|
23
|
-
"cred"
|
|
24
|
-
];
|
|
25
|
-
declare const BUILTIN_PORT_KEYS: readonly [
|
|
26
|
-
"errorPort",
|
|
27
|
-
"completePort",
|
|
28
|
-
"statusPort"
|
|
29
|
-
];
|
|
30
9
|
export interface NodeRedRuntimeSettings {
|
|
31
10
|
userDir?: string;
|
|
32
11
|
nodesDir?: string | string[];
|
|
@@ -357,21 +336,29 @@ interface NodeRedContextStore {
|
|
|
357
336
|
*/
|
|
358
337
|
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
359
338
|
}
|
|
360
|
-
declare
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
339
|
+
declare const TYPED_INPUT_TYPES: readonly [
|
|
340
|
+
"msg",
|
|
341
|
+
"flow",
|
|
342
|
+
"global",
|
|
343
|
+
"str",
|
|
344
|
+
"num",
|
|
345
|
+
"bool",
|
|
346
|
+
"json",
|
|
347
|
+
"bin",
|
|
348
|
+
"re",
|
|
349
|
+
"jsonata",
|
|
350
|
+
"date",
|
|
351
|
+
"env",
|
|
352
|
+
"node",
|
|
353
|
+
"cred"
|
|
354
|
+
];
|
|
355
|
+
declare const BUILTIN_PORT_KEYS: readonly [
|
|
356
|
+
"errorPort",
|
|
357
|
+
"completePort",
|
|
358
|
+
"statusPort"
|
|
359
|
+
];
|
|
373
360
|
interface JsonSchemaObjectExtensions {
|
|
374
|
-
format?: "node-id" |
|
|
361
|
+
format?: "node-id" | (string & {});
|
|
375
362
|
/** expose this settings property to the editor via RED.settings */
|
|
376
363
|
exportable?: boolean;
|
|
377
364
|
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
@@ -440,11 +427,15 @@ export declare const StatusPortSchema: import("@sinclair/typebox").TObject<{
|
|
|
440
427
|
import("@sinclair/typebox").TObject<{
|
|
441
428
|
fill: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[
|
|
442
429
|
import("@sinclair/typebox").TLiteral<"red">,
|
|
443
|
-
import("@sinclair/typebox").TLiteral<"green"
|
|
430
|
+
import("@sinclair/typebox").TLiteral<"green">,
|
|
431
|
+
import("@sinclair/typebox").TLiteral<"yellow">,
|
|
432
|
+
import("@sinclair/typebox").TLiteral<"blue">,
|
|
433
|
+
import("@sinclair/typebox").TLiteral<"grey">,
|
|
434
|
+
import("@sinclair/typebox").TLiteral<"gray">
|
|
444
435
|
]>>;
|
|
445
436
|
shape: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[
|
|
446
|
-
import("@sinclair/typebox").TLiteral<"
|
|
447
|
-
import("@sinclair/typebox").TLiteral<"
|
|
437
|
+
import("@sinclair/typebox").TLiteral<"ring">,
|
|
438
|
+
import("@sinclair/typebox").TLiteral<"dot">
|
|
448
439
|
]>>;
|
|
449
440
|
text: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
450
441
|
}>,
|
|
@@ -460,6 +451,17 @@ interface NodeRefResolved<T = any> {
|
|
|
460
451
|
readonly __nrg_node_ref: true;
|
|
461
452
|
readonly __instance: T;
|
|
462
453
|
}
|
|
454
|
+
interface TypedInputResolved<T = unknown> {
|
|
455
|
+
readonly __nrg_typed_input: true;
|
|
456
|
+
readonly __value: T;
|
|
457
|
+
}
|
|
458
|
+
interface UnsafeResolved<T = unknown> {
|
|
459
|
+
readonly __nrg_unsafe: true;
|
|
460
|
+
readonly __value: T;
|
|
461
|
+
}
|
|
462
|
+
interface ConfigNodeBrand {
|
|
463
|
+
readonly __nrg_config_node: true;
|
|
464
|
+
}
|
|
463
465
|
/** Schema type representing a reference to a config node. Resolves to the node instance at runtime. */
|
|
464
466
|
export interface TNodeRef<T = any> extends TSchema {
|
|
465
467
|
[Kind]: "NodeRef";
|
|
@@ -468,26 +470,11 @@ export interface TNodeRef<T = any> extends TSchema {
|
|
|
468
470
|
format: "node-id";
|
|
469
471
|
"x-nrg-node-type"?: string;
|
|
470
472
|
}
|
|
471
|
-
type ResolvedStatic<T> = T extends NodeRefResolved<infer I> ? I : T extends TypedInput<any> ? T : T extends (...args: any[]) => any ? T : T extends Array<infer Item> ? ResolvedStatic<Item>[] : T extends object ? {
|
|
472
|
-
[K in keyof T]: ResolvedStatic<T[K]>;
|
|
473
|
-
} : T;
|
|
474
|
-
/**
|
|
475
|
-
* Infers the TypeScript type from a schema or a record of schemas.
|
|
476
|
-
*
|
|
477
|
-
* - Single schema: `Infer<typeof MySchema>` → the inferred message type
|
|
478
|
-
* - Record of schemas: `Infer<typeof outputsSchema>` → `{ portName: InferredType }` port map
|
|
479
|
-
*
|
|
480
|
-
* The record form produces a simple mapped type that resolves eagerly,
|
|
481
|
-
* giving `sendToPort()` proper autocomplete in class-based nodes.
|
|
482
|
-
*/
|
|
483
|
-
export type Infer<T extends TSchema | Record<string, TSchema>> = T extends TSchema ? ResolvedStatic<Static<T>> : {
|
|
484
|
-
[K in keyof T & string]: T[K] extends TSchema ? ResolvedStatic<Static<T[K]>> : never;
|
|
485
|
-
};
|
|
486
473
|
type TypedInputType = (typeof TYPED_INPUT_TYPES)[number];
|
|
487
474
|
/** Schema type representing a Node-RED TypedInput (value + type pair). */
|
|
488
475
|
export interface TTypedInput<T = unknown> extends TSchema {
|
|
489
476
|
[Kind]: "TypedInput";
|
|
490
|
-
static:
|
|
477
|
+
static: TypedInputResolved<T>;
|
|
491
478
|
"x-nrg-typed-input": true;
|
|
492
479
|
}
|
|
493
480
|
interface NrgSchemaOptions extends SchemaOptions, JsonSchemaObjectExtensions {
|
|
@@ -498,17 +485,46 @@ export type NodeSource = Static<typeof NodeSourceSchema>;
|
|
|
498
485
|
export type ErrorPortMessage = Static<typeof ErrorPortSchema>;
|
|
499
486
|
export type CompletePortMessage = Static<typeof CompletePortSchema>;
|
|
500
487
|
export type StatusPortMessage = Static<typeof StatusPortSchema>;
|
|
488
|
+
declare class TypedInput<T = unknown> {
|
|
489
|
+
private readonly RED;
|
|
490
|
+
private readonly node;
|
|
491
|
+
private readonly input;
|
|
492
|
+
private readonly resolvers;
|
|
493
|
+
constructor(RED: RED, node: NodeRedNode, input: {
|
|
494
|
+
value: unknown;
|
|
495
|
+
type: TypedInputType;
|
|
496
|
+
});
|
|
497
|
+
get type(): TypedInputType;
|
|
498
|
+
get value(): unknown;
|
|
499
|
+
resolve(msg?: Record<string, any>): Promise<T>;
|
|
500
|
+
}
|
|
501
|
+
type ResolvedStatic<T> = T extends NodeRefResolved<infer I> ? I : T extends TypedInputResolved<infer U> ? TypedInput<U> : T extends UnsafeResolved<infer V> ? V : T extends (...args: any[]) => any ? T : T extends Array<infer Item> ? ResolvedStatic<Item>[] : T extends object ? {
|
|
502
|
+
[K in keyof T]: ResolvedStatic<T[K]>;
|
|
503
|
+
} : T;
|
|
504
|
+
/**
|
|
505
|
+
* Infers the TypeScript type from a schema or a record of schemas.
|
|
506
|
+
*
|
|
507
|
+
* - Single schema: `Infer<typeof MySchema>` → the inferred message type
|
|
508
|
+
* - Record of schemas: `Infer<typeof outputsSchema>` → `{ portName: InferredType }` port map
|
|
509
|
+
*
|
|
510
|
+
* The record form produces a simple mapped type that resolves eagerly,
|
|
511
|
+
* giving `sendToPort()` proper autocomplete in class-based nodes.
|
|
512
|
+
*/
|
|
513
|
+
export type Infer<T extends TSchema | Record<string, TSchema>> = T extends TSchema ? ResolvedStatic<Static<T>> : {
|
|
514
|
+
[K in keyof T & string]: T[K] extends TSchema ? ResolvedStatic<Static<T[K]>> : never;
|
|
515
|
+
};
|
|
501
516
|
type InferOr<T, Fallback> = T extends TSchema ? Infer<T> : Fallback;
|
|
502
517
|
type InferOutputs<T> = T extends readonly TSchema[] ? {
|
|
503
518
|
[K in keyof T]: T[K] extends TSchema ? Infer<T[K]> : never;
|
|
504
519
|
} : T extends TSchema ? Infer<T> : T extends Record<string, TSchema> ? {
|
|
505
520
|
[K in keyof T & string]: Infer<T[K]>;
|
|
506
521
|
} : any;
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
522
|
+
type AnyConstructor = abstract new (...args: any[]) => any;
|
|
523
|
+
type NodeRefInstance<T> = T extends AnyConstructor ? InstanceType<T> : T;
|
|
524
|
+
type ConfigNodeRef = ConfigNodeBrand | (abstract new (...args: any[]) => ConfigNodeBrand);
|
|
525
|
+
declare function NodeRef<T extends ConfigNodeRef = ConfigNodeBrand>(type: string, options?: NrgSchemaOptions): TNodeRef<NodeRefInstance<T>>;
|
|
510
526
|
declare function TypedInput$1<T = unknown>(options?: NrgSchemaOptions): TTypedInput<T>;
|
|
511
|
-
type NrgStringFormat = StringFormatOption | "password" | "byte" | "binary" | "url" | "duration" | "iso-time" | "iso-date-time" | "json-pointer-uri-fragment";
|
|
527
|
+
type NrgStringFormat = StringFormatOption | "node-id" | "password" | "byte" | "binary" | "url" | "duration" | "iso-time" | "iso-date-time" | "json-pointer-uri-fragment";
|
|
512
528
|
interface NrgStringOptions extends Omit<StringOptions, "format"> {
|
|
513
529
|
format?: NrgStringFormat;
|
|
514
530
|
}
|
|
@@ -523,24 +539,16 @@ declare function OutputContextModes(options?: NrgSchemaOptions & {
|
|
|
523
539
|
import("@sinclair/typebox").TLiteral<"trace">,
|
|
524
540
|
import("@sinclair/typebox").TLiteral<"reset">
|
|
525
541
|
]>>;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
* Includes all standard TypeBox types plus {@link NodeRef}, {@link TypedInput},
|
|
529
|
-
* {@link OutputReturnProperties} and {@link OutputContextModes}.
|
|
530
|
-
*
|
|
531
|
-
* For ports or config fields that carry non-data values (functions, class
|
|
532
|
-
* instances, Buffers, streams, connections), use `Unsafe<T>()` to get the
|
|
533
|
-
* TypeScript type without runtime validation — `Any()`/`Unknown()` skip
|
|
534
|
-
* validation too but lose the type. For config-node references and typed inputs
|
|
535
|
-
* use {@link NodeRef} / {@link TypedInput} instead. See the Schemas guide.
|
|
536
|
-
*/
|
|
537
|
-
export declare const SchemaType: import("@sinclair/typebox").JavaScriptTypeBuilder & {
|
|
542
|
+
declare function NrgUnsafe<T = unknown>(options?: object): TUnsafe<UnsafeResolved<T>>;
|
|
543
|
+
declare const NrgBuilders: {
|
|
538
544
|
String: typeof NrgString;
|
|
545
|
+
Unsafe: typeof NrgUnsafe;
|
|
539
546
|
NodeRef: typeof NodeRef;
|
|
540
547
|
TypedInput: typeof TypedInput$1;
|
|
541
548
|
OutputReturnProperties: typeof OutputReturnProperties;
|
|
542
549
|
OutputContextModes: typeof OutputContextModes;
|
|
543
550
|
};
|
|
551
|
+
export declare const SchemaType: Omit<typeof BaseType, keyof typeof NrgBuilders> & typeof NrgBuilders;
|
|
544
552
|
/**
|
|
545
553
|
* Creates a validated object schema from a set of properties. Automatically
|
|
546
554
|
* marks non-JSON types (e.g., Function) as non-validatable.
|
|
@@ -833,6 +841,7 @@ interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined
|
|
|
833
841
|
export declare abstract class ConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends Node$1<TConfig, TCredentials, TSettings> implements IConfigNode<TConfig, TCredentials, TSettings> {
|
|
834
842
|
static readonly category: string;
|
|
835
843
|
readonly config: ConfigNodeConfig<TConfig>;
|
|
844
|
+
readonly __nrg_config_node: true;
|
|
836
845
|
protected readonly context: ConfigNodeContext;
|
|
837
846
|
constructor(RED: RED, node: NodeRedNode, config: ConfigNodeConfig<TConfig>, credentials: ConfigNodeCredentials<TCredentials>);
|
|
838
847
|
get userIds(): string[];
|
|
@@ -850,7 +859,7 @@ type ConfigNodeContext = {
|
|
|
850
859
|
};
|
|
851
860
|
type BoundConfigNode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined> = ConfigNode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TS, any>>;
|
|
852
861
|
/** Public instance interface for config nodes. Implemented by {@link ConfigNode}. */
|
|
853
|
-
export interface IConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings
|
|
862
|
+
export interface IConfigNode<TConfig = any, TCredentials = any, TSettings = any> extends INode<TConfig, TCredentials, TSettings>, ConfigNodeBrand {
|
|
854
863
|
readonly config: ConfigNodeConfig<TConfig>;
|
|
855
864
|
readonly credentials: ConfigNodeCredentials<TCredentials> | undefined;
|
|
856
865
|
readonly userIds: string[];
|
|
@@ -5,7 +5,7 @@ interface FormField {
|
|
|
5
5
|
key: string;
|
|
6
6
|
label: string;
|
|
7
7
|
icon: string;
|
|
8
|
-
inputType: "text" | "number" | "boolean" | "select" | "typed" | "config" | "editor" | "array-text";
|
|
8
|
+
inputType: "text" | "number" | "boolean" | "select" | "typed" | "config" | "editor" | "array-text" | "object-json";
|
|
9
9
|
required: boolean;
|
|
10
10
|
htmlType?: "text" | "number" | "password";
|
|
11
11
|
options?: Array<{
|
|
@@ -35,6 +35,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
35
35
|
configFields(): FormField[];
|
|
36
36
|
credentialFields(): FormField[];
|
|
37
37
|
}, {
|
|
38
|
+
setObjectField(key: string, raw: string): void;
|
|
38
39
|
resolveI18n(prefix: string, key: string): string | undefined;
|
|
39
40
|
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
41
|
node: {
|
|
@@ -98,6 +99,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
98
99
|
type: StringConstructor;
|
|
99
100
|
default: string;
|
|
100
101
|
};
|
|
102
|
+
ariaLabel: {
|
|
103
|
+
type: StringConstructor;
|
|
104
|
+
default: string;
|
|
105
|
+
};
|
|
101
106
|
}>, {}, {}, {
|
|
102
107
|
iconClass(): string;
|
|
103
108
|
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -113,12 +118,17 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
113
118
|
type: StringConstructor;
|
|
114
119
|
default: string;
|
|
115
120
|
};
|
|
121
|
+
ariaLabel: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
116
125
|
}>> & Readonly<{
|
|
117
126
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
118
127
|
}>, {
|
|
119
128
|
label: string;
|
|
120
129
|
icon: string;
|
|
121
130
|
modelValue: boolean;
|
|
131
|
+
ariaLabel: string;
|
|
122
132
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
123
133
|
NodeRedInput: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
124
134
|
modelValue: {
|
|
@@ -11,6 +11,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
11
11
|
type: StringConstructor;
|
|
12
12
|
default: string;
|
|
13
13
|
};
|
|
14
|
+
/** Accessible name for the control when no visible `label` is rendered
|
|
15
|
+
* (e.g. a bare toggle in a table cell where the column header is the
|
|
16
|
+
* visible label but isn't programmatically associated). */
|
|
17
|
+
ariaLabel: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
14
21
|
}>, {}, {}, {
|
|
15
22
|
iconClass(): string;
|
|
16
23
|
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -26,11 +33,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
26
33
|
type: StringConstructor;
|
|
27
34
|
default: string;
|
|
28
35
|
};
|
|
36
|
+
/** Accessible name for the control when no visible `label` is rendered
|
|
37
|
+
* (e.g. a bare toggle in a table cell where the column header is the
|
|
38
|
+
* visible label but isn't programmatically associated). */
|
|
39
|
+
ariaLabel: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
29
43
|
}>> & Readonly<{
|
|
30
44
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
45
|
}>, {
|
|
32
46
|
label: string;
|
|
33
47
|
icon: string;
|
|
34
48
|
modelValue: boolean;
|
|
49
|
+
ariaLabel: string;
|
|
35
50
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
36
51
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Component, App } from "vue";
|
|
2
2
|
import type { TSchema, Static } from "@sinclair/typebox";
|
|
3
3
|
import type { SchemaObject } from "ajv";
|
|
4
|
-
import type { NodeRefResolved, TypedInputResolved } from "../types";
|
|
4
|
+
import type { NodeRefResolved, TypedInputResolved, UnsafeResolved } from "../types";
|
|
5
5
|
import type { JsonSchemaObjectExtensions } from "../schema-options";
|
|
6
6
|
export interface NodeStateCredentials {
|
|
7
7
|
[key: string]: any;
|
|
@@ -205,7 +205,7 @@ export interface TypedInputValue {
|
|
|
205
205
|
* - `TypedInput<T>` → `TypedInputValue` (raw value + type pair)
|
|
206
206
|
* - Functions pass through, arrays and objects map recursively
|
|
207
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 ? {
|
|
208
|
+
export type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extends TypedInputResolved<any> ? TypedInputValue : T extends UnsafeResolved<infer V> ? V : T extends (...args: any[]) => any ? T : T extends Array<infer I> ? EditorStatic<I>[] : T extends object ? {
|
|
209
209
|
[K in keyof T]: EditorStatic<T[K]>;
|
|
210
210
|
} : T;
|
|
211
211
|
/**
|
|
@@ -216,6 +216,9 @@ export type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extend
|
|
|
216
216
|
* - `TypedInput<T>` → `{ value: string; type: string }`
|
|
217
217
|
* - All other types resolve via TypeBox's `Static<T>`
|
|
218
218
|
*
|
|
219
|
+
* Accepts a single schema or a record of schemas (e.g. an outputs map),
|
|
220
|
+
* mirroring the server `Infer` so the same pattern compiles on both planes.
|
|
221
|
+
*
|
|
219
222
|
* @example
|
|
220
223
|
* ```ts
|
|
221
224
|
* import type { Infer } from "@bonsae/nrg/client";
|
|
@@ -224,4 +227,6 @@ export type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extend
|
|
|
224
227
|
* type Config = Infer<typeof ConfigSchema>;
|
|
225
228
|
* ```
|
|
226
229
|
*/
|
|
227
|
-
export type Infer<T extends TSchema
|
|
230
|
+
export type Infer<T extends TSchema | Record<string, TSchema>> = T extends TSchema ? EditorStatic<Static<T>> : {
|
|
231
|
+
[K in keyof T & string]: T[K] extends TSchema ? EditorStatic<Static<T[K]>> : never;
|
|
232
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* from one definition instead of drifting copies.
|
|
6
6
|
*/
|
|
7
7
|
export interface JsonSchemaObjectExtensions {
|
|
8
|
-
format?: "node-id" |
|
|
8
|
+
format?: "node-id" | (string & {});
|
|
9
9
|
/** expose this settings property to the editor via RED.settings */
|
|
10
10
|
exportable?: boolean;
|
|
11
11
|
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
@@ -20,13 +20,37 @@ interface NodeRefResolved<T = any> {
|
|
|
20
20
|
readonly __instance: T;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Brand produced by `Static` of a TypedInput schema. Carries the resolved value
|
|
24
|
+
* type `T` so each plane can map it: the server `ResolvedStatic` maps it to the
|
|
25
|
+
* `TypedInput<T>` class instance (with `.resolve()`); the client `EditorStatic`
|
|
26
|
+
* maps it to the raw `{ value, type }` editor pair. Nominal (not structural) so
|
|
27
|
+
* the shared schema type never needs to reference the server `TypedInput` class.
|
|
26
28
|
*/
|
|
27
|
-
interface TypedInputResolved {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: string;
|
|
29
|
+
interface TypedInputResolved<T = unknown> {
|
|
30
|
+
readonly __nrg_typed_input: true;
|
|
31
|
+
readonly __value: T;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Brand produced by `Static` of an `Unsafe<T>` schema. Carries `T` so both
|
|
35
|
+
* planes resolve it straight back to `T` unchanged. Without the brand, a class
|
|
36
|
+
* instance passed via `Unsafe<Conn>` would be deep-mapped by `ResolvedStatic`/
|
|
37
|
+
* `EditorStatic` into a structural object, silently dropping private/protected/
|
|
38
|
+
* `#` members so the result is no longer assignable to `Conn` (TS2741) — exactly
|
|
39
|
+
* the documented non-data-value use case (connections, streams, Buffers).
|
|
40
|
+
*/
|
|
41
|
+
interface UnsafeResolved<T = unknown> {
|
|
42
|
+
readonly __nrg_unsafe: true;
|
|
43
|
+
readonly __value: T;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Type-only marker carried by every nrg config node — the server `ConfigNode`
|
|
47
|
+
* class and the `IConfigNode` interface both declare it. It lets the
|
|
48
|
+
* browser-safe `NodeRef<T>` builder constrain `T` to a config node WITHOUT the
|
|
49
|
+
* shared layer importing the server `ConfigNode` type: shared owns the marker,
|
|
50
|
+
* and the server's config-node types declare they carry it. Phantom — declared
|
|
51
|
+
* type-only, never a real runtime field.
|
|
52
|
+
*/
|
|
53
|
+
interface ConfigNodeBrand {
|
|
54
|
+
readonly __nrg_config_node: true;
|
|
55
|
+
}
|
|
56
|
+
export type { NodeRefResolved, TypedInputResolved, UnsafeResolved, ConfigNodeBrand, };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* from one definition instead of drifting copies.
|
|
6
6
|
*/
|
|
7
7
|
export interface JsonSchemaObjectExtensions {
|
|
8
|
-
format?: "node-id" |
|
|
8
|
+
format?: "node-id" | (string & {});
|
|
9
9
|
/** expose this settings property to the editor via RED.settings */
|
|
10
10
|
exportable?: boolean;
|
|
11
11
|
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
@@ -8,13 +8,16 @@ interface NodeRefResolved<T = any> {
|
|
|
8
8
|
readonly __nrg_node_ref: true;
|
|
9
9
|
readonly __instance: T;
|
|
10
10
|
}
|
|
11
|
-
interface TypedInputResolved {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
interface TypedInputResolved<T = unknown> {
|
|
12
|
+
readonly __nrg_typed_input: true;
|
|
13
|
+
readonly __value: T;
|
|
14
|
+
}
|
|
15
|
+
interface UnsafeResolved<T = unknown> {
|
|
16
|
+
readonly __nrg_unsafe: true;
|
|
17
|
+
readonly __value: T;
|
|
15
18
|
}
|
|
16
19
|
interface JsonSchemaObjectExtensions {
|
|
17
|
-
format?: "node-id" |
|
|
20
|
+
format?: "node-id" | (string & {});
|
|
18
21
|
/** expose this settings property to the editor via RED.settings */
|
|
19
22
|
exportable?: boolean;
|
|
20
23
|
/** set by SchemaType.NodeRef — the referenced config node type */
|
|
@@ -117,7 +120,7 @@ interface TypedInputValue {
|
|
|
117
120
|
value: string;
|
|
118
121
|
type: string;
|
|
119
122
|
}
|
|
120
|
-
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 ? {
|
|
123
|
+
type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extends TypedInputResolved<any> ? TypedInputValue : T extends UnsafeResolved<infer V> ? V : T extends (...args: any[]) => any ? T : T extends Array<infer I> ? EditorStatic<I>[] : T extends object ? {
|
|
121
124
|
[K in keyof T]: EditorStatic<T[K]>;
|
|
122
125
|
} : T;
|
|
123
126
|
export interface MockEditor {
|
|
@@ -108,10 +108,13 @@ interface NodeRefResolved<T = any> {
|
|
|
108
108
|
readonly __nrg_node_ref: true;
|
|
109
109
|
readonly __instance: T;
|
|
110
110
|
}
|
|
111
|
-
interface TypedInputResolved {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
interface TypedInputResolved<T = unknown> {
|
|
112
|
+
readonly __nrg_typed_input: true;
|
|
113
|
+
readonly __value: T;
|
|
114
|
+
}
|
|
115
|
+
interface UnsafeResolved<T = unknown> {
|
|
116
|
+
readonly __nrg_unsafe: true;
|
|
117
|
+
readonly __value: T;
|
|
115
118
|
}
|
|
116
119
|
interface NodeRedNodeButtonDefinition {
|
|
117
120
|
toggle: string;
|
|
@@ -182,7 +185,7 @@ interface TypedInputValue {
|
|
|
182
185
|
value: string;
|
|
183
186
|
type: string;
|
|
184
187
|
}
|
|
185
|
-
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 ? {
|
|
188
|
+
type EditorStatic<T> = T extends NodeRefResolved<any> ? string : T extends TypedInputResolved<any> ? TypedInputValue : T extends UnsafeResolved<infer V> ? V : T extends (...args: any[]) => any ? T : T extends Array<infer I> ? EditorStatic<I>[] : T extends object ? {
|
|
186
189
|
[K in keyof T]: EditorStatic<T[K]>;
|
|
187
190
|
} : T;
|
|
188
191
|
interface FormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema> {
|
|
@@ -202,6 +202,7 @@ declare const NodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
|
202
202
|
name: import("@sinclair/typebox").TString;
|
|
203
203
|
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
204
204
|
}>;
|
|
205
|
+
type Schema<T extends TProperties = TProperties> = TObject<T>;
|
|
205
206
|
interface NodeRedLog {
|
|
206
207
|
info(msg: any): void;
|
|
207
208
|
warn(msg: any): void;
|
|
@@ -341,7 +342,6 @@ interface NodeRedContextStore {
|
|
|
341
342
|
*/
|
|
342
343
|
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
343
344
|
}
|
|
344
|
-
type Schema<T extends TProperties = TProperties> = TObject<T>;
|
|
345
345
|
interface NodeContextStore {
|
|
346
346
|
get<T = any>(key: string): Promise<T>;
|
|
347
347
|
set<T = any>(key: string, value: T): Promise<void>;
|
package/vite/index.js
CHANGED
|
@@ -110,13 +110,6 @@ function mergeOptions(defaults, overrides) {
|
|
|
110
110
|
import fs4 from "fs";
|
|
111
111
|
|
|
112
112
|
// src/vite/async-utils.ts
|
|
113
|
-
function debounce(fn, delay) {
|
|
114
|
-
let timeout = null;
|
|
115
|
-
return (...args) => {
|
|
116
|
-
if (timeout) clearTimeout(timeout);
|
|
117
|
-
timeout = setTimeout(() => fn(...args), delay);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
113
|
function withTimeout(promise, ms, fallback) {
|
|
121
114
|
return new Promise((resolve, reject) => {
|
|
122
115
|
const timeout = setTimeout(() => {
|
|
@@ -767,6 +760,7 @@ var NodeRedLauncher = class {
|
|
|
767
760
|
import chokidar from "chokidar";
|
|
768
761
|
import treeKill2 from "tree-kill";
|
|
769
762
|
import path14 from "path";
|
|
763
|
+
import { debounce } from "es-toolkit";
|
|
770
764
|
|
|
771
765
|
// src/vite/server/build.ts
|
|
772
766
|
import { build as viteBuild } from "vite";
|
|
@@ -1366,11 +1360,17 @@ function packageJsonGenerator(options) {
|
|
|
1366
1360
|
distDependencies = void 0;
|
|
1367
1361
|
}
|
|
1368
1362
|
const distPackageJson = {
|
|
1369
|
-
|
|
1363
|
+
name: rootPackageJson.name,
|
|
1364
|
+
version: rootPackageJson.version,
|
|
1365
|
+
description: rootPackageJson.description,
|
|
1366
|
+
author: rootPackageJson.author,
|
|
1367
|
+
license: rootPackageJson.license,
|
|
1368
|
+
homepage: rootPackageJson.homepage,
|
|
1369
|
+
repository: rootPackageJson.repository,
|
|
1370
|
+
bugs: rootPackageJson.bugs,
|
|
1371
|
+
engines: rootPackageJson.engines,
|
|
1370
1372
|
main: "index.js",
|
|
1371
1373
|
type: "commonjs",
|
|
1372
|
-
devDependencies: void 0,
|
|
1373
|
-
scripts: void 0,
|
|
1374
1374
|
dependencies: distDependencies,
|
|
1375
1375
|
keywords: [
|
|
1376
1376
|
.../* @__PURE__ */ new Set([...rootPackageJson.keywords ?? [], "node-red"])
|
|
@@ -2519,8 +2519,8 @@ function localesGenerator(options) {
|
|
|
2519
2519
|
}
|
|
2520
2520
|
},
|
|
2521
2521
|
help: {
|
|
2522
|
-
validateInput: "\u5728 input() \u8FD0\u884C\u524D\uFF0C\u6839\u636E\u8F93\u5165\
|
|
2523
|
-
outputs: "\u6309\u7AEF\u53E3\u7684\u8F93\u51FA\u8BBE\u7F6E\u3002\u9A8C\u8BC1\u6570\u636E\u6839\u636E\u7AEF\u53E3\
|
|
2522
|
+
validateInput: "\u5728 input() \u8FD0\u884C\u524D\uFF0C\u6839\u636E\u8F93\u5165\u7ED3\u6784\u63CF\u8FF0\u6821\u9A8C\u4F20\u5165\u6D88\u606F\u3002",
|
|
2523
|
+
outputs: "\u6309\u7AEF\u53E3\u7684\u8F93\u51FA\u8BBE\u7F6E\u3002\u9A8C\u8BC1\u6570\u636E\u6839\u636E\u7AEF\u53E3\u7ED3\u6784\u63CF\u8FF0\u6821\u9A8C\u53D1\u9001\u7684\u503C\uFF1B\u4E0A\u4E0B\u6587\u6A21\u5F0F\u63A7\u5236\u5982\u4F55\u643A\u5E26\u4F20\u5165\u6D88\u606F\u3002",
|
|
2524
2524
|
lifecyclePorts: "\u53EF\u9009\u7684\u989D\u5916\u8F93\u51FA\u7AEF\u53E3\uFF0C\u5728\u51FA\u9519\u3001\u5B8C\u6210\u4EE5\u53CA\u6BCF\u6B21\u72B6\u6001\u53D8\u5316\u65F6\u89E6\u53D1\u3002",
|
|
2525
2525
|
learnMore: "\u4E86\u89E3\u66F4\u591A"
|
|
2526
2526
|
}
|