// Package types provides shared types and interfaces.
package types

import "time"

// Document represents an indexed document.
type Document struct {
	ID        string                 `json:"id"`
	Source    string                 `json:"source"`
	Type      string                 `json:"type"`
	Title     string                 `json:"title"`
	Content   string                 `json:"content"`
	URL       string                 `json:"url,omitempty"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	Hash      string                 `json:"hash"`
	Timestamp time.Time              `json:"timestamp"`
}

// Chunk represents a text chunk for indexing.
type Chunk struct {
	ID       string         `json:"id"`
	DocID    string         `json:"doc_id"`
	Content  string         `json:"content"`
	Vector   []float32      `json:"vector,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
	Position int            `json:"position"`
}

// SearchResult represents a search result.
type SearchResult struct {
	ID       string         `json:"id"`
	DocID    string         `json:"doc_id"`
	Content  string         `json:"content"`
	Score    float64        `json:"score"`
	Source   string         `json:"source"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

// Source represents a documentation source.
type Source struct {
	Name        string   `yaml:"name"`
	Type        string   `yaml:"type"`
	URL         string   `yaml:"url,omitempty"`
	Query       string   `yaml:"query,omitempty"`
	ResultLimit int      `yaml:"result_limit,omitempty"`
	Domains     []string `yaml:"domains,omitempty"`
	Repo        string   `yaml:"repo,omitempty"`
	Branch      string   `yaml:"branch,omitempty"`
	Path        string   `yaml:"path,omitempty"`
	Include     []string `yaml:"include,omitempty"`
	Exclude     []string `yaml:"exclude,omitempty"`
	Schedule    string   `yaml:"schedule,omitempty"`
}

// Status represents index status.
type Status struct {
	Healthy       bool           `json:"healthy"`
	DocumentCount int            `json:"document_count"`
	ChunkCount    int            `json:"chunk_count"`
	Dimension     int            `json:"dimension"`
	LastUpdated   time.Time      `json:"last_updated"`
	StorageBytes  int64          `json:"storage_bytes"`
	Sources       []SourceStatus `json:"sources"`
}

// SourceStatus represents status of a single source.
type SourceStatus struct {
	Name     string    `json:"name"`
	Type     string    `json:"type"`
	DocCount int       `json:"doc_count"`
	LastSync time.Time `json:"last_sync"`
	Status   string    `json:"status"`
	NextSync time.Time `json:"next_sync,omitempty"`
}
