import type { BlockOutput, IBlock, IFullBlocksClient, ITarget, ITrigger, IBlocksNode, IMutableNode } from '../types/index.ts'; import type { IMQTTConnection } from '@hass-blocks/hass-mqtt'; import type { IRunContext } from '../types/index.ts'; /** * @public * * The core Hass Blocks abstraction! - all Blocks must extend from this class for * the framework to be able to execute them */ export declare abstract class Block implements IBlock, IMutableNode { /** * String to identify this particular instance of a block. Must be unique */ readonly id: string; private targets; /** * All child nodes of this block */ private _trigger?; /** * Child nodes */ readonly children: IMutableNode[]; constructor( /** * String to identify this particular instance of a block. Must be unique */ id: string, targets: ITarget[] | undefined, /** * All child nodes of this block */ _trigger?: (ITrigger | ITrigger[]) | undefined); /** * Add a child node * * @param node - node to be added */ addChild(...node: IMutableNode[]): void; /** * Returns true if this node has a trigger attached */ protected hasTrigger(): boolean; /** * A JSON representation of the block. Used for websocket and rest serialisation */ toJson(): IBlocksNode; /** * Adds the next sequence node. The default implementation * simply adds the node as a child of this node, however * subclasses can override this to ensure that any children they need * to connect up in between are connected * * @param node - node to be added */ addNext(node?: IMutableNode): void; /** * Triggers that are currently registered with this block */ get trigger(): ITrigger | ITrigger[]; set trigger(trigger: ITrigger | ITrigger[]); /** * Friendly name for the block - for use in user interfaces */ abstract readonly name: string; /** * If defined, this method will be called when the parent automation is registered. * If any configuration is invalid, an error should be thrown */ initialise(client: IFullBlocksClient, mqtt: IMQTTConnection): Promise; /** * Iterate through a sequence of nodes and connect them together * * @param nodes - the nodes to link */ linkNodes(...nodes: IMutableNode[]): void; /** * String that identifies the kind of block */ abstract readonly type: string; /** * Called by the framework when the block is executed * * @param client - An initialised blocks client, * @param input - The input for this block - usually the output from the last one * @param events - An initialised event bus * @param triggerId - a uuid trigger id, unique to this particular trigger sequence */ abstract run(context: IRunContext): Promise> | BlockOutput; } //# sourceMappingURL=block.d.ts.map