-- SPDX-FileCopyrightText: 2026 Alexandra de Wit
--
-- SPDX-License-Identifier: MIT
-- Full laziness allocates rarely used continuations for each member, so reads specialise here.
{-# OPTIONS_GHC -fno-full-laziness #-}

-- | PyPI full and selected Simple-index reads for "Ecluse.Core.Registry.Metadata.Fetch".
module Ecluse.Core.Registry.PyPI.Metadata (
    pypiReadWith,
    preparePyPIRead,
    pypiMirrorRead,
    pypiChargeFactors,
    pypiIndexWalk,
    projectPyPIStream,
    PyPIFullRead,
    pypiPackedWalk,
    projectPyPIPacked,
) where

import Control.Monad.ST (ST, stToIO)
import Data.JsonStream.Lexer (Cursor)
import Data.Map.Strict qualified as Map
import Data.Primitive.PrimVar (PrimVar)
import Data.Set qualified as Set

import Ecluse.Core.Package (Artifact (artEntryKey), PackageDetails (pkgArtifacts), PackageInfo (infoVersions), PackageName)
import Ecluse.Core.Package.Filter (enforceArtifactLocations, enforceArtifactLocationsOf)
import Ecluse.Core.Registry.CachedDocument (CachedDoc, pypiPacked, pypiSimpleCached)
import Ecluse.Core.Registry.Json.Intern (InternTable, tableTexts)
import Ecluse.Core.Registry.Json.Packed (docTable)
import Ecluse.Core.Registry.Json.Walk (Step, Steps, Walked (..), readJsonWalk)
import Ecluse.Core.Registry.Json.Writer (Writer, newWriter)
import Ecluse.Core.Registry.JsonStream (StreamResult (..))
import Ecluse.Core.Registry.Metadata (MetadataError, VersionDoc (..), VersionRead (..))
import Ecluse.Core.Registry.Metadata.EntryFloor (countingEntries, readFlooredWalk)
import Ecluse.Core.Registry.Metadata.Fetch.Preparation (PrepareRead (PrepareRead))
import Ecluse.Core.Registry.Metadata.Fetch.Types (DocumentWalk, EcosystemRead (..))
import Ecluse.Core.Registry.Metadata.Projection (streamError)
import Ecluse.Core.Registry.Origin (OriginClient (ocChargeFullReadWorkspace))
import Ecluse.Core.Registry.PyPI.Document (PackedSimple, SimpleDocument, restrictSimpleFiles)
import Ecluse.Core.Registry.PyPI.FileWriter (FileWriter, fileWriter)
import Ecluse.Core.Registry.PyPI.Reader (fileUniqueFields, pypiFullWalk, pypiWalk)
import Ecluse.Core.Registry.PyPI.Request (pypiArtifactHosts, simpleIndexRequestUnder)
import Ecluse.Core.Registry.PyPI.Streaming (PyPIRead (..))
import Ecluse.Core.Registry.PyPI.StreamingProjection (PyPIProjection, claimsEnvelope, collectField, emptyProjection, finishPackedProjection, finishProjection, keepsFile, packedFileStep, retainedEntries)
import Ecluse.Core.Security (AllowedHostPorts, Limits, ecosystemArtifactAuthorities, maxNestingDepth)
import Ecluse.Core.Server.Admission.Types (ChargeFactors (..))
import Ecluse.Core.Version (Version, renderVersion)

-- | Full and selected reads share the Simple-index request and field policy, with the full read's absolute workspace payer.
pypiReadWith :: (Int -> IO ()) -> EcosystemRead
pypiReadWith :: (Int -> IO ()) -> EcosystemRead
pypiReadWith Int -> IO ()
pay = (Int -> IO ())
-> (PackageName -> Text -> PyPIRead)
-> (PackageDetails -> SimpleDocument -> Maybe CachedDoc)
-> EcosystemRead
pypiReadOf Int -> IO ()
pay PackageName -> Text -> PyPIRead
SelectedRead ((SimpleDocument -> Maybe CachedDoc)
-> PackageDetails -> SimpleDocument -> Maybe CachedDoc
forall a b. a -> b -> a
const (Maybe CachedDoc -> SimpleDocument -> Maybe CachedDoc
forall a b. a -> b -> a
const Maybe CachedDoc
forall a. Maybe a
Nothing))

-- | 'pypiReadWith' under the selected origin's full-read workspace, which pays the per-entry floor.
preparePyPIRead :: PrepareRead
preparePyPIRead :: PrepareRead
preparePyPIRead = (OriginClient -> IO (Either MetadataError EcosystemRead))
-> PrepareRead
PrepareRead (Either MetadataError EcosystemRead
-> IO (Either MetadataError EcosystemRead)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either MetadataError EcosystemRead
 -> IO (Either MetadataError EcosystemRead))
-> (OriginClient -> Either MetadataError EcosystemRead)
-> OriginClient
-> IO (Either MetadataError EcosystemRead)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EcosystemRead -> Either MetadataError EcosystemRead
forall a b. b -> Either a b
Right (EcosystemRead -> Either MetadataError EcosystemRead)
-> (OriginClient -> EcosystemRead)
-> OriginClient
-> Either MetadataError EcosystemRead
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> IO ()) -> EcosystemRead
pypiReadWith ((Int -> IO ()) -> EcosystemRead)
-> (OriginClient -> Int -> IO ()) -> OriginClient -> EcosystemRead
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OriginClient -> Int -> IO ()
ocChargeFullReadWorkspace)

