import type { NodeAPI, NodeStatus, Node as NRNode } from 'node-red'; import type { Node } from './node'; import type { NodeMessage } from './types'; export type DoneCb = (err?: Error) => void; export type SentMessage = NodeMessage | (NodeMessage | null)[]; /** * Interface to separate our nodes from Node Red APIs */ export interface Api { send(msg: SentMessage): void; error(log: string): void; log(log: string): void; warn(log: string): void; on(event: 'input', cb: (msg: NodeMessage, done: DoneCb) => void): void; on(event: 'close', cb: (done: VoidFunction) => void): void; status(status: string | NodeStatus): void; getNode new (...args: any[]) => Node>(id: string): InstanceType> | undefined; findNodeIdByType(type: string): string | undefined; /** * Due to how bamboozled node initialization flow is we need to create copy of API * in each Node instance */ cloneAndInstantiate(node: Node, config: any): Api; } export declare class NodeRedApi implements Api { protected RED: NodeAPI; protected instance: { node: NRNode; config: any; } | null; constructor(RED: NodeAPI, instance?: { node: NRNode; config: any; } | null); cloneAndInstantiate(node: Node, config: any): NodeRedApi; send(msg: SentMessage): void; error(log: string): void; log(log: string): void; warn(log: string): void; findNodeIdByType(type: string): string | undefined; getNode>(id: string): T | undefined; on(event: 'input', cb: (msg: NodeMessage, done: DoneCb) => void): void; on(event: 'close', cb: (done: VoidFunction) => void): void; status(status: string | NodeStatus): void; }