ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Package

Description

The ecosystem-neutral package model used by admission and rules. Artifact entry keys retain source coordinates while adapters keep ownership of wire formats.

Synopsis

Scopes

data Scope Source #

An npm scope without its leading @. mkScope removes that prefix, so equality does not depend on how the scope was written.

Instances

Instances details
Show Scope Source # 
Instance details

Defined in Ecluse.Core.Package

Methods

showsPrec :: Int -> Scope -> ShowS #

show :: Scope -> String #

showList :: [Scope] -> ShowS #

Eq Scope Source # 
Instance details

Defined in Ecluse.Core.Package

Methods

(==) :: Scope -> Scope -> Bool #

(/=) :: Scope -> Scope -> Bool #

Ord Scope Source # 
Instance details

Defined in Ecluse.Core.Package

Methods

compare :: Scope -> Scope -> Ordering #

(<) :: Scope -> Scope -> Bool #

(<=) :: Scope -> Scope -> Bool #

(>) :: Scope -> Scope -> Bool #

(>=) :: Scope -> Scope -> Bool #

max :: Scope -> Scope -> Scope #

min :: Scope -> Scope -> Scope #

mkScope :: Text -> Scope Source #

Build a Scope, tolerating an optional leading '@'.

unScope :: Scope -> Text Source #

The bare scope text, without the leading '@'.

renderScope :: Scope -> Text Source #

Render a scope in npm wire form, with the leading '@'.

Package identity

data PackageName Source #

A registry-independent identity built with mkPackageName. Equality and ordering use (pkgEcosystem, pkgNamespace, pkgCanonical), excluding the display spelling.

mkPackageName :: Ecosystem -> Maybe Scope -> Text -> PackageName Source #

Build a name with its ecosystem lookup key, retaining the published spelling.

pkgEcosystem :: PackageName -> Ecosystem Source #

The ecosystem this name belongs to.

pkgNamespace :: PackageName -> Maybe Scope Source #

The npm scope. Unscoped ecosystems use Nothing.

pkgCanonical :: PackageName -> ShortText Source #

The lookup key under the ecosystem's name grammar.

pkgBaseName :: PackageName -> ShortText Source #

The base name with any @scope/ prefix dropped. It is not part of identity. Read it back through unscopedName.

renderPackageName :: PackageName -> Text Source #

Render a package name in its native wire form (the display name).

unscopedName :: PackageName -> Text Source #

The unscoped (base) name as Text: @babel/code-frame reads back as code-frame.

data WireNameRefusal e Source #

Why a wire name did not yield an unnamespaced package name.

Constructors

WireNamespaced

The wire carried a non-empty namespace.

WireNameUnusable e

The ecosystem's grammar refused the bare name.

Instances

Instances details
Show e => Show (WireNameRefusal e) Source # 
Instance details

Defined in Ecluse.Core.Package

Eq e => Eq (WireNameRefusal e) Source # 
Instance details

Defined in Ecluse.Core.Package

unnamespacedWireName :: (Text -> Either e PackageName) -> Maybe Text -> Text -> Either (WireNameRefusal e) PackageName Source #

Refuse a non-empty wire namespace, then read the bare name through the ecosystem's grammar.

The name charset boundary

isAsciiNameComponent :: Text -> Bool Source #

Whether one component of a package name is ASCII with no control character: the boundary every ecosystem's grammar rests on, because an invisible codepoint renders two names as one.

Canonical keys

canonicalise :: Ecosystem -> Text -> Text Source #

Normalise a display name into its canonical matching key for an ecosystem. An ecosystem with a normalisation grammar keeps it in its own module.

Normalised signals

data CodeExecSignal Source #

Whether installation executes package-supplied code, including builds and native extensions.

Constructors

NoCodeOnInstall

Determined: installation runs no code.

RunsCodeOnInstall Text

Determined: installation runs code. The text says how, for the audit trail.

CodeExecUnknown

Not determined from registry metadata. Rules that read it abstain.

Instances

Instances details
Show CodeExecSignal Source # 
Instance details

Defined in Ecluse.Core.Package

Eq CodeExecSignal Source # 
Instance details

Defined in Ecluse.Core.Package

data DependencySources Source #

Whether installing a version fetches a dependency from somewhere other than the registry.

Constructors

RegistryDependencies

Every installable dependency resolves through the registry.

FetchesOutsideRegistry Text

A dependency installs from elsewhere, such as a git repository. The text names it, for the audit trail.

DependencySourcesUnknown

Not determined: the adapter does not read dependency sources. Pure rules abstain.

data Availability Source #

Whether a version is offered, advisory-deprecated, or withdrawn. The registry's notice text stays in the served document.

Constructors

Available

Offered normally.

Deprecated

Advisory deprecation (npm), still resolvable.

Yanked

Withdrawn from resolution (PyPI yank keeps the file, RubyGems yank removes it).

Instances

Instances details
Show Availability Source # 
Instance details

Defined in Ecluse.Core.Package

Eq Availability Source # 
Instance details

Defined in Ecluse.Core.Package

Artifacts

data Artifact Source #

One distribution file with its source coordinate and optional metadata companion.

Constructors

Artifact 

Fields

Instances

Instances details
Show Artifact Source # 
Instance details

Defined in Ecluse.Core.Package

Eq Artifact Source # 
Instance details

Defined in Ecluse.Core.Package

data CoreMetadata Source #

The upstream companion declaration, preserving raw digest names and values.

Constructors

MetadataAvailable Bool

The index declares availability without a digest.

MetadataDigests (Map Text Text)

Algorithm names and digest strings exactly as declared by the index.

Instances

Instances details
Show CoreMetadata Source # 
Instance details

Defined in Ecluse.Core.Package

Eq CoreMetadata Source # 
Instance details

