@bonsae/nrg 0.6.2 → 0.7.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/types/server.d.ts CHANGED
@@ -2183,6 +2183,20 @@ export type InferOutputs<T> = T extends readonly TSchema[] ? {
2183
2183
  } : T extends TSchema ? Static<T> : any;
2184
2184
  export type BoundIONode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined, TIn extends TSchema | undefined, TOut extends TSchema | readonly TSchema[] | undefined> = IONode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TIn, any>, InferOutputs<TOut>, InferOr<TS, any>>;
2185
2185
  export type BoundConfigNode<TC extends TSchema | undefined, TCr extends TSchema | undefined, TS extends TSchema | undefined> = ConfigNode<InferOr<TC, any>, InferOr<TCr, any>, InferOr<TS, any>>;
2186
+ export interface ConfigNodeInstance<TConfig = any, TCredentials = any> {
2187
+ readonly config: ConfigNodeConfig<TConfig>;
2188
+ readonly credentials: ConfigNodeCredentials<TCredentials> | undefined;
2189
+ readonly id: string;
2190
+ readonly name: string | undefined;
2191
+ }
2192
+ export interface IONodeInstance<TConfig = any, TCredentials = any, TInput = any, TOutput = any> {
2193
+ readonly config: IONodeConfig<TConfig>;
2194
+ readonly credentials: IONodeCredentials<TCredentials> | undefined;
2195
+ readonly id: string;
2196
+ readonly name: string | undefined;
2197
+ input(msg: TInput): void | Promise<void>;
2198
+ send(msg: TOutput): void;
2199
+ }
2186
2200
  export interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined> {
2187
2201
  type: string;
2188
2202
  category?: string;
@@ -2215,10 +2229,10 @@ export interface ConfigNodeDefinition<TConfigSchema extends TSchema | undefined
2215
2229
  created?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>): void | Promise<void>;
2216
2230
  closed?(this: BoundConfigNode<TConfigSchema, TCredsSchema, TSettingsSchema>, removed?: boolean): void | Promise<void>;
2217
2231
  }
2218
- export interface NodeClassBase {
2232
+ export interface NodeClassBase<TInstance = unknown> {
2219
2233
  readonly type: string;
2220
2234
  readonly category: string;
2221
- new (...args: any[]): any;
2235
+ new (...args: any[]): TInstance;
2222
2236
  }
2223
2237
  declare abstract class Node$1<TConfig = any, TCredentials = any, TSettings = any> {
2224
2238
  static readonly type: string;
@@ -2254,12 +2268,12 @@ declare abstract class Node$1<TConfig = any, TCredentials = any, TSettings = any
2254
2268
  get credentials(): NodeCredentials<TCredentials> | undefined;
2255
2269
  get settings(): TSettings;
2256
2270
  }
2257
- export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeClassBase;
2258
- export declare function defineConfigNode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined>(def: ConfigNodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema>): NodeClassBase;
2271
+ export declare function defineIONode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined, TInputSchema extends TSchema | undefined = undefined, TOutputsSchema extends TSchema | readonly TSchema[] | undefined = undefined>(def: IONodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): NodeClassBase<IONodeInstance<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>, InferOr<TInputSchema, any>, InferOutputs<TOutputsSchema>>>;
2272
+ export declare function defineConfigNode<TConfigSchema extends TSchema | undefined = undefined, TCredsSchema extends TSchema | undefined = undefined, TSettingsSchema extends TSchema | undefined = undefined>(def: ConfigNodeDefinition<TConfigSchema, TCredsSchema, TSettingsSchema>): NodeClassBase<ConfigNodeInstance<InferOr<TConfigSchema, any>, InferOr<TCredsSchema, any>>>;
2259
2273
  export declare class NrgError extends Error {
2260
2274
  constructor(message: string);
2261
2275
  }
2262
- export type AnyNodeClass = (abstract new (...args: any[]) => Node$1) & Partial<typeof Node$1>;
2276
+ export type AnyNodeClass = ((abstract new (...args: any[]) => Node$1) & Partial<typeof Node$1>) | NodeClassBase<any>;
2263
2277
  /**
2264
2278
  * Registers a custom node with Node-RED.
2265
2279
  *