/**
 * Transform Step — map/reshape payload fields into context variables.
 * Config: { mappings: { key: "{{trigger.field}}" } }
 * Template variables are already resolved by the engine before this runs.
 */

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

async function executeTransform(
  step: PipelineStep,
  _context: PipelineContext,
  _executionId: number
): Promise<StepExecutorResult> {
  const mappings = step.config.mappings || {};

  // Config values are already template-resolved by the engine,
  // so we just pass them through as context output.
  return { success: true, output: mappings };
}

registerStepExecutor('transform', executeTransform);