Defined in Ecluse.Core.Package

data Hash Source #

An artifact digest validated by mkHash. Record updates must preserve its encoding and length.

Instances

Instances details
Show Hash Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Methods

showsPrec :: Int -> Hash -> ShowS #

show :: Hash -> String #

showList :: [Hash] -> ShowS #

Eq Hash Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Methods

(==) :: Hash -> Hash -> Bool #

(/=) :: Hash -> Hash -> Bool #

hashAlg :: Hash -> HashAlg Source #

The digest algorithm.

hashValue :: Hash -> Text Source #

Hex, or one sha512-… component for SRI.

mkHash :: HashAlg -> Text -> Either Text Hash Source #

Validate encoding and digest length, preserving the wire spelling. Strength is a separate admission decision.

mkSriHashes :: Text -> Either Text (NonEmpty Hash) Source #

Split SRI components, rejecting the whole string when empty or when any component is malformed.

data HashAlg Source #

A digest algorithm, ordered by integrity authority: SRI < MD5 < SHA1 < SHA256 < SHA384 < Blake2b < SHA512.

Constructors

SHA1 
SHA256 
SHA384 
SHA512 
MD5 
Blake2b 
SRI

One Subresource-Integrity component. mkSriHashes splits whitespace-separated components.

Instances

Instances details
Generic HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Associated Types

type Rep HashAlg 
Instance details

Defined in Ecluse.Core.Package.Hash

type Rep HashAlg = D1 ('MetaData "HashAlg" "Ecluse.Core.Package.Hash" "ecluse-0.4.0-inplace-ecluse-core" 'False) ((C1 ('MetaCons "SHA1" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SHA256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA384" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "SHA512" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MD5" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Blake2b" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SRI" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: HashAlg -> Rep HashAlg x #

to :: Rep HashAlg x -> HashAlg #

Show HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Eq HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Methods

(==) :: HashAlg -> HashAlg -> Bool #

(/=) :: HashAlg -> HashAlg -> Bool #

Ord HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Universe HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

Methods

universe :: [HashAlg] #

type Rep HashAlg Source # 
Instance details

Defined in Ecluse.Core.Package.Hash

type Rep HashAlg = D1 ('MetaData "HashAlg" "Ecluse.Core.Package.Hash" "ecluse-0.4.0-inplace-ecluse-core" 'False) ((C1 ('MetaCons "SHA1" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SHA256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SHA384" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "SHA512" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MD5" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Blake2b" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SRI" 'PrefixI 'False) (U1 :: Type -> Type))))

Algorithm vocabulary

renderHashAlg :: HashAlg -> Text Source #

The canonical lowercase name, also used in configuration and error text.

parseHashAlg :: Text -> Either Text HashAlg Source #

Parse canonical names and single-dash aliases, ignoring case and surrounding whitespace. SRI is not selectable.

sriPrefix :: Text -> Text Source #

The token before the first dash. Without a dash, the entire string is the prefix.

sriBody :: Text -> Text Source #

The body after the first dash, or empty text when there is no dash.

sriAlgorithm :: Text -> Maybe HashAlg Source #

Resolve an SRI prefix. An unsupported prefix asserts no algorithm and clears no integrity floor.

Digest computation

computeDigest :: HashAlg -> Maybe (LByteString -> ByteString) Source #

Digest computation for verifiable algorithms. MD5 cannot prove integrity, and SRI must first resolve its algorithm.

isComputable :: HashAlg -> Bool Source #

Whether the worker can compute and verify the algorithm.

Per-version details

data PackageDetails Source #

The ecosystem-agnostic snapshot of one package version: the signals a rule sees and the artifact facts that merge, admission, serving and the mirror read. Adapters project into it.

Constructors

PackageDetails 

Fields

Instances

Instances details
Show PackageDetails Source # 
Instance details

Defined in Ecluse.Core.Package

Eq PackageDetails Source # 
Instance details

Defined in Ecluse.Core.Package

Packument-level view

data PackageInfo Source #

A registry-independent package view containing per-version PackageDetails. Adapters own the wire format and project into this type.

Constructors

PackageInfo 

Fields

Instances

Instances details
Show PackageInfo Source # 
Instance details

Defined in Ecluse.Core.Package

Eq PackageInfo Source # 
Instance details

Defined in Ecluse.Core.Package

Dropped entries

data InvalidEntry Source #

A single registry-document entry a projection dropped as malformed rather than failing the whole document, kept so an operator can see that an upstream served one, and which.

mkInvalidEntry :: InvalidEntryKind -> Text -> Value -> Text -> InvalidEntry Source #

Record a dropped entry, reducing every URL in the key and the value to its authority: an upstream-supplied artifact location can carry a credential, and this record reaches a log line.

data InvalidEntryKind Source #

Which kind of registry-document entry a dropped InvalidEntry came from. A dropped manifest or index file loses a serve candidate, a dropped tag, time or listing only its own datum.

Constructors

InvalidVersionManifest

A versions entry whose manifest did not project (no dist/tarball, an unusable version).

InvalidDistTag

A dist-tags entry whose target was not a usable version string.

InvalidPublishTime

A time entry, keyed by a present version, that was not a decodable instant.

InvalidIndexFile

A Simple-index file entry that did not project (no name or location, an unusable digest).

InvalidVersionListing

A versions-listing entry that was not a usable version string.

renderInvalidEntryKind :: InvalidEntryKind -> Text Source #

The operator-facing label for a drop kind. It is the bucket key an operator filters on, so it is held stable as this text rather than the constructor name.

dropCountsByKind :: [InvalidEntry] -> Map Text Int Source #

How many entries dropped under each kind's label. Only the kinds actually seen appear, so a document's drop profile carries no bucket its ecosystem has no entries for.