package metadata

import "time"

const EventVersionV1 = "v1"

// Envelope is the common metadata present on every stream event.
type Envelope struct {
	EventID      string    `json:"event_id"`
	EventVersion string    `json:"event_version"`
	CreatedAt    time.Time `json:"created_at"`
	TraceID      string    `json:"trace_id,omitempty"`
	SpanID       string    `json:"span_id,omitempty"`
}

// NewEnvelope creates a v1 envelope with the given event ID and current UTC timestamp.
func NewEnvelope(eventID string) Envelope {
	return Envelope{
		EventID:      eventID,
		EventVersion: EventVersionV1,
		CreatedAt:    time.Now().UTC(),
	}
}