-- | Workers retain the supported envelope beside selected files without changing ordinary serve reads.
pypiMirrorRead :: EcosystemRead
pypiMirrorRead :: EcosystemRead
pypiMirrorRead = (Int -> IO ())
-> (PackageName -> Text -> PyPIRead)
-> (PackageDetails -> SimpleDocument -> Maybe CachedDoc)
-> EcosystemRead
pypiReadOf (IO () -> Int -> IO ()
forall a b. a -> b -> a
const IO ()
forall (f :: * -> *). Applicative f => f ()
pass) PackageName -> Text -> PyPIRead
MirrorRead (\PackageDetails
details -> CachedDoc -> Maybe CachedDoc
forall a. a -> Maybe a
Just (CachedDoc -> Maybe CachedDoc)
-> (SimpleDocument -> CachedDoc)
-> SimpleDocument
-> Maybe CachedDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDetails -> SimpleDocument -> CachedDoc
mirrorDocument PackageDetails
details)

pypiReadOf :: (Int -> IO ()) -> (PackageName -> Text -> PyPIRead) -> (PackageDetails -> SimpleDocument -> Maybe CachedDoc) -> EcosystemRead
pypiReadOf :: (Int -> IO ())
-> (PackageName -> Text -> PyPIRead)
-> (PackageDetails -> SimpleDocument -> Maybe CachedDoc)
-> EcosystemRead
pypiReadOf Int -> IO ()
pay PackageName -> Text -> PyPIRead
mode PackageDetails -> SimpleDocument -> Maybe CachedDoc
retain =
    EcosystemRead
        { erRequest :: BaseRequest
-> Maybe ClientCredential
-> PackageName
-> Either UrlFormationError Request
erRequest = BaseRequest
-> Maybe ClientCredential
-> PackageName
-> Either UrlFormationError Request
simpleIndexRequestUnder
        , erUniqueFields :: [Text]
erUniqueFields = [Text]
fileUniqueFields
        , erWalkFull :: Limits -> PackageName -> Text -> DocumentWalk PyPIFullRead
erWalkFull = \Limits
limits PackageName
name Text
_ -> (Int -> IO ())
-> Limits -> PackageName -> DocumentWalk PyPIFullRead
readPyPIFull Int -> IO ()
pay Limits
limits PackageName
name
        , erFinishFull :: Limits
-> PackageName
-> Text
-> StreamResult PyPIFullRead
-> Either MetadataError (PackageInfo, CachedDoc)
erFinishFull = Limits
-> PackageName
-> Text
-> StreamResult PyPIFullRead
-> Either MetadataError (PackageInfo, CachedDoc)
finishPyPIFull
        , erRetainedEntries :: PyPIFullRead -> RetainedEntries
erRetainedEntries = \(Walked InternTable
_ PyPIProjection
acc) -> PyPIProjection -> RetainedEntries
retainedEntries PyPIProjection
acc
        , erWalkSelected :: Limits -> PackageName -> Version -> DocumentWalk PyPIProjection
erWalkSelected = \Limits
limits PackageName
name Version
version -> Limits -> PackageName -> PyPIRead -> DocumentWalk PyPIProjection
readPyPIIndex Limits
limits PackageName
name (PackageName -> Text -> PyPIRead
mode PackageName
name (Version -> Text
renderVersion Version
version))
        , erFinishSelected :: Limits
-> PackageName
-> Text
-> Version
-> StreamResult PyPIProjection
-> Either MetadataError VersionRead
erFinishSelected = (PackageDetails -> SimpleDocument -> Maybe CachedDoc)
-> Limits
-> PackageName
-> Text
-> Version
-> StreamResult PyPIProjection
-> Either MetadataError VersionRead
finishPyPIVersion PackageDetails -> SimpleDocument -> Maybe CachedDoc
retain
        }

