<?php

declare(strict_types=1);

namespace Drupal\flowdrop_runtime\Event;

use Drupal\flowdrop_runtime\DTO\Runtime\NodeExecutionContext;
use Drupal\flowdrop_orchestration\DTO\Snapshot\WorkflowSnapshot;
use Symfony\Contracts\EventDispatcher\Event;

/**
 * Event dispatched when a workflow execution completes.
 *
 * @internal
 */
class WorkflowCompletedEvent extends Event {

  /**
   * The event name.
   */
  const NAME = 'flowdrop.workflow.completed';

  /**
   * Constructs a new WorkflowCompletedEvent.
   *
   * @param array $workflowData
   *   The workflow data array.
   * @param string $executionId
   *   The execution ID.
   * @param string $workflowId
   *   The workflow ID.
   * @param array $results
   *   Map of node ID to execution results.
   * @param array $skippedNodes
   *   Array of skipped node IDs.
   * @param float $executionTime
   *   The total execution time.
   * @param \Drupal\flowdrop_runtime\DTO\Runtime\NodeExecutionContext $context
   *   The execution context.
   * @param \Drupal\flowdrop_orchestration\DTO\Snapshot\WorkflowSnapshot|null $snapshot
   *   The workflow snapshot, if available.
   */
  public function __construct(
    public readonly array $workflowData,
    public readonly string $executionId,
    public readonly string $workflowId,
    public readonly array $results,
    public readonly array $skippedNodes,
    public readonly float $executionTime,
    public readonly NodeExecutionContext $context,
    public readonly ?WorkflowSnapshot $snapshot = NULL,
  ) {}

}
