ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Npm.Metadata

Description

npm metadata reads for full manifests and selected versions. Both fetch the full packument because publish-age rules need its time map. Selective reads materialise only the requested version and timestamp. A version read pairs the typed projection with the selected version object, which the mirror write republishes.

Synopsis

Per-request read handle

newNpmMetadataReads :: TracingPort -> MetricsPort -> (PackageName -> MetadataError -> IO ()) -> (PackageName -> [InvalidEntry] -> IO ()) -> (PackageName -> IO ()) -> OriginFor posture -> MetadataReads posture Source #

Bind one origin's npm metadata reads to their observers, leaving the caching policy to the caller.

npm full-manifest fetch

fetchNpmManifest :: TracingPort -> OriginClient -> PackageName -> IO (Either MetadataError Manifest) Source #

Fetch compact installation metadata and the complete source digest inside the response lifetime.

The memory budget

npmChargeFactors :: ChargeFactors Source #

npm's memory charges, above the largest packed read peak per source byte (0.89, react) and output working set per basis byte of a realistic merge (1.52, @aws-sdk/client-s3) from one step up.

Reading a packument

readNpmPackument :: Limits -> PackageName -> PackumentRead -> IO ByteString -> IO (Either LimitError (StreamResult (Walked TreeRead))) Source #

Walk a packument's chunks into aeson's tree with the production field policy, over a table keyed afresh for the read.

npmPackumentWalk :: Limits -> PackageName -> PackumentRead -> InternTable -> TokenResult -> Step (Walked TreeRead) Source #

The production packument walk into aeson's tree over a caller's intern table.

readNpmFull :: Limits -> PackageName -> Text -> IO ByteString -> IO (Either LimitError (StreamResult NpmFullRead)) Source #

Walk a whole packument's chunks into its packed form, over a table keyed afresh for the read.

type NpmFullRead = Walked PackedRead Source #

What a full read finishes with: the read's table, and its typed facts and packed releases.

npmFullWalk :: Writer st -> Limits -> PackageName -> InternTable -> TokenResult -> ST st (Steps (ST st) NpmFullRead) Source #

The production full-read walk: each kept release packed by the writer against the caller's table.

npmFullTable :: Text -> PackageName -> InternTable -> ST st (InternTable, Writer st) Source #

A full read's table with the source author pointer every served release holds, and the writer that packs each release against it.

Pure projection

projectNpmStream :: Limits -> PackageName -> Text -> StreamResult (Walked TreeRead) -> Either MetadataError (PackageInfo, Value) Source #

Finish a streamed source, keeping its typed error classification.

projectNpmPacked :: Limits -> PackageName -> Text -> StreamResult NpmFullRead -> Either MetadataError (PackageInfo, PackedPackument) Source #

Finish a full read over its sealed table, keeping its typed error classification.

selectNpmRead :: Version -> Int -> (PackageInfo, Value) -> VersionRead Source #

Pair one release with its compact source object and the same document's latest tag.

selectNpmVersionDoc :: Version -> CachedDoc -> Maybe CachedDoc Source #

Select the object paired with a warm full projection under the same rendered version key.