-- | Charges per 1000 source or output-basis bytes, calibrated with native memory probes. See @docs/testing.md@.
pypiChargeFactors :: ChargeFactors
pypiChargeFactors :: ChargeFactors
pypiChargeFactors = ChargeFactors{cfFullReadPermille :: Int
cfFullReadPermille = Int
3500, cfKeptPermille :: Int
cfKeptPermille = Int
3300, cfOutputPermille :: Int
cfOutputPermille = Int
1900}

readPyPIIndex :: Limits -> PackageName -> PyPIRead -> DocumentWalk PyPIProjection
readPyPIIndex :: Limits -> PackageName -> PyPIRead -> DocumentWalk PyPIProjection
readPyPIIndex Limits
limits PackageName
name PyPIRead
mode BodyLimit
bound InternTable
table = BodyLimit
-> (Cursor -> Step PyPIProjection)
-> IO ByteString
-> IO (Either LimitError (StreamResult PyPIProjection))
forall (m :: * -> *) s.
Monad m =>
BodyLimit
-> (Cursor -> Step s)
-> m ByteString
-> m (Either LimitError (StreamResult s))
readJsonWalk BodyLimit
bound (Limits
-> PackageName
-> PyPIRead
-> InternTable
-> Cursor
-> Step PyPIProjection
pypiIndexWalk Limits
limits PackageName
name PyPIRead
mode InternTable
table)

-- | The production Simple-index walk over a caller's intern table.
pypiIndexWalk :: Limits -> PackageName -> PyPIRead -> InternTable -> Cursor -> Step PyPIProjection
pypiIndexWalk :: Limits
-> PackageName
-> PyPIRead
-> InternTable
-> Cursor
-> Step PyPIProjection
pypiIndexWalk Limits
limits PackageName
name PyPIRead
mode InternTable
table = Int
-> PyPIRead
-> (PyPIProjection
    -> PyPIField -> Either LimitError PyPIProjection)
-> (PyPIProjection -> Bool)
-> (PyPIProjection -> Text -> Bool)
-> InternTable
-> PyPIProjection
-> Cursor
-> Step PyPIProjection
forall s.
Int
-> PyPIRead
-> (s -> PyPIField -> Either LimitError s)
-> (s -> Bool)
-> (s -> Text -> Bool)
-> InternTable
-> s
-> Cursor
-> Step s
pypiWalk (Limits -> Int
maxNestingDepth Limits
limits) PyPIRead
mode (Limits
-> PyPIProjection -> PyPIField -> Either LimitError PyPIProjection
collectField Limits
limits) PyPIProjection -> Bool
keepsFile PyPIProjection -> Text -> Bool
claimsEnvelope InternTable
table (PackageName -> PyPIProjection
emptyProjection PackageName
name)

-- | The packed read returns its final table beside the typed projection and supported files.
type PyPIFullRead = Walked PyPIProjection

