// src/nodes/baseNode.ts
import { INodeContext, NodeStatus, IExecutionRecord } from '../types/runtime';
import { NodeMetadata } from '../types/config';

export abstract class BaseNode {
  abstract readonly metadata: NodeMetadata;

  /**
   * Core execution logic for the node.
   * Implementers should focus on the business task.
   * State changes (output, variables) should ideally happen via INodeContext helpers.
   */
  abstract execute(context: INodeContext): Promise<void>; // No return value needed, manipulate context directly

  /**
   * Optional: Validate input before execution.
   * Throw ConfigurationError for invalid input.
   */
  validate?(context: INodeContext): Promise<void> | void;

  /**
   * Optional: Compensation logic if the node's action needs to be undone.
   * Called by the engine during failure/rollback scenarios.
   */
  compensate?(context: INodeContext): Promise<void>;

  /**
   * Optional: Specify required roles for execution. Checked by the engine.
   */
  get requiredRoles(): string[] | undefined {
      return undefined;
  }
}