package events

import "time"

type RepoEvent struct {
	RepoID    int64     `json:"repoId"`
	RepoName  string    `json:"repoName"`
	OwnerID   int64     `json:"ownerId"`
	OwnerName string    `json:"ownerName"`
	ActorID   int64     `json:"actorId"`
	ActorName string    `json:"actorName"`
	At        time.Time `json:"at"`
}

type PushEvent struct {
	RepoID    int64     `json:"repoId"`
	RepoName  string    `json:"repoName"`
	OwnerName string    `json:"ownerName"`
	Ref       string    `json:"ref"`
	Before    string    `json:"before"`
	After     string    `json:"after"`
	Pusher    string    `json:"pusher"`
	At        time.Time `json:"at"`
}

type PREvent struct {
	PRID         int64     `json:"prId"`
	RepoID       int64     `json:"repoId"`
	RepoName     string    `json:"repoName"`
	OwnerName    string    `json:"ownerName"`
	Title        string    `json:"title"`
	SourceBranch string    `json:"sourceBranch"`
	TargetBranch string    `json:"targetBranch"`
	AuthorID     int64     `json:"authorId"`
	AuthorName   string    `json:"authorName"`
	At           time.Time `json:"at"`
}

type IssueEvent struct {
	IssueID   int64     `json:"issueId"`
	RepoID    int64     `json:"repoId"`
	RepoName  string    `json:"repoName"`
	OwnerName string    `json:"ownerName"`
	Title     string    `json:"title"`
	AuthorID  int64     `json:"authorId"`
	At        time.Time `json:"at"`
}

type AuditEvent struct {
	ActorID      int64     `json:"actorId"`
	ActorName    string    `json:"actorName"`
	Action       string    `json:"action"`
	ResourceType string    `json:"resourceType"`
	ResourcePath string    `json:"resourcePath"`
	IPAddress    string    `json:"ipAddress"`
	StatusCode   int       `json:"statusCode"`
	At           time.Time `json:"at"`
}

type PipelineEvent struct {
	RunID  int64     `json:"runId"`
	RepoID int64     `json:"repoId"`
	Status string    `json:"status"`
	At     time.Time `json:"at"`
}

type JobEvent struct {
	RunID  int64     `json:"runId"`
	JobID  int64     `json:"jobId"`
	Status string    `json:"status"`
	At     time.Time `json:"at"`
}

type LogChunkEvent struct {
	RunID      int64  `json:"runId"`
	JobID      int64  `json:"jobId"`
	StepID     int64  `json:"stepId"`
	ChunkIndex int    `json:"chunkIndex"`
	Content    string `json:"content"`
}

// WSEnvelope wraps any event for delivery over the WebSocket connection.
type WSEnvelope struct {
	Subject string `json:"subject"`
	Payload []byte `json:"payload"`
}
