metadata

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package metadata defines a metadata struct for Javascript packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToProto

ToProto converts the Metadata struct to a JavascriptPackageJSONMetadata proto.

Types

type JavascriptPackageJSONMetadata

type JavascriptPackageJSONMetadata = JavascriptPackageMetadata

JavascriptPackageJSONMetadata is an alias for JavascriptPackageMetadata for compatibility.

type JavascriptPackageMetadata

type JavascriptPackageMetadata struct {
	Author       *Person   `json:"author,omitempty"`
	Maintainers  []*Person `json:"maintainers,omitempty"`
	Contributors []*Person `json:"contributors,omitempty"`

	// Source indicates whether this package's dependency was resolved from the official
	// NPM registry, a local path, git repository, or private registry.
	Source NPMPackageSource `json:"source,omitempty"`

	// Dependencies maps direct dependencies to version constraints.
	Dependencies map[string]string `json:"dependencies,omitempty"`

	// DepGroupVals stores the dependency groups (e.g. "dev", "prod") the package belongs to.
	DepGroupVals []string `json:"dep_groups,omitempty"`
}

JavascriptPackageMetadata holds metadata information for JavaScript packages across package.json and various lockfile formats.

func ToStruct

ToStruct converts the JavascriptPackageJSONMetadata proto to a Metadata struct.

func (*JavascriptPackageMetadata) DepGroups

func (m *JavascriptPackageMetadata) DepGroups() []string

DepGroups returns the dependency groups property in the metadata.

func (*JavascriptPackageMetadata) IsProtoable

func (m *JavascriptPackageMetadata) IsProtoable()

IsProtoable marks the struct as a metadata type.

func (*JavascriptPackageMetadata) PackageSource

func (m *JavascriptPackageMetadata) PackageSource() NPMPackageSource

PackageSource returns the NPMPackageSource of the package.

type NPMPackageSource

type NPMPackageSource string

NPMPackageSource is the source of the NPM package.

const (
	// Unknown is when the source of the NPM package is unknown because the lockfile was not found.
	Unknown NPMPackageSource = "UNKNOWN"
	// PublicRegistry is the public NPM registry.
	PublicRegistry NPMPackageSource = "PUBLIC_REGISTRY"
	// Other is any other remote or private source (e.g. GitHub).
	// This is used for packages that are not found in the public NPM registry.
	Other NPMPackageSource = "OTHER"
	// Local is the local filesystem that stores the package versions.
	// This is used for when the package is locally-developed or -installed.
	Local NPMPackageSource = "LOCAL"
)

func (NPMPackageSource) ToProto

func (source NPMPackageSource) ToProto() pb.PackageSource

ToProto converts the NPMPackageSource to the proto enum.

type Person

type Person struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	URL   string `json:"url"`
}

Person represents a person field in a javascript package.json file.

func PersonFromString

func PersonFromString(s string) *Person

PersonFromString parses a string of the form "name <email> (url)" into a Person struct.

func (*Person) PersonString

func (p *Person) PersonString() string

PersonString produces a string format of Person struct in the format of "name <email> (url)"

func (*Person) UnmarshalJSON

func (p *Person) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a JSON object or string into a Person struct.

Jump to

Keyboard shortcuts

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