<?php

declare(strict_types=1);

namespace Drupal\native_observability_eca_bridge\Eca;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\native_observability\Event\NativeObservabilityEvents;
use Drupal\native_observability\Event\TraceRecordedEvent;
use Drupal\native_observability\Event\TracesDeletedEvent;

/**
 * Provides Native Observability ECA event definition metadata.
 *
 * This class intentionally does not extend ECA plugin base classes, so the
 * event definition contract can be unit-tested in environments where the
 * optional ECA runtime is not installed.
 */
final class NativeObservabilityEventDefinitions {

  /**
   * Returns the set of event variants exposed by the ECA plugin.
   *
   * @return array<string, array<string, mixed>>
   *   Keyed by derivative ID; each value is an ECA event definition array.
   */
  public static function definitions(): array {
    return [
      'trace_recorded' => [
        'label' => new TranslatableMarkup('Trace recorded'),
        'description' => new TranslatableMarkup('Fires after every HTTP request trace is persisted to the database.'),
        'event_name' => NativeObservabilityEvents::TRACE_RECORDED,
        'event_class' => TraceRecordedEvent::class,
        'version_introduced' => '1.0.0',
      ],
      'traces_deleted' => [
        'label' => new TranslatableMarkup('Traces deleted'),
        'description' => new TranslatableMarkup('Fires after all traces have been bulk-deleted.'),
        'event_name' => NativeObservabilityEvents::TRACES_DELETED,
        'event_class' => TracesDeletedEvent::class,
        'version_introduced' => '1.0.0',
      ],
    ];
  }

}
