Documentation
¶
Overview ¶
Package provides maps package identities to source-level names and project bindings.
Index ¶
- type Binding
- type BindingResolver
- type BindingResult
- type Catalog
- type Diagnostic
- type Evidence
- type EvidenceMethod
- type ImportMatch
- type ImportRequest
- type ImportResult
- type MatchMode
- type Package
- type ProjectSurfaceResult
- type ProvidedName
- type Surface
- type SurfaceOptions
- type SurfaceResolver
- type SurfaceResolverFunc
- type SurfaceResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binding ¶
type Binding struct {
PURL string
Imported string
Target string
Local string
Match MatchMode
Evidence []Evidence
}
Binding connects a package to the name used by one project.
type BindingResolver ¶
type BindingResolver interface {
ResolveBindings(ctx context.Context, projectDir string) (BindingResult, error)
}
BindingResolver resolves dependency bindings for a project directory.
type BindingResult ¶
type BindingResult struct {
Bindings []Binding
Diagnostics []Diagnostic
}
BindingResult contains project bindings and any non-fatal diagnostics.
func MergeBindingResults ¶
func MergeBindingResults(results ...BindingResult) BindingResult
MergeBindingResults combines project bindings, deduplicates mappings and evidence, and returns deterministic output.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is an immutable collection of package surfaces indexed by PURL. Versioned entries apply only to that version. Entries without a version are used as fallbacks for every version of the package.
func NewCatalog ¶
NewCatalog creates a curated surface catalog.
func (*Catalog) ResolveSurface ¶
func (c *Catalog) ResolveSurface( ctx context.Context, pkg Package, _ SurfaceOptions, ) (SurfaceResult, error)
ResolveSurface implements SurfaceResolver using curated local data.
type Diagnostic ¶
Diagnostic records a non-fatal resolver problem.
type Evidence ¶
type Evidence struct {
Method EvidenceMethod
Source string
}
Evidence describes where a mapping came from.
type EvidenceMethod ¶
type EvidenceMethod string
EvidenceMethod identifies how a package or binding mapping was obtained.
const ( // EvidenceResolver comes from package-manager resolution output. EvidenceResolver EvidenceMethod = "resolver" // EvidenceManifest comes from a manifest, lockfile, or import map. EvidenceManifest EvidenceMethod = "manifest" // EvidenceInstalled comes from installed package metadata or contents. EvidenceInstalled EvidenceMethod = "installed" // EvidenceArtifact comes from a package artifact. EvidenceArtifact EvidenceMethod = "artifact" // EvidenceCurated comes from an explicit maintained mapping. EvidenceCurated EvidenceMethod = "curated" // EvidenceHeuristic comes from an opt-in naming guess. EvidenceHeuristic EvidenceMethod = "heuristic" )
type ImportMatch ¶
type ImportMatch struct {
PURL string
Provided ProvidedName
}
ImportMatch connects an import to one matching package surface.
type ImportRequest ¶
type ImportRequest struct {
Language string
Name string
Packages []Package
Options SurfaceOptions
}
ImportRequest describes a source import and the project dependencies that may provide it.
type ImportResult ¶
type ImportResult struct {
Language string
Name string
Matches []ImportMatch
Diagnostics []Diagnostic
}
ImportResult contains every package surface matching an import and any non-fatal diagnostics collected while resolving project surfaces.
func MatchImport ¶
func MatchImport(language, name string, project ProjectSurfaceResult) ImportResult
MatchImport returns every matching package from an already resolved project.
func ResolveImport ¶
func ResolveImport( ctx context.Context, resolver SurfaceResolver, request ImportRequest, ) (ImportResult, error)
ResolveImport resolves the requested project package surfaces and returns every package that provides the import.
type Package ¶
type Package struct {
PURL string
}
Package identifies a package whose source-level surface should be resolved.
type ProjectSurfaceResult ¶
type ProjectSurfaceResult struct {
Surfaces []Surface
Diagnostics []Diagnostic
}
ProjectSurfaceResult contains the package surfaces resolved for one set of project dependencies and any non-fatal diagnostics.
func ResolveProjectSurfaces ¶
func ResolveProjectSurfaces( ctx context.Context, resolver SurfaceResolver, packages []Package, options SurfaceOptions, ) (ProjectSurfaceResult, error)
ResolveProjectSurfaces resolves surfaces for caller-supplied project dependencies. It continues after resolver errors and returns successful surfaces alongside the joined error.
type ProvidedName ¶
type ProvidedName struct {
Language string
Name string
Kind string
Match MatchMode
// Separator is the boundary between a prefix name and a matched
// descendant, for example "." for a Python module or "/" for an npm
// subpath. It is unused for MatchExact.
Separator string
// CaseInsensitive folds ASCII case when matching. Set it for languages
// whose module or namespace lookup is itself case-insensitive, for
// example PHP, where `use GuzzleHttp\Client` and `use guzzlehttp\client`
// resolve to the same class. Name still retains its canonical spelling.
CaseInsensitive bool
Evidence []Evidence
}
ProvidedName is a source-level name supplied by a package.
func (ProvidedName) Matches ¶
func (name ProvidedName) Matches(imported string) bool
Matches reports whether imported is covered by the provided name. Matching is case-sensitive by default because Name retains its exact source-visible spelling; CaseInsensitive folds ASCII case for languages whose lookup does.
type Surface ¶
type Surface struct {
PURL string
Provides []ProvidedName
}
Surface contains the source-level names provided by a package.
type SurfaceOptions ¶
type SurfaceOptions struct {
IncludeHeuristics bool
}
SurfaceOptions controls package-surface resolution.
type SurfaceResolver ¶
type SurfaceResolver interface {
ResolveSurface(ctx context.Context, pkg Package, options SurfaceOptions) (SurfaceResult, error)
}
SurfaceResolver resolves the source-level surface provided by a package.
type SurfaceResolverFunc ¶ added in v0.2.0
type SurfaceResolverFunc func(ctx context.Context, pkg Package, options SurfaceOptions) (SurfaceResult, error)
SurfaceResolverFunc adapts a function to a SurfaceResolver.
func Chain ¶ added in v0.2.0
func Chain(resolvers ...SurfaceResolver) SurfaceResolverFunc
Chain returns a SurfaceResolver that queries each resolver in order and merges every non-empty result for a package. Later resolvers still run after an earlier one produces a result so callers can combine, for example, a curated catalog with a heuristic fallback and receive both mappings with their distinct evidence. A resolver that returns an error contributes a diagnostic and the chain continues.
func (SurfaceResolverFunc) ResolveSurface ¶ added in v0.2.0
func (f SurfaceResolverFunc) ResolveSurface(ctx context.Context, pkg Package, options SurfaceOptions) (SurfaceResult, error)
ResolveSurface calls f.
type SurfaceResult ¶
type SurfaceResult struct {
Surface Surface
Diagnostics []Diagnostic
}
SurfaceResult contains a package surface and any non-fatal diagnostics.
func MergeSurfaceResults ¶
func MergeSurfaceResults(purl string, results ...SurfaceResult) SurfaceResult
MergeSurfaceResults combines results for purl, deduplicates mappings and evidence, and returns deterministic output. A result for a different PURL is omitted and reported as a diagnostic.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package artifacts inspects package archive contents for source-level names.
|
Package artifacts inspects package archive contents for source-level names. |
|
Package bindings parses project-local package-manager metadata into source import bindings.
|
Package bindings parses project-local package-manager metadata into source import bindings. |
|
Package curated contains local package-surface catalogs.
|
Package curated contains local package-surface catalogs. |
|
Package heuristic provides a SurfaceResolver that maps a package identity to its conventional source-level name using per-ecosystem naming rules alone.
|
Package heuristic provides a SurfaceResolver that maps a package identity to its conventional source-level name using per-ecosystem naming rules alone. |