indexers

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatapackIndexerNames added in v1.0.39

func DatapackIndexerNames() []string

DatapackIndexerNames returns the registered datapack indexer names, sorted, so callers can search every provider for merged coverage.

func DatapackIndexerOrigin added in v1.0.39

func DatapackIndexerOrigin(idx DatapackIndexer) string

DatapackIndexerOrigin returns the indexer's configured API origin, or "" when the indexer does not report one.

func FirstDatapackLatestFile added in v1.0.39

func FirstDatapackLatestFile(ctx context.Context, datapackID, gameVersion string, idxs []DatapackIndexer) (*DatapackFile, DatapackIndexer, error)

FirstDatapackLatestFile resolves a datapack file against the given indexers in order and returns the first success with the indexer that resolved it (for download trust scoping). An id from one provider must not be resolvable on another, so cross-provider misses are expected and joined into the final error.

func IsAuthError

func IsAuthError(err error) bool

Reports whether the error is an auth error

func IsNetworkError

func IsNetworkError(err error) bool

Reports whether the error is a network error

func IsNotFound

func IsNotFound(err error) bool

Reports whether the error is a not-found error

func IsRateLimit

func IsRateLimit(err error) bool

Reports whether the error is a rate-limit error

func RegisterDatapackIndexer added in v1.0.39

func RegisterDatapackIndexer(name string, factory DatapackIndexerFactory)

RegisterDatapackIndexer registers a DatapackIndexerFactory under the given name. Typically called from an indexer package's init() function.

func RegisterIndexer

func RegisterIndexer(name string, factory IndexerFactory)

RegisterIndexer registers an IndexerFactory under the given name. Typically called from an indexer package's init() function.

Types

type Datapack added in v1.0.39

type Datapack struct {
	ID            string   `json:"id"`
	IndexerID     string   `json:"indexer_id"`
	Indexer       string   `json:"indexer"`
	Name          string   `json:"name"`
	Slug          string   `json:"slug"`
	Summary       string   `json:"summary"`
	IconURL       string   `json:"icon_url"`
	WebsiteURL    string   `json:"website_url"`
	Author        string   `json:"author"`
	DownloadCount int64    `json:"download_count"`
	GameVersions  []string `json:"game_versions"`
	DateModified  string   `json:"date_modified"`
}

Datapack is a datapack as reported by an indexer.

type DatapackFile added in v1.0.39

type DatapackFile struct {
	DatapackID   string   `json:"datapack_id"`
	Filename     string   `json:"filename"`
	DownloadURL  string   `json:"download_url"`
	Size         int64    `json:"size"`
	SHA1         string   `json:"sha1"`
	SHA512       string   `json:"sha512"`
	GameVersions []string `json:"game_versions"`
}

DatapackFile is a downloadable datapack artifact.

type DatapackIndexer added in v1.0.39

type DatapackIndexer interface {
	// SearchDatapacks searches for datapacks matching the criteria.
	SearchDatapacks(ctx context.Context, query string, gameVersion string, offset, limit int) (*DatapackSearchResult, error)

	// GetDatapackLatestFile returns the primary downloadable file for a
	// datapack, optionally filtered to a game version.
	GetDatapackLatestFile(ctx context.Context, datapackID string, gameVersion string) (*DatapackFile, error)

	// GetIndexerName returns the name of this indexer (e.g. "modrinth").
	GetIndexerName() string
}

DatapackIndexer defines the interface for datapack discovery services. A datapack is a self-contained world-data bundle (recipes, loot tables, worldgen) that runs on Vanilla servers without a mod loader, so it is a separate content type from mods and modpacks.

func DatapackIndexersFor added in v1.0.39

func DatapackIndexersFor(name, apiKey string, cfg *config.Config) ([]DatapackIndexer, error)

DatapackIndexersFor builds the datapack indexer set for file resolution: the named indexer, or every registered provider when name is empty so search results from any provider remain installable.

func NewDatapackIndexer added in v1.0.39

func NewDatapackIndexer(name string, apiKey string, cfg *config.Config) (DatapackIndexer, error)

NewDatapackIndexer creates a DatapackIndexer by name using the factory registry.

type DatapackIndexerFactory added in v1.0.39

type DatapackIndexerFactory func(apiKey string, cfg *config.Config) DatapackIndexer

DatapackIndexerFactory creates a DatapackIndexer from an API key and config.

type DatapackSearchResult added in v1.0.39

type DatapackSearchResult struct {
	Datapacks  []Datapack
	TotalCount int
	PageSize   int
	Offset     int
}

DatapackSearchResult holds a page of datapack search results.

type ErrorKind

type ErrorKind int

indexer errors

const (
	ErrAuth      ErrorKind = iota // 401/403 or missing API key
	ErrRateLimit                  // 429
	ErrNotFound                   // 404
	ErrNetwork                    // DNS failure, timeout, connection refused
	ErrAPI                        // Other non-2xx status codes
	ErrDecode                     // JSON decode failures
)

