<?php

declare(strict_types=1);

namespace App\Administration\Domain\Event;

use App\Shared\Domain\DomainEvent;
use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
 * Événement émis lorsque toutes les sessions (sauf courante) sont invalidées.
 *
 * @see Story 1.6 - Gestion des sessions
 */
final readonly class ToutesSessionsInvalidees implements DomainEvent
{
    /**
     * @param list<string> $invalidatedFamilyIds Les IDs des familles de tokens invalidées
     */
    public function __construct(
        public string $userId,
        public array $invalidatedFamilyIds,
        public string $exceptFamilyId,
        public TenantId $tenantId,
        public string $ipAddress,
        public string $userAgent,
        public DateTimeImmutable $occurredOn,
    ) {
    }

    public function occurredOn(): DateTimeImmutable
    {
        return $this->occurredOn;
    }

    public function aggregateId(): UuidInterface
    {
        return Uuid::fromString($this->userId);
    }
}
