| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data Scope
- mkScope :: Text -> Scope
- unScope :: Scope -> Text
- renderScope :: Scope -> Text
- data PackageName
- mkPackageName :: Ecosystem -> Maybe Scope -> Text -> PackageName
- pkgEcosystem :: PackageName -> Ecosystem
- pkgNamespace :: PackageName -> Maybe Scope
- pkgCanonical :: PackageName -> ShortText
- pkgBaseName :: PackageName -> ShortText
- renderPackageName :: PackageName -> Text
- unscopedName :: PackageName -> Text
- data WireNameRefusal e
- unnamespacedWireName :: (Text -> Either e PackageName) -> Maybe Text -> Text -> Either (WireNameRefusal e) PackageName
- isAsciiNameComponent :: Text -> Bool
- canonicalise :: Ecosystem -> Text -> Text
- data CodeExecSignal
- data DependencySources
- data Availability
- data Artifact = Artifact {
- artEntryKey :: EntryKey
- artFilename :: Text
- artUrl :: Text
- artHashes :: [Hash]
- artCoreMetadata :: Maybe CoreMetadata
- artSize :: Maybe Int
- data CoreMetadata
- data Hash
- hashAlg :: Hash -> HashAlg
- hashValue :: Hash -> Text
- mkHash :: HashAlg -> Text -> Either Text Hash
- mkSriHashes :: Text -> Either Text (NonEmpty Hash)
- data HashAlg
- renderHashAlg :: HashAlg -> Text
- parseHashAlg :: Text -> Either Text HashAlg
- sriPrefix :: Text -> Text
- sriBody :: Text -> Text
- sriAlgorithm :: Text -> Maybe HashAlg
- computeDigest :: HashAlg -> Maybe (LByteString -> ByteString)
- isComputable :: HashAlg -> Bool
- data PackageDetails = PackageDetails {}
- data PackageInfo = PackageInfo {}
- data InvalidEntry
- mkInvalidEntry :: InvalidEntryKind -> Text -> Value -> Text -> InvalidEntry
- data InvalidEntryKind
- renderInvalidEntryKind :: InvalidEntryKind -> Text
- dropCountsByKind :: [InvalidEntry] -> Map Text Int
Scopes
An npm scope without its leading @. mkScope removes that prefix,
so equality does not depend on how the scope was written.
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
(, excluding the display spelling.pkgEcosystem, pkgNamespace, pkgCanonical)
Instances
| Show PackageName Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> PackageName -> ShowS # show :: PackageName -> String # showList :: [PackageName] -> ShowS # | |
| Eq PackageName Source # | |
Defined in Ecluse.Core.Package | |
| Ord PackageName Source # | |
Defined in Ecluse.Core.Package Methods compare :: PackageName -> PackageName -> Ordering # (<) :: PackageName -> PackageName -> Bool # (<=) :: PackageName -> PackageName -> Bool # (>) :: PackageName -> PackageName -> Bool # (>=) :: PackageName -> PackageName -> Bool # max :: PackageName -> PackageName -> PackageName # min :: PackageName -> PackageName -> PackageName # | |
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
| Show e => Show (WireNameRefusal e) Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> WireNameRefusal e -> ShowS # show :: WireNameRefusal e -> String # showList :: [WireNameRefusal e] -> ShowS # | |
| Eq e => Eq (WireNameRefusal e) Source # | |
Defined in Ecluse.Core.Package Methods (==) :: WireNameRefusal e -> WireNameRefusal e -> Bool # (/=) :: WireNameRefusal e -> WireNameRefusal e -> Bool # | |
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
| Show CodeExecSignal Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> CodeExecSignal -> ShowS # show :: CodeExecSignal -> String # showList :: [CodeExecSignal] -> ShowS # | |
| Eq CodeExecSignal Source # | |
Defined in Ecluse.Core.Package Methods (==) :: CodeExecSignal -> CodeExecSignal -> Bool # (/=) :: CodeExecSignal -> CodeExecSignal -> Bool # | |
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. |
Instances
| Show DependencySources Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> DependencySources -> ShowS # show :: DependencySources -> String # showList :: [DependencySources] -> ShowS # | |
| Eq DependencySources Source # | |
Defined in Ecluse.Core.Package Methods (==) :: DependencySources -> DependencySources -> Bool # (/=) :: DependencySources -> DependencySources -> Bool # | |
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
| Show Availability Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> Availability -> ShowS # show :: Availability -> String # showList :: [Availability] -> ShowS # | |
| Eq Availability Source # | |
Defined in Ecluse.Core.Package | |
Artifacts
One distribution file with its source coordinate and optional metadata companion.
Constructors
| Artifact | |
Fields
| |
Instances
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
| Show CoreMetadata Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> CoreMetadata -> ShowS # show :: CoreMetadata -> String # showList :: [CoreMetadata] -> ShowS # | |
| Eq CoreMetadata Source # | |
Defined in Ecluse.Core.Package | |
An artifact digest validated by mkHash. Record updates must preserve its encoding and length.
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.
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. |
Instances
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.
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
| Show PackageDetails Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> PackageDetails -> ShowS # show :: PackageDetails -> String # showList :: [PackageDetails] -> ShowS # | |
| Eq PackageDetails Source # | |
Defined in Ecluse.Core.Package Methods (==) :: PackageDetails -> PackageDetails -> Bool # (/=) :: PackageDetails -> PackageDetails -> Bool # | |
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
| Show PackageInfo Source # | |
Defined in Ecluse.Core.Package Methods showsPrec :: Int -> PackageInfo -> ShowS # show :: PackageInfo -> String # showList :: [PackageInfo] -> ShowS # | |
| Eq PackageInfo Source # | |
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.
Instances
| Show InvalidEntry Source # | |
Defined in Ecluse.Core.Package.InvalidEntry Methods showsPrec :: Int -> InvalidEntry -> ShowS # show :: InvalidEntry -> String # showList :: [InvalidEntry] -> ShowS # | |
| Eq InvalidEntry Source # | |
Defined in Ecluse.Core.Package.InvalidEntry | |
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 |
| InvalidDistTag | A |
| InvalidPublishTime | A |
| 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. |
Instances
| Show InvalidEntryKind Source # | |
Defined in Ecluse.Core.Package.InvalidEntry Methods showsPrec :: Int -> InvalidEntryKind -> ShowS # show :: InvalidEntryKind -> String # showList :: [InvalidEntryKind] -> ShowS # | |
| Eq InvalidEntryKind Source # | |
Defined in Ecluse.Core.Package.InvalidEntry Methods (==) :: InvalidEntryKind -> InvalidEntryKind -> Bool # (/=) :: InvalidEntryKind -> InvalidEntryKind -> Bool # | |
| Ord InvalidEntryKind Source # | |
Defined in Ecluse.Core.Package.InvalidEntry Methods compare :: InvalidEntryKind -> InvalidEntryKind -> Ordering # (<) :: InvalidEntryKind -> InvalidEntryKind -> Bool # (<=) :: InvalidEntryKind -> InvalidEntryKind -> Bool # (>) :: InvalidEntryKind -> InvalidEntryKind -> Bool # (>=) :: InvalidEntryKind -> InvalidEntryKind -> Bool # max :: InvalidEntryKind -> InvalidEntryKind -> InvalidEntryKind # min :: InvalidEntryKind -> InvalidEntryKind -> InvalidEntryKind # | |
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.