func (ErrorKind) String

func (k ErrorKind) String() string

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

HTTPClient wraps http.Client with common indexer request logic.

func NewHTTPClient

func NewHTTPClient(indexer string, userAgent string, extraHeaders map[string]string) *HTTPClient

NewHTTPClient creates a shared HTTP client for an indexer.

func (*HTTPClient) DoJSON

func (h *HTTPClient) DoJSON(ctx context.Context, url string, dest any) error

DoJSON performs a GET request, checks the status, and JSON-decodes into dest. It returns structured IndexerErrors for all failure modes.

type IndexerError

type IndexerError struct {
	Kind       ErrorKind
	Indexer    string
	StatusCode int
	URL        string
	Body       string
	Err        error
}

func NewAPIError

func NewAPIError(indexer string, statusCode int, url string, body string) *IndexerError

It automatically classifies 401/403 as Auth, 404 as NotFound, 429 as RateLimit.

func NewAuthConfigError

func NewAuthConfigError(indexer string, msg string) *IndexerError

Missing API key configuration

func NewDecodeError

func NewDecodeError(indexer string, url string, err error) *IndexerError

JSON decode failures.

func NewNetworkError

func NewNetworkError(indexer string, url string, err error) *IndexerError

IndexerError for network-level failures like dns

func (*IndexerError) Error

func (e *IndexerError) Error() string

func (*IndexerError) Unwrap

func (e *IndexerError) Unwrap() error

type IndexerFactory

type IndexerFactory func(apiKey string, cfg *config.Config) ModpackIndexer

IndexerFactory creates a ModpackIndexer from an API key and config.

type Modpack

type Modpack struct {
	ID            string    `json:"id"`
	IndexerID     string    `json:"indexer_id"` // Original ID from the indexer
	Indexer       string    `json:"indexer"`    // Which indexer this came from
	Name          string    `json:"name"`
	Slug          string    `json:"slug"`
	Summary       string    `json:"summary"`
	Description   string    `json:"description"`
	LogoURL       string    `json:"logo_url"`
	WebsiteURL    string    `json:"website_url"`
	DownloadCount int64     `json:"download_count"`
	Categories    []string  `json:"categories"`
	GameVersions  []string  `json:"game_versions"`
	ModLoaders    []string  `json:"mod_loaders"`
	LatestFileID  string    `json:"latest_file_id"`
	DateCreated   time.Time `json:"date_created"`
	DateModified  time.Time `json:"date_modified"`
	DateReleased  time.Time `json:"date_released"`
}

Modpack represents a modpack from any indexer

type ModpackFile

type ModpackFile struct {
	ID               string    `json:"id"`
	ModpackID        string    `json:"modpack_id"`
	DisplayName      string    `json:"display_name"`
	FileName         string    `json:"file_name"`
	FileDate         time.Time `json:"file_date"`
	FileLength       int64     `json:"file_length"`
	ReleaseType      string    `json:"release_type"` // "release", "beta", "alpha"
	DownloadURL      string    `json:"download_url"`
	GameVersions     []string  `json:"game_versions"`
	ModLoader        string    `json:"mod_loader"`
	ServerPackFileID *string   `json:"server_pack_file_id,omitempty"`
	SortIndex        int       `json:"sort_index"`
	VersionNumber    string    `json:"version_number"` // Human-readable version for Modrinth
}

ModpackFile represents a downloadable file for a modpack

type ModpackIndexer

type ModpackIndexer interface {
	// SearchModpacks searches for modpacks with the given criteria
	SearchModpacks(ctx context.Context, query string, gameVersion string, modLoader string, offset, limit int) (*SearchResult, error)

	// GetModpack retrieves detailed information about a specific modpack
	GetModpack(ctx context.Context, modpackID string) (*Modpack, error)

	// GetModpackFiles retrieves all available files for a modpack
	GetModpackFiles(ctx context.Context, modpackID string) ([]ModpackFile, error)

	// GetIndexerName returns the name of this indexer (e.g., "fuego", "modrinth")
	GetIndexerName() string
}

ModpackIndexer defines the interface for modpack indexing services

func NewIndexer

func NewIndexer(name string, apiKey string, cfg *config.Config) (ModpackIndexer, error)

NewIndexer creates a ModpackIndexer by name using the factory registry.

type OriginReporter added in v1.0.39

type OriginReporter interface {
	Origin() string
}

OriginReporter is an optional DatapackIndexer capability: it reports the configured API origin. Downloads inherit this origin's network trust (see minecraft.DownloadAllowsPrivate), so a public index can never point the panel at internal hosts while self-hosted indexes keep serving LAN files. Indexers that do not report an origin get strict public-only downloads.

type SearchResult

type SearchResult struct {
	Modpacks   []Modpack
	TotalCount int
	PageSize   int
	Offset     int
}

SearchResult contains the results of a modpack search

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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