package admin

import "time"

type User struct {
	ID          string     `json:"id"`
	Username    string     `json:"username"`
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   time.Time  `json:"updatedAt"`
	LastLoginAt *time.Time `json:"lastLoginAt"`
}

type PostStatus string

const (
	PostStatusDraft     PostStatus = "draft"
	PostStatusPublished PostStatus = "published"
	PostStatusArchived  PostStatus = "archived"
	PostStatusDeleted   PostStatus = "deleted"
)

type VersionReason string

const (
	VersionReasonSave      VersionReason = "save"
	VersionReasonPublish   VersionReason = "publish"
	VersionReasonUnpublish VersionReason = "unpublish"
	VersionReasonArchive   VersionReason = "archive"
	VersionReasonRestore   VersionReason = "restore"
	VersionReasonImport    VersionReason = "import"
	VersionReasonRollback  VersionReason = "rollback"
)

type BuildJobTrigger string

const (
	BuildJobTriggerPublish BuildJobTrigger = "publish"
	BuildJobTriggerManual  BuildJobTrigger = "manual"
	BuildJobTriggerImport  BuildJobTrigger = "import"
	BuildJobTriggerSync    BuildJobTrigger = "sync"
)

type BuildJobStatus string

const (
	BuildJobStatusQueued    BuildJobStatus = "queued"
	BuildJobStatusRunning   BuildJobStatus = "running"
	BuildJobStatusSuccess   BuildJobStatus = "success"
	BuildJobStatusFailed    BuildJobStatus = "failed"
	BuildJobStatusCancelled BuildJobStatus = "cancelled"
)

type Post struct {
	ID           string     `json:"id"`
	Slug         string     `json:"slug"`
	Title        string     `json:"title"`
	Summary      string     `json:"summary"`
	BodyMarkdown string     `json:"bodyMarkdown"`
	Status       PostStatus `json:"status"`
	Tags         []string   `json:"tags"`
	Cover        string     `json:"cover"`
	Version      int        `json:"version"`
	SlugSource   string     `json:"slugSource"`
	SlugLocked   bool       `json:"slugLocked"`
	PublishedAt  *time.Time `json:"publishedAt"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	DeletedAt    *time.Time `json:"deletedAt"`
}

type Tag struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Slug      string    `json:"slug"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type BuildJob struct {
	ID         string          `json:"id"`
	Trigger    BuildJobTrigger `json:"trigger"`
	Status     BuildJobStatus  `json:"status"`
	PostID     *string         `json:"postId"`
	StartedAt  *time.Time      `json:"startedAt"`
	FinishedAt *time.Time      `json:"finishedAt"`
	Log        string          `json:"log"`
	Error      string          `json:"error"`
	CreatedAt  time.Time       `json:"createdAt"`
	CreatedBy  *string         `json:"createdBy"`
}

type AuditLog struct {
	ID            string         `json:"id"`
	ActorID       *string        `json:"actorId"`
	ActorUsername string         `json:"actorUsername"`
	Action        string         `json:"action"`
	ResourceType  string         `json:"resourceType"`
	ResourceID    string         `json:"resourceId"`
	IPAddress     string         `json:"ipAddress"`
	UserAgent     string         `json:"userAgent"`
	Details       map[string]any `json:"details"`
	CreatedAt     time.Time      `json:"createdAt"`
}
