store

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrawlProgressItem

type CrawlProgressItem struct {
	URL          string
	ItemType     string
	Status       string
	ErrorType    string
	ErrorMessage string
	ParentEntity string
}

CrawlProgressItem represents a single crawl progress entry.

type CrawlSession

type CrawlSession struct {
	ID           int64
	LibraryID    string
	Status       string
	TotalURLs    int
	SuccessCount int
	FailCount    int
	SkipCount    int
	StartedAt    time.Time
	CompletedAt  *time.Time
}

CrawlSession represents a crawl session row from the database.

type CrawlStats

type CrawlStats struct {
	Total          int
	Success        int
	Failed         int
	Skipped        int
	FailuresByType map[string]int
}

CrawlStats holds aggregate statistics for a crawl session.

type EntityRecord

type EntityRecord struct {
	ID          int64     `json:"id"`
	LibraryID   string    `json:"library_id"`
	Slug        string    `json:"slug"`
	Name        string    `json:"name"`
	Kind        string    `json:"kind"`
	Description string    `json:"description"`
	SourceFile  string    `json:"source_file"`
	SourceCode  string    `json:"source_code"`
	URL         string    `json:"url"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

EntityRecord represents an entity row from the database.

type LibraryRecord

type LibraryRecord struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Description  string    `json:"description"`
	SourceURL    string    `json:"source_url"`
	Version      string    `json:"version"`
	TrustScore   float64   `json:"trust_score"`
	SnippetCount int       `json:"snippet_count"`
	CrawledAt    time.Time `json:"crawled_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

LibraryRecord represents a library row from the database.

type MethodRecord

type MethodRecord struct {
	ID             int64     `json:"id"`
	EntityID       int64     `json:"entity_id"`
	Slug           string    `json:"slug"`
	Name           string    `json:"name"`
	Signature      string    `json:"signature"`
	Description    string    `json:"description"`
	ParametersJSON string    `json:"parameters_json"`
	ReturnType     string    `json:"return_type"`
	ReturnDesc     string    `json:"return_desc"`
	SourceCode     string    `json:"source_code"`
	WrappedSource  string    `json:"wrapped_source"`
	WrappedMethod  string    `json:"wrapped_method"`
	URL            string    `json:"url"`
	Since          string    `json:"since"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

MethodRecord represents a method row from the database.

type RelationRecord

type RelationRecord struct {
	ID          int64  `json:"id"`
	MethodID    int64  `json:"method_id"`
	Kind        string `json:"kind"`
	TargetName  string `json:"target_name"`
	TargetURL   string `json:"target_url"`
	Description string `json:"description"`
}

RelationRecord represents a relation row from the database.

type SearchResult

type SearchResult struct {
	EntityID    int64   `json:"entity_id"`
	MethodID    *int64  `json:"method_id,omitempty"`
	SnippetType string  `json:"snippet_type"` // "class" or "method"
	EntityName  string  `json:"entity_name"`
	MethodName  string  `json:"method_name,omitempty"`
	Rank        float64 `json:"rank"`
}

SearchResult represents a single FTS5 search hit.

type Store

type Store interface {
	UpsertLibrary(ctx context.Context, id string, meta source.LibraryMeta) error
	GetLibrary(ctx context.Context, id string) (*LibraryRecord, error)
	SearchLibraries(ctx context.Context, query string) ([]LibraryRecord, error)
	ListLibraries(ctx context.Context) ([]LibraryRecord, error)

	UpsertEntity(ctx context.Context, libraryID string, entity *source.Entity) (int64, error)
	GetEntity(ctx context.Context, libraryID, slug string) (*EntityRecord, error)
	GetEntityByID(ctx context.Context, id int64) (*EntityRecord, error)
	ListEntities(ctx context.Context, libraryID string) ([]EntityRecord, error)

	UpsertMethod(ctx context.Context, entityID int64, method *source.Method) error
	GetMethod(ctx context.Context, entityID int64, slug string) (*MethodRecord, error)
	ListMethods(ctx context.Context, entityID int64) ([]MethodRecord, error)
	ListRelations(ctx context.Context, methodID int64) ([]RelationRecord, error)

	UpdateSnippetCount(ctx context.Context, libraryID string, count int) error
	ComputeSnippetCount(ctx context.Context, libraryID string) (int, error)
	Search(ctx context.Context, libraryID, query string, limit int, mode string) ([]SearchResult, error)
	RebuildIndex(ctx context.Context, libraryID string) error

	CreateCrawlSession(ctx context.Context, libraryID string, totalURLs int) (int64, error)
	UpdateCrawlSession(ctx context.Context, sessionID int64, status string, success, fail, skip int) error
	GetLastSession(ctx context.Context, libraryID string) (*CrawlSession, error)
	RecordProgress(ctx context.Context, sessionID int64, item *CrawlProgressItem) error
	GetProcessedURLs(ctx context.Context, sessionID int64) (map[string]string, error)
	GetCrawlStats(ctx context.Context, sessionID int64) (*CrawlStats, error)
	GetFailures(ctx context.Context, sessionID int64) ([]CrawlProgressItem, error)

	Close() error
}

Store defines the persistence interface for documentation data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL