package com.correx.testing.fixtures

import com.correx.core.events.events.EventMetadata
import com.correx.core.events.events.EventPayload
import com.correx.core.events.events.NewEvent
import com.correx.core.events.events.StoredEvent
import com.correx.core.events.events.ToolInvokedEvent
import com.correx.core.events.types.EventId
import com.correx.core.events.types.SessionId
import kotlinx.datetime.Instant

object EventFixtures {
    fun newEvent(
        eventId: EventId,
        sessionId: SessionId = SessionId("s1"),
        payload: EventPayload = ToolInvokedEvent("write"),
        timestamp: Instant = Instant.parse("2026-01-01T00:00:00Z")
    ): NewEvent {
        return NewEvent(
            metadata = EventMetadata(
                eventId = eventId,
                sessionId = sessionId,
                timestamp = timestamp,
                schemaVersion = 1,
                causationId = null,
                correlationId = null
            ),
            payload = payload
        )
    }

    fun stored(
        eventId: EventId = EventId("e1"),
        payload: EventPayload = ToolInvokedEvent("write"),
        sessionId: SessionId = SessionId("s1"),
        sequence: Long = 1L,
        sessionSequence: Long = sequence,
        timestamp: Instant = Instant.parse("2026-01-01T00:00:00Z")
    ): StoredEvent {
        return StoredEvent(
            metadata = EventMetadata(
                eventId = eventId,
                sessionId = sessionId,
                timestamp = timestamp,
                schemaVersion = 1,
                causationId = null,
                correlationId = null
            ),
            sequence = sequence,
            sessionSequence = sessionSequence,
            payload = payload
        )
    }
}
