@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
|
@@ -1,125 +1,13 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { SchemaObject } from 'ajv';
|
|
5
|
-
import { App } from 'vue';
|
|
3
|
+
import { TSchema } from '@sinclair/typebox';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
interface NodeRedNodeButtonDefinition {
|
|
35
|
-
toggle: string;
|
|
36
|
-
onclick: () => void;
|
|
37
|
-
enabled?: () => boolean;
|
|
38
|
-
visible?: () => boolean;
|
|
39
|
-
}
|
|
40
|
-
interface NodeRedNode {
|
|
41
|
-
id: string;
|
|
42
|
-
type: string;
|
|
43
|
-
name: string;
|
|
44
|
-
category: string;
|
|
45
|
-
x: string;
|
|
46
|
-
y: string;
|
|
47
|
-
g: string;
|
|
48
|
-
z: string;
|
|
49
|
-
credentials: Record<string, any>;
|
|
50
|
-
_def: {
|
|
51
|
-
defaults: Record<string, {
|
|
52
|
-
value: string;
|
|
53
|
-
type?: string;
|
|
54
|
-
label?: string;
|
|
55
|
-
required?: boolean;
|
|
56
|
-
}>;
|
|
57
|
-
credentials: Record<string, {
|
|
58
|
-
value: string;
|
|
59
|
-
type?: "password" | "text";
|
|
60
|
-
label?: string;
|
|
61
|
-
required?: boolean;
|
|
62
|
-
}>;
|
|
63
|
-
category: string;
|
|
64
|
-
color?: string;
|
|
65
|
-
icon?: string;
|
|
66
|
-
label?: ((this: NodeRedNode) => string) | string;
|
|
67
|
-
inputs?: number;
|
|
68
|
-
outputs?: number;
|
|
69
|
-
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
70
|
-
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
71
|
-
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
72
|
-
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
73
|
-
align?: "left" | "right";
|
|
74
|
-
button?: NodeRedNodeButtonDefinition;
|
|
75
|
-
};
|
|
76
|
-
_newState?: NodeRedNode;
|
|
77
|
-
_app?: App | null;
|
|
78
|
-
_: (str: string) => string;
|
|
79
|
-
/** dynamic port count (base outputs + enabled built-in ports) */
|
|
80
|
-
outputs?: number;
|
|
81
|
-
/** injected when the node has an inputSchema */
|
|
82
|
-
validateInput?: boolean;
|
|
83
|
-
/** built-in port toggles, present when declared in the configSchema */
|
|
84
|
-
errorPort?: boolean;
|
|
85
|
-
completePort?: boolean;
|
|
86
|
-
statusPort?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Per-port output settings, indexed by base-output port. `validateOutputs` is
|
|
89
|
-
* injected (empty) when the node has an outputsSchema; `outputReturnProperties`
|
|
90
|
-
* and `outputContextModes` are author-declared (SchemaType.*) — present only
|
|
91
|
-
* when the node opts into per-port return keys / context modes. Read at
|
|
92
|
-
* runtime by IONode.
|
|
93
|
-
*/
|
|
94
|
-
validateOutputs?: Record<number, boolean>;
|
|
95
|
-
outputContextModes?: Record<number, "carry" | "trace" | "reset">;
|
|
96
|
-
outputReturnProperties?: Record<number, string>;
|
|
97
|
-
[key: string]: any;
|
|
98
|
-
}
|
|
99
|
-
interface JsonPropertySchema extends JsonSchemaObjectExtensions {
|
|
100
|
-
type?: string | string[];
|
|
101
|
-
properties?: Record<string, JsonPropertySchema>;
|
|
102
|
-
required?: string[];
|
|
103
|
-
enum?: unknown[];
|
|
104
|
-
anyOf?: JsonPropertySchema[];
|
|
105
|
-
const?: unknown;
|
|
106
|
-
items?: JsonPropertySchema;
|
|
107
|
-
title?: string;
|
|
108
|
-
description?: string;
|
|
109
|
-
default?: unknown;
|
|
110
|
-
}
|
|
111
|
-
interface JsonSchemaObject extends SchemaObject {
|
|
112
|
-
type: "object";
|
|
113
|
-
properties?: Record<string, JsonPropertySchema>;
|
|
114
|
-
required?: string[];
|
|
115
|
-
}
|
|
116
|
-
interface TypedInputValue {
|
|
117
|
-
value: string;
|
|
118
|
-
type: string;
|
|
119
|
-
}
|
|
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 ? {
|
|
121
|
-
[K in keyof T]: EditorStatic<T[K]>;
|
|
122
|
-
} : T;
|
|
5
|
+
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): {
|
|
6
|
+
node: Record<string, any>;
|
|
7
|
+
schema: Record<string, any>;
|
|
8
|
+
errors: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
type JsonSchemaObject = Record<string, any>;
|
|
123
11
|
export interface MockEditor {
|
|
124
12
|
getValue(): string;
|
|
125
13
|
setValue(val: string): void;
|
|
@@ -216,30 +104,6 @@ export interface MockRED {
|
|
|
216
104
|
settings: MockSettings;
|
|
217
105
|
notify(message: any, options?: Record<string, any>): MockNotification;
|
|
218
106
|
}
|
|
219
|
-
interface FormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema> {
|
|
220
|
-
node: NodeRedNode & EditorStatic<Static<TConfig>> & {
|
|
221
|
-
credentials: EditorStatic<Static<TCredentials>> & Record<string, any>;
|
|
222
|
-
};
|
|
223
|
-
schema: Record<string, any>;
|
|
224
|
-
errors: Record<string, string>;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Composable that provides typed access to the form node, schema, and errors.
|
|
228
|
-
* Replaces `defineProps` in custom form components — no props declaration needed.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```vue
|
|
232
|
-
* <script setup lang="ts">
|
|
233
|
-
* import { useFormNode } from "@bonsae/nrg/client";
|
|
234
|
-
* import type { ConfigsSchema, CredentialsSchema } from "../../server/schemas/my-node";
|
|
235
|
-
*
|
|
236
|
-
* const { node, errors } = useFormNode<typeof ConfigsSchema, typeof CredentialsSchema>();
|
|
237
|
-
* node.name // string — typed from ConfigsSchema
|
|
238
|
-
* node.credentials.apiKey // string — typed from CredentialsSchema
|
|
239
|
-
* </script>
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): FormNode<TConfig, TCredentials>;
|
|
243
107
|
export interface TestNode {
|
|
244
108
|
id: string;
|
|
245
109
|
type: string;
|
|
@@ -85,12 +85,6 @@ export interface SetupOptions {
|
|
|
85
85
|
settingsFile?: string;
|
|
86
86
|
flow?: Record<string, unknown>[];
|
|
87
87
|
}
|
|
88
|
-
export declare const defaultConfig: {
|
|
89
|
-
testTimeout: number;
|
|
90
|
-
hookTimeout: number;
|
|
91
|
-
globalSetup: string[];
|
|
92
|
-
include: string[];
|
|
93
|
-
};
|
|
94
88
|
export declare function setup(options?: SetupOptions): Promise<void>;
|
|
95
89
|
export declare function teardown(): Promise<void>;
|
|
96
90
|
export declare class NodeRedEditor {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { App } from 'vue';
|
|
3
|
+
import { TSchema } from '@sinclair/typebox';
|
|
5
4
|
|
|
6
5
|
export interface MockEditor {
|
|
7
6
|
getValue(): string;
|
|
@@ -96,111 +95,18 @@ export interface MockRED {
|
|
|
96
95
|
notify(message: any, options?: Record<string, any>): MockNotification;
|
|
97
96
|
}
|
|
98
97
|
export declare function createRED(): MockRED;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
interface MockJQueryElement {
|
|
99
|
+
0: Element | null;
|
|
100
|
+
length: number;
|
|
101
|
+
[method: string]: any;
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
interface NodeRedNodeButtonDefinition {
|
|
110
|
-
toggle: string;
|
|
111
|
-
onclick: () => void;
|
|
112
|
-
enabled?: () => boolean;
|
|
113
|
-
visible?: () => boolean;
|
|
114
|
-
}
|
|
115
|
-
interface NodeRedNode {
|
|
116
|
-
id: string;
|
|
117
|
-
type: string;
|
|
118
|
-
name: string;
|
|
119
|
-
category: string;
|
|
120
|
-
x: string;
|
|
121
|
-
y: string;
|
|
122
|
-
g: string;
|
|
123
|
-
z: string;
|
|
124
|
-
credentials: Record<string, any>;
|
|
125
|
-
_def: {
|
|
126
|
-
defaults: Record<string, {
|
|
127
|
-
value: string;
|
|
128
|
-
type?: string;
|
|
129
|
-
label?: string;
|
|
130
|
-
required?: boolean;
|
|
131
|
-
}>;
|
|
132
|
-
credentials: Record<string, {
|
|
133
|
-
value: string;
|
|
134
|
-
type?: "password" | "text";
|
|
135
|
-
label?: string;
|
|
136
|
-
required?: boolean;
|
|
137
|
-
}>;
|
|
138
|
-
category: string;
|
|
139
|
-
color?: string;
|
|
140
|
-
icon?: string;
|
|
141
|
-
label?: ((this: NodeRedNode) => string) | string;
|
|
142
|
-
inputs?: number;
|
|
143
|
-
outputs?: number;
|
|
144
|
-
paletteLabel?: ((this: NodeRedNode) => string) | string;
|
|
145
|
-
labelStyle?: ((this: NodeRedNode) => string) | string;
|
|
146
|
-
inputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
147
|
-
outputLabels?: ((this: NodeRedNode, index: number) => string) | string;
|
|
148
|
-
align?: "left" | "right";
|
|
149
|
-
button?: NodeRedNodeButtonDefinition;
|
|
150
|
-
};
|
|
151
|
-
_newState?: NodeRedNode;
|
|
152
|
-
_app?: App | null;
|
|
153
|
-
_: (str: string) => string;
|
|
154
|
-
/** dynamic port count (base outputs + enabled built-in ports) */
|
|
155
|
-
outputs?: number;
|
|
156
|
-
/** injected when the node has an inputSchema */
|
|
157
|
-
validateInput?: boolean;
|
|
158
|
-
/** built-in port toggles, present when declared in the configSchema */
|
|
159
|
-
errorPort?: boolean;
|
|
160
|
-
completePort?: boolean;
|
|
161
|
-
statusPort?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Per-port output settings, indexed by base-output port. `validateOutputs` is
|
|
164
|
-
* injected (empty) when the node has an outputsSchema; `outputReturnProperties`
|
|
165
|
-
* and `outputContextModes` are author-declared (SchemaType.*) — present only
|
|
166
|
-
* when the node opts into per-port return keys / context modes. Read at
|
|
167
|
-
* runtime by IONode.
|
|
168
|
-
*/
|
|
169
|
-
validateOutputs?: Record<number, boolean>;
|
|
170
|
-
outputContextModes?: Record<number, "carry" | "trace" | "reset">;
|
|
171
|
-
outputReturnProperties?: Record<number, string>;
|
|
172
|
-
[key: string]: any;
|
|
173
|
-
}
|
|
174
|
-
interface TypedInputValue {
|
|
175
|
-
value: string;
|
|
176
|
-
type: string;
|
|
177
|
-
}
|
|
178
|
-
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 ? {
|
|
179
|
-
[K in keyof T]: EditorStatic<T[K]>;
|
|
180
|
-
} : T;
|
|
181
|
-
interface FormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema> {
|
|
182
|
-
node: NodeRedNode & EditorStatic<Static<TConfig>> & {
|
|
183
|
-
credentials: EditorStatic<Static<TCredentials>> & Record<string, any>;
|
|
184
|
-
};
|
|
103
|
+
type MockJQuery = (selector: any, attrs?: Record<string, any>) => MockJQueryElement;
|
|
104
|
+
/** Build the `$` function the test harness assigns to `window.$`. */
|
|
105
|
+
export declare function createJQuery(): MockJQuery;
|
|
106
|
+
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): {
|
|
107
|
+
node: Record<string, any>;
|
|
185
108
|
schema: Record<string, any>;
|
|
186
109
|
errors: Record<string, string>;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Composable that provides typed access to the form node, schema, and errors.
|
|
190
|
-
* Replaces `defineProps` in custom form components — no props declaration needed.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```vue
|
|
194
|
-
* <script setup lang="ts">
|
|
195
|
-
* import { useFormNode } from "@bonsae/nrg/client";
|
|
196
|
-
* import type { ConfigsSchema, CredentialsSchema } from "../../server/schemas/my-node";
|
|
197
|
-
*
|
|
198
|
-
* const { node, errors } = useFormNode<typeof ConfigsSchema, typeof CredentialsSchema>();
|
|
199
|
-
* node.name // string — typed from ConfigsSchema
|
|
200
|
-
* node.credentials.apiKey // string — typed from CredentialsSchema
|
|
201
|
-
* </script>
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
export declare function useFormNode<TConfig extends TSchema = TSchema, TCredentials extends TSchema = TSchema>(): FormNode<TConfig, TCredentials>;
|
|
110
|
+
};
|
|
205
111
|
|
|
206
112
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Static, TObject, TOptional, TProperties, TSchema, TString } from '@sinclair/typebox';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { Express as Express$1 } from 'express';
|
|
6
5
|
import { Http2ServerRequest } from 'http2';
|
|
7
6
|
|
|
8
7
|
interface NodeRedRuntimeSettings {
|
|
@@ -202,6 +201,68 @@ declare const NodeConfigSchema: import("@sinclair/typebox").TObject<{
|
|
|
202
201
|
name: import("@sinclair/typebox").TString;
|
|
203
202
|
z: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
204
203
|
}>;
|
|
204
|
+
type Schema<T extends TProperties = TProperties> = TObject<T>;
|
|
205
|
+
interface NodeContextStore {
|
|
206
|
+
get<T = any>(key: string): Promise<T>;
|
|
207
|
+
set<T = any>(key: string, value: T): Promise<void>;
|
|
208
|
+
keys(): Promise<string[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Atomically add `by` (default 1) to a numeric key and return the new value.
|
|
211
|
+
* Prefer this over `get`+`set` for counters: it's atomic across instances when
|
|
212
|
+
* the context store supports it (e.g. a DynamoDB `ADD` or Redis `INCR` store),
|
|
213
|
+
* and serialized within the process otherwise — so concurrent messages never
|
|
214
|
+
* lose updates.
|
|
215
|
+
*/
|
|
216
|
+
increment(key: string, by?: number): Promise<number>;
|
|
217
|
+
/**
|
|
218
|
+
* Atomic read-modify-write: `fn(current)` returns the next value, applied
|
|
219
|
+
* atomically (a conditional write + retry on a capable store, a per-key lock
|
|
220
|
+
* otherwise). `fn` MAY run more than once on a write conflict, so keep it pure
|
|
221
|
+
* (no side effects).
|
|
222
|
+
*/
|
|
223
|
+
update<T = any>(key: string, fn: (current: T) => T | Promise<T>): Promise<T>;
|
|
224
|
+
}
|
|
225
|
+
interface NodeConstructor<T = any, TConfig = any, TCredentials = any> {
|
|
226
|
+
readonly type: string;
|
|
227
|
+
readonly category: string;
|
|
228
|
+
readonly color?: string;
|
|
229
|
+
readonly align?: "left" | "right";
|
|
230
|
+
readonly inputs?: number;
|
|
231
|
+
readonly outputs?: number;
|
|
232
|
+
readonly configSchema?: Schema;
|
|
233
|
+
readonly credentialsSchema?: Schema;
|
|
234
|
+
readonly settingsSchema?: Schema;
|
|
235
|
+
readonly inputSchema?: Schema;
|
|
236
|
+
readonly outputsSchema?: TSchema | TSchema[] | Record<string, TSchema>;
|
|
237
|
+
readonly validateInput?: boolean;
|
|
238
|
+
readonly validateOutput?: boolean;
|
|
239
|
+
readonly name: string;
|
|
240
|
+
registered?(RED: RED): void | Promise<void>;
|
|
241
|
+
register(RED: RED): void | Promise<void>;
|
|
242
|
+
validateSettings(RED: RED): void;
|
|
243
|
+
new (RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>): T;
|
|
244
|
+
}
|
|
245
|
+
type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
|
|
246
|
+
type NodeCredentials<TCredentials = any> = TCredentials;
|
|
247
|
+
interface INode<TConfig = any, TCredentials = any, TSettings = any> {
|
|
248
|
+
readonly config: NodeConfig<TConfig>;
|
|
249
|
+
readonly id: string;
|
|
250
|
+
readonly name: string | undefined;
|
|
251
|
+
readonly z: string | undefined;
|
|
252
|
+
readonly credentials: NodeCredentials<TCredentials> | undefined;
|
|
253
|
+
readonly settings: TSettings;
|
|
254
|
+
i18n(key: string, substitutions?: Record<string, string>): string;
|
|
255
|
+
setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
|
|
256
|
+
setInterval(fn: () => void, ms: number): NodeJS.Timeout;
|
|
257
|
+
clearTimeout(timer: NodeJS.Timeout): void;
|
|
258
|
+
clearInterval(interval: NodeJS.Timeout): void;
|
|
259
|
+
on(event: string, callback: (...args: any[]) => void): void;
|
|
260
|
+
log(msg: any): void;
|
|
261
|
+
warn(message: string): void;
|
|
262
|
+
error(message: string, msg?: any): void;
|
|
263
|
+
created?(): void | Promise<void>;
|
|
264
|
+
closed?(removed?: boolean): void | Promise<void>;
|
|
265
|
+
}
|
|
205
266
|
interface NodeRedLog {
|
|
206
267
|
info(msg: any): void;
|
|
207
268
|
warn(msg: any): void;
|
|
@@ -330,53 +391,16 @@ interface NodeRedContextStore {
|
|
|
330
391
|
get(key: string, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
331
392
|
set(key: string, value: any, store: string | undefined, callback: (err: Error | null) => void): void;
|
|
332
393
|
keys(store: string | undefined, callback: (err: Error | null, keys: string[]) => void): void;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
readonly color?: string;
|
|
344
|
-
readonly align?: "left" | "right";
|
|
345
|
-
readonly inputs?: number;
|
|
346
|
-
readonly outputs?: number;
|
|
347
|
-
readonly configSchema?: Schema;
|
|
348
|
-
readonly credentialsSchema?: Schema;
|
|
349
|
-
readonly settingsSchema?: Schema;
|
|
350
|
-
readonly inputSchema?: Schema;
|
|
351
|
-
readonly outputsSchema?: TSchema | TSchema[] | Record<string, TSchema>;
|
|
352
|
-
readonly validateInput?: boolean;
|
|
353
|
-
readonly validateOutput?: boolean;
|
|
354
|
-
readonly name: string;
|
|
355
|
-
registered?(RED: RED): void | Promise<void>;
|
|
356
|
-
register(RED: RED): void | Promise<void>;
|
|
357
|
-
validateSettings(RED: RED): void;
|
|
358
|
-
new (RED: RED, node: NodeRedNode, config: NodeConfig<TConfig>, credentials: NodeCredentials<TCredentials>): T;
|
|
359
|
-
}
|
|
360
|
-
type NodeConfig<TConfig = any> = TConfig & Static<typeof NodeConfigSchema>;
|
|
361
|
-
type NodeCredentials<TCredentials = any> = TCredentials;
|
|
362
|
-
interface INode<TConfig = any, TCredentials = any, TSettings = any> {
|
|
363
|
-
readonly config: NodeConfig<TConfig>;
|
|
364
|
-
readonly id: string;
|
|
365
|
-
readonly name: string | undefined;
|
|
366
|
-
readonly z: string | undefined;
|
|
367
|
-
readonly credentials: NodeCredentials<TCredentials> | undefined;
|
|
368
|
-
readonly settings: TSettings;
|
|
369
|
-
i18n(key: string, substitutions?: Record<string, string>): string;
|
|
370
|
-
setTimeout(fn: () => void, ms: number): NodeJS.Timeout;
|
|
371
|
-
setInterval(fn: () => void, ms: number): NodeJS.Timeout;
|
|
372
|
-
clearTimeout(timer: NodeJS.Timeout): void;
|
|
373
|
-
clearInterval(interval: NodeJS.Timeout): void;
|
|
374
|
-
on(event: string, callback: (...args: any[]) => void): void;
|
|
375
|
-
log(msg: any): void;
|
|
376
|
-
warn(message: string): void;
|
|
377
|
-
error(message: string, msg?: any): void;
|
|
378
|
-
created?(): void | Promise<void>;
|
|
379
|
-
closed?(removed?: boolean): void | Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Optional atomic add — provided by context stores that support it (e.g.
|
|
396
|
+
* DynamoDB `ADD` / Redis `INCR`). When absent, nrg serializes in-process.
|
|
397
|
+
*/
|
|
398
|
+
increment?(key: string, by: number, store: string | undefined, callback: (err: Error | null, value: number) => void): void;
|
|
399
|
+
/**
|
|
400
|
+
* Optional atomic read-modify-write — provided by stores that support it
|
|
401
|
+
* (e.g. a DynamoDB conditional write). When absent, nrg serializes in-process.
|
|
402
|
+
*/
|
|
403
|
+
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
380
404
|
}
|
|
381
405
|
type Channel = "sent" | "received";
|
|
382
406
|
declare class Recorder {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Static, TObject, TOptional, TProperties, TSchema, TString } from '@sinclair/typebox';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { Express as Express$1 } from 'express';
|
|
6
5
|
import { Http2ServerRequest } from 'http2';
|
|
7
6
|
|
|
8
7
|
interface NodeRedRuntimeSettings {
|
|
@@ -207,6 +206,21 @@ interface NodeContextStore {
|
|
|
207
206
|
get<T = any>(key: string): Promise<T>;
|
|
208
207
|
set<T = any>(key: string, value: T): Promise<void>;
|
|
209
208
|
keys(): Promise<string[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Atomically add `by` (default 1) to a numeric key and return the new value.
|
|
211
|
+
* Prefer this over `get`+`set` for counters: it's atomic across instances when
|
|
212
|
+
* the context store supports it (e.g. a DynamoDB `ADD` or Redis `INCR` store),
|
|
213
|
+
* and serialized within the process otherwise — so concurrent messages never
|
|
214
|
+
* lose updates.
|
|
215
|
+
*/
|
|
216
|
+
increment(key: string, by?: number): Promise<number>;
|
|
217
|
+
/**
|
|
218
|
+
* Atomic read-modify-write: `fn(current)` returns the next value, applied
|
|
219
|
+
* atomically (a conditional write + retry on a capable store, a per-key lock
|
|
220
|
+
* otherwise). `fn` MAY run more than once on a write conflict, so keep it pure
|
|
221
|
+
* (no side effects).
|
|
222
|
+
*/
|
|
223
|
+
update<T = any>(key: string, fn: (current: T) => T | Promise<T>): Promise<T>;
|
|
210
224
|
}
|
|
211
225
|
interface NodeConstructor<T = any, TConfig = any, TCredentials = any> {
|
|
212
226
|
readonly type: string;
|
|
@@ -377,6 +391,16 @@ interface NodeRedContextStore {
|
|
|
377
391
|
get(key: string, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
378
392
|
set(key: string, value: any, store: string | undefined, callback: (err: Error | null) => void): void;
|
|
379
393
|
keys(store: string | undefined, callback: (err: Error | null, keys: string[]) => void): void;
|
|
394
|
+
/**
|
|
395
|
+
* Optional atomic add — provided by context stores that support it (e.g.
|
|
396
|
+
* DynamoDB `ADD` / Redis `INCR`). When absent, nrg serializes in-process.
|
|
397
|
+
*/
|
|
398
|
+
increment?(key: string, by: number, store: string | undefined, callback: (err: Error | null, value: number) => void): void;
|
|
399
|
+
/**
|
|
400
|
+
* Optional atomic read-modify-write — provided by stores that support it
|
|
401
|
+
* (e.g. a DynamoDB conditional write). When absent, nrg serializes in-process.
|
|
402
|
+
*/
|
|
403
|
+
update?(key: string, fn: (current: any) => any, store: string | undefined, callback: (err: Error | null, value: any) => void): void;
|
|
380
404
|
}
|
|
381
405
|
export interface MockRED extends RED {
|
|
382
406
|
registerNode(id: string, nodeRedNode: Partial<NodeRedNode>): void;
|
package/types/vite.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface BuildContext {
|
|
|
4
4
|
outDir: string;
|
|
5
5
|
packageName: string;
|
|
6
6
|
isDev: boolean;
|
|
7
|
+
/** Resolved server source dir, scanned to recover `Unsafe<T>()` types for docs. */
|
|
8
|
+
serverSrcDir?: string;
|
|
7
9
|
}
|
|
8
10
|
export interface BuildPluginOptions {
|
|
9
11
|
serverBuildOptions: ServerBuildOptions;
|