/**
 * Set Variable Step — set a single context variable.
 * Config: { key: "my_var", value: "{{trigger.something}}" }
 */

import { registerStepExecutor } from '../pipeline-engine';
import { PipelineStep, PipelineContext, StepExecutorResult } from '../../types/pipeline';

async function executeSetVariable(
  step: PipelineStep,
  _context: PipelineContext,
  _executionId: number
): Promise<StepExecutorResult> {
  const { key, value } = step.config;

  if (!key) {
    return { success: false, error: 'Missing "key" in set_variable config' };
  }

  return { success: true, output: { [key]: value } };
}

registerStepExecutor('set_variable', executeSetVariable);