readPyPIFull :: (Int -> IO ()) -> Limits -> PackageName -> DocumentWalk PyPIFullRead
readPyPIFull :: (Int -> IO ())
-> Limits -> PackageName -> DocumentWalk PyPIFullRead
readPyPIFull Int -> IO ()
pay Limits
limits PackageName
name BodyLimit
bound InternTable
table IO ByteString
readChunk = do
    writer <- ST RealWorld (Writer RealWorld) -> IO (Writer RealWorld)
forall a. ST RealWorld a -> IO a
stToIO (Maybe (Entry, Entry) -> ST RealWorld (Writer RealWorld)
forall st. Maybe (Entry, Entry) -> ST st (Writer st)
newWriter Maybe (Entry, Entry)
forall a. Maybe a
Nothing)
    build <- stToIO (fileWriter writer)
    readFlooredWalk pay (cfFullReadPermille pypiChargeFactors) bound (\PrimVar RealWorld Int
owed -> PrimVar RealWorld Int
-> Writer RealWorld
-> FileWriter RealWorld
-> Limits
-> PackageName
-> InternTable
-> Cursor
-> ST RealWorld (Steps (ST RealWorld) PyPIFullRead)
forall st.
PrimVar st Int
-> Writer st
-> FileWriter st
-> Limits
-> PackageName
-> InternTable
-> Cursor
-> ST st (Steps (ST st) PyPIFullRead)
pypiPackedWalk PrimVar RealWorld Int
owed Writer RealWorld
writer FileWriter RealWorld
build Limits
limits PackageName
name InternTable
table) readChunk

-- | Full reads use the supplied table and writer without materialising file trees, publishing the floors their retained entries owe.
pypiPackedWalk :: PrimVar st Int -> Writer st -> FileWriter st -> Limits -> PackageName -> InternTable -> Cursor -> ST st (Steps (ST st) PyPIFullRead)
pypiPackedWalk :: forall st.
PrimVar st Int
-> Writer st
-> FileWriter st
-> Limits
-> PackageName
-> InternTable
-> Cursor
-> ST st (Steps (ST st) PyPIFullRead)
pypiPackedWalk PrimVar st Int
owed Writer st
writer FileWriter st
build Limits
limits PackageName
name InternTable
table =
    FileWriter st
-> Int
-> FieldStep
     PyPIProjection PyPIField (ST st (Steps (ST st) PyPIFullRead))
-> (PyPIProjection -> Bool)
-> (PyPIProjection -> Text -> Bool)
-> (PyPIProjection
    -> Int
    -> FileValue
    -> (Either LimitError PyPIProjection
        -> ST st (Steps (ST st) PyPIFullRead))
    -> ST st (Steps (ST st) PyPIFullRead))
-> InternTable
-> PyPIProjection
-> Cursor
-> ST st (Steps (ST st) PyPIFullRead)
forall st s.
FileWriter st
-> Int
-> FieldStep s PyPIField (ST st (Steps (ST st) (Walked s)))
-> (s -> Bool)
-> (s -> Text -> Bool)
-> (s
    -> Int
    -> FileValue
    -> (Either LimitError s -> ST st (Steps (ST st) (Walked s)))
    -> ST st (Steps (ST st) (Walked s)))
-> InternTable
-> s
-> Cursor
-> ST st (Steps (ST st) (Walked s))
pypiFullWalk FileWriter st
build (Limits -> Int
maxNestingDepth Limits
limits) FieldStep
  PyPIProjection PyPIField (ST st (Steps (ST st) PyPIFullRead))
forall {r}.
PyPIProjection
-> PyPIField
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
step PyPIProjection -> Bool
keepsFile PyPIProjection -> Text -> Bool
claimsEnvelope PyPIProjection
-> Int
-> FileValue
-> (Either LimitError PyPIProjection
    -> ST st (Steps (ST st) PyPIFullRead))
