source

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MergeSourceExmodz = "exmodz"
	MergeSourcePak    = "pak"
)

Merge-source kinds (#221). An empty Kind means MergeSourceExmodz - every pre-#221 constructor built exmodz-only sources and never set a kind.

Variables

View Source
var ErrNotSupported = errors.New("operation not supported by this source")

ErrNotSupported indicates a source does not support the requested operation. Callers should branch with errors.Is(err, ErrNotSupported) and degrade gracefully (hide the action, show a notice) rather than treat it as a failure.

Functions

func TypeLabelOf added in v1.21.0

func TypeLabelOf(src ModSource) string

TypeLabelOf returns src's self-reported kind ("directory"/"manifest"/ "api" for custom sources, "built-in" for NexusMods/CurseForge), falling back to "unknown" when src implements no TypeLabeler. Mirrors CapabilitiesOf's optional-interface pattern; the fallback is unreachable in production (every real source implements TypeLabeler), reachable only by bare test doubles.

Types

type AuthInstructionsProvider added in v1.21.0

type AuthInstructionsProvider interface{ AuthInstructions() string }

AuthInstructionsProvider supplies human setup steps for obtaining a key. Absent: generic instructions naming the env var.

type Capabilities added in v1.6.0

type Capabilities struct {
	Search       bool
	Dependencies bool
	Updates      bool
	Auth         bool
	// Versions: the source CAN carry per-file Version strings usable for
	// exact version->file resolution (#96). Advisory, not a guarantee:
	// resolution itself degrades dynamically per mod - a file list with no
	// version data yields ErrNotSupported even when this is true (see
	// core.ResolveVersionFiles).
	Versions bool
}

Capabilities reports which optional operations a source supports.

func CapabilitiesOf added in v1.6.0

func CapabilitiesOf(src ModSource) Capabilities

CapabilitiesOf returns src's capabilities. Sources that do not implement CapabilityReporter are assumed fully capable — a default kept for test doubles; production sources should implement CapabilityReporter explicitly rather than rely on this fallback.

type CapabilityReporter added in v1.6.0

type CapabilityReporter interface {
	Capabilities() Capabilities
}

CapabilityReporter is implemented by sources that support only a subset of ModSource operations. Sources that do not implement it are assumed fully capable.

type DownloadHeaderProvider added in v1.7.0

type DownloadHeaderProvider interface {
	DownloadHeaders(fileURL string) map[string]string
}

DownloadHeaderProvider is implemented by sources whose file downloads need extra HTTP headers (e.g. header-mode API-key auth on a manifest source). Service.DownloadModToCache consults it with the resolved download URL so the source can scope credentials (e.g. same-origin only). A nil map means no extra headers.

type EnvKeyProvider added in v1.21.0

type EnvKeyProvider interface{ EnvKey() string }

EnvKeyProvider names the environment variable consulted for this source's API key. Absent: the derived LMM_<ID>_API_KEY convention applies.

type GameCatalog added in v1.21.0

type GameCatalog interface {
	ListGames(ctx context.Context) ([]GameEntry, error)
}

GameCatalog lists the games a source knows about, for interactive game-creation flows. Absent: manual identifier entry.

type GameEntry added in v1.21.0

type GameEntry struct{ ID, Name, Slug string }

GameEntry is one game known to a source's catalog, for interactive game-creation flows.

type KeyValidator added in v1.21.0

type KeyValidator interface {
	ValidateKey(ctx context.Context, key string) error
}

KeyValidator performs a live API-key check at auth-login time. Absent: keys are stored and validated on first use.

type MergeCompiler added in v1.28.0

type MergeCompiler interface {
	// ValidateSource parses/validates sourceFilePath (the retained,
	// not-yet-merged source archive) without compiling anything - called at
	// ingest time (download/import) so a malformed archive fails loud
	// immediately rather than at the next merge.
	ValidateSource(sourceFilePath string) error

	// MergeCompile applies every entry in sources, in order (profile load
	// order), against basePakPath's tables, and writes the merged result to
	// outputPakPath. Returns non-fatal warnings (e.g. same-path asset
	// collisions - last-applied wins) alongside a nil error; a nil error
	// with warnings is still a fully-written, deployable pak. Pak-kind
	// sources that cannot be converted are skipped per-mod and reported in
	// failed (#221) - only exmodz-source errors and I/O failures are fatal.
	MergeCompile(ctx context.Context, basePakPath string, sources []MergeSource, outputPakPath string) (warnings []string, failed []MergeFailure, err error)
}

MergeCompiler is implemented by sources whose compile-eligible files must be merged across every enabled mod into ONE profile-level artifact rather than compiled per-mod (#197: Icarus's cross-mod table merge - a whole-pak last-wins deploy would silently drop one mod's table rows whenever two mods patch the same table). Replaces #196's Compiler interface, which this source no longer implements: there is no more per-mod compiled artifact to produce.

type MergeFailure added in v1.30.0

type MergeFailure struct {
	ModRef string
	Reason string
}

MergeFailure records one source that could not participate in a merge (#221: an irreconcilable pak). The merge itself still succeeds - the failed mod is skipped and falls back to raw deploy; core uses this list to reconcile cache manifests and record outcomes in the fingerprint.

type MergeSource added in v1.28.0

type MergeSource struct {
	ModRef     string // "sourceID:modID" - machine identity (MergeFailure, ownership tracking)
	ModName    string // display name preferred over ModRef in user-facing warnings; may be empty
	SourcePath string // the retained source archive to read (.exmodz, or a raw .pak eligible for conversion - #221)
	Kind       string // MergeSourceExmodz (default when empty) or MergeSourcePak
}

MergeSource identifies one mod's contribution to a merge, in the order it must be applied (profile load order).

type ModSource

type ModSource interface {
	// Identity
	ID() string
	Name() string

	// Authentication
	AuthURL() string
	ExchangeToken(ctx context.Context, code string) (*Token, error)

	// Discovery
	Search(ctx context.Context, query SearchQuery) (SearchResult, error)
	GetMod(ctx context.Context, gameID, modID string) (*domain.Mod, error)
	GetDependencies(ctx context.Context, mod *domain.Mod) ([]domain.ModReference, error)

	// Downloads
	GetModFiles(ctx context.Context, mod *domain.Mod) ([]domain.DownloadableFile, error)
	GetDownloadURL(ctx context.Context, mod *domain.Mod, fileID string) (string, error)

	// Updates
	CheckUpdates(ctx context.Context, installed []domain.InstalledMod) ([]domain.Update, error)
}

ModSource is the interface for mod repositories

type Registry

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

Registry manages available mod sources

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new source registry

func (*Registry) Get

func (r *Registry) Get(id string) (ModSource, error)

Get retrieves a source by ID

func (*Registry) List

func (r *Registry) List() []ModSource

List returns all registered sources

func (*Registry) Register

func (r *Registry) Register(source ModSource)

Register adds a source to the registry

type SearchQuery

type SearchQuery struct {
	GameID   string
	Query    string
	Category string   // Optional category filter (source-specific: ID or name)
	Tags     []string // Optional tag filters (source-specific)
	Page     int
	PageSize int
}

SearchQuery contains parameters for searching mods.

type SearchResult added in v1.3.0

type SearchResult struct {
	Mods       []domain.Mod
	TotalCount int // Total results available (0 if unknown)
	Page       int
	PageSize   int
}

SearchResult contains paginated search results.

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	ExpiresAt    time.Time
}

Token represents an OAuth token

type TypeLabeler added in v1.21.0

type TypeLabeler interface{ TypeLabel() string }

TypeLabeler names the source's kind for listings (directory/manifest/api/ built-in). Absent: "unknown".

Directories

Path Synopsis
Package custom implements user-defined mod sources configured declaratively via YAML files in <configDir>/sources/.
Package custom implements user-defined mod sources configured declaratively via YAML files in <configDir>/sources/.
metadata
Package metadata extracts mod metadata from well-known files inside a mod directory (e.g.
Package metadata extracts mod metadata from well-known files inside a mod directory (e.g.
Package httpclient is a thin JSON HTTP client used by mod-source SDKs (NexusMods, CurseForge, ...).
Package httpclient is a thin JSON HTTP client used by mod-source SDKs (NexusMods, CurseForge, ...).

Jump to

Keyboard shortcuts

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