-> ST st (Steps (ST st) PyPIFullRead)
forall {r}.
PyPIProjection
-> Int
-> FileValue
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
fileStep InternTable
table (PackageName -> PyPIProjection
emptyProjection PackageName
name)
  where
    counted :: (Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection -> ST st r
counted = PrimVar st Int
-> (PyPIProjection -> RetainedEntries)
-> (Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection
-> ST st r
forall st s r.
PrimVar st Int
-> (s -> RetainedEntries)
-> (Either LimitError s -> ST st r)
-> Either LimitError s
-> ST st r
countingEntries PrimVar st Int
owed PyPIProjection -> RetainedEntries
retainedEntries
    step :: PyPIProjection
-> PyPIField
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
step PyPIProjection
acc PyPIField
field Either LimitError PyPIProjection -> ST st r
next = (Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection -> ST st r
forall {r}.
(Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection -> ST st r
counted Either LimitError PyPIProjection -> ST st r
next (Limits
-> PyPIProjection -> PyPIField -> Either LimitError PyPIProjection
collectField Limits
limits PyPIProjection
acc PyPIField
field)
    fileStep :: PyPIProjection
-> Int
-> FileValue
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
fileStep PyPIProjection
acc Int
position FileValue
value Either LimitError PyPIProjection -> ST st r
next = Writer st
-> Limits
-> PyPIProjection
-> Int
-> FileValue
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
forall st r.
Writer st
-> Limits
-> PyPIProjection
-> Int
-> FileValue
-> (Either LimitError PyPIProjection -> ST st r)
-> ST st r
packedFileStep Writer st
writer Limits
limits PyPIProjection
acc Int
position FileValue
value ((Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection -> ST st r
forall {r}.
(Either LimitError PyPIProjection -> ST st r)
-> Either LimitError PyPIProjection -> ST st r
counted Either LimitError PyPIProjection -> ST st r
next)
{-# INLINE pypiPackedWalk #-}

-- | Finish packed full reads without rebuilding file trees for their typed facts.
projectPyPIPacked :: Limits -> PackageName -> StreamResult PyPIFullRead -> Either MetadataError (PackageInfo, PackedSimple)
projectPyPIPacked :: Limits
-> PackageName
-> StreamResult PyPIFullRead
-> Either MetadataError (PackageInfo, PackedSimple)
projectPyPIPacked Limits
limits PackageName
name StreamResult PyPIFullRead
streamed = do
    Walked table acc <- (ParseError -> MetadataError)
-> Either ParseError PyPIFullRead
-> Either MetadataError PyPIFullRead
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Limits -> ParseError -> MetadataError
streamError Limits
limits) (StreamResult PyPIFullRead -> Either ParseError PyPIFullRead
forall a. StreamResult a -> Either ParseError a
streamValue StreamResult PyPIFullRead
streamed)
    finishPackedProjection name (docTable (tableTexts table)) acc

finishPyPIFull :: Limits -> PackageName -> Text -> StreamResult PyPIFullRead -> Either MetadataError (PackageInfo, CachedDoc)
finishPyPIFull :: Limits
-> PackageName
-> Text
-> StreamResult PyPIFullRead
-> Either MetadataError (PackageInfo, CachedDoc)
finishPyPIFull Limits
limits PackageName
name Text
base StreamResult PyPIFullRead
streamed =
    (PackageInfo -> PackageInfo)
-> (PackedSimple -> CachedDoc)
-> (PackageInfo, PackedSimple)
-> (PackageInfo, CachedDoc)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap (AllowedHostPorts -> Text -> PackageInfo -> PackageInfo
enforceArtifactLocations AllowedHostPorts
pypiArtifactAuthorities Text
base) ((PackedSimple -> CachedDoc, CachedDoc -> Maybe PackedSimple)
-> PackedSimple -> CachedDoc
forall a b. (a, b) -> a
fst (PackedSimple -> CachedDoc, CachedDoc -> Maybe PackedSimple)
pypiPacked) ((PackageInfo, PackedSimple) -> (PackageInfo, CachedDoc))
-> Either MetadataError (PackageInfo, PackedSimple)
-> Either MetadataError (PackageInfo, CachedDoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Limits
-> PackageName
-> StreamResult PyPIFullRead
-> Either MetadataError (PackageInfo, PackedSimple)
projectPyPIPacked Limits
limits PackageName
name StreamResult PyPIFullRead
streamed

finishPyPIVersion :: (PackageDetails -> SimpleDocument -> Maybe CachedDoc) -> Limits -> PackageName -> Text -> Version -> StreamResult PyPIProjection -> Either MetadataError VersionRead
finishPyPIVersion :: (PackageDetails -> SimpleDocument -> Maybe CachedDoc)
-> Limits
-> PackageName
-> Text
-> Version
-> StreamResult PyPIProjection
-> Either MetadataError VersionRead
finishPyPIVersion PackageDetails -> SimpleDocument -> Maybe CachedDoc
retain Limits
limits PackageName
name Text
base Version
version StreamResult PyPIProjection
streamed = do
    (info, document) <- Limits
-> PackageName
-> StreamResult PyPIProjection
-> Either MetadataError (PackageInfo, SimpleDocument)
projectPyPIStream Limits
limits PackageName
name StreamResult PyPIProjection
streamed
    pure
        VersionRead
            { vrVersion = do
                details <- Map.lookup (renderVersion version) (infoVersions info)
                located <- enforceArtifactLocationsOf pypiArtifactAuthorities base details
                pure VersionDoc{vdDetails = located, vdRaw = retain located document}
            , vrBodyBytes = streamBytes streamed
            , vrUpstreamLatest = Nothing
            }

mirrorDocument :: PackageDetails -> SimpleDocument -> CachedDoc
mirrorDocument :: PackageDetails -> SimpleDocument -> CachedDoc
mirrorDocument PackageDetails
details SimpleDocument
document = (SimpleDocument -> CachedDoc, CachedDoc -> Maybe SimpleDocument)
-> SimpleDocument -> CachedDoc
forall a b. (a, b) -> a
fst (SimpleDocument -> CachedDoc, CachedDoc -> Maybe SimpleDocument)
pypiSimpleCached SimpleDocument
retained
  where
    keys :: Set EntryKey
keys = [EntryKey] -> Set EntryKey
forall a. Ord a => [a] -> Set a
Set.fromList ((Artifact -> EntryKey) -> [Artifact] -> [EntryKey]
forall a b. (a -> b) -> [a] -> [b]
map Artifact -> EntryKey
artEntryKey (NonEmpty Artifact -> [Artifact]
forall a. NonEmpty a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (PackageDetails -> NonEmpty Artifact
pkgArtifacts PackageDetails
details)))
    retained :: SimpleDocument
retained = Set EntryKey -> SimpleDocument -> SimpleDocument
restrictSimpleFiles Set EntryKey
keys SimpleDocument
document

-- | Finish a tree read, keeping files linked to their source coordinates.
projectPyPIStream :: Limits -> PackageName -> StreamResult PyPIProjection -> Either MetadataError (PackageInfo, SimpleDocument)
projectPyPIStream :: Limits
-> PackageName
-> StreamResult PyPIProjection
-> Either MetadataError (PackageInfo, SimpleDocument)
projectPyPIStream Limits
limits PackageName
name StreamResult PyPIProjection
streamed =
    (ParseError -> MetadataError)
-> Either ParseError PyPIProjection
-> Either MetadataError PyPIProjection
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Limits -> ParseError -> MetadataError
streamError Limits
limits) (StreamResult PyPIProjection -> Either ParseError PyPIProjection
forall a. StreamResult a -> Either ParseError a
streamValue StreamResult PyPIProjection
streamed) Either MetadataError PyPIProjection
-> (PyPIProjection
    -> Either MetadataError (PackageInfo, SimpleDocument))
-> Either MetadataError (PackageInfo, SimpleDocument)
forall a b.
Either MetadataError a
-> (a -> Either MetadataError b) -> Either MetadataError b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= PackageName
-> PyPIProjection
-> Either MetadataError (PackageInfo, SimpleDocument)
finishProjection PackageName
name

pypiArtifactAuthorities :: AllowedHostPorts
pypiArtifactAuthorities :: AllowedHostPorts
pypiArtifactAuthorities = [Text] -> AllowedHostPorts
ecosystemArtifactAuthorities [Text]
pypiArtifactHosts