ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Npm.Request

Description

npm request paths, metadata negotiation and credentials over shared HTTP mechanics.

Synopsis

Content negotiation

data MetadataForm Source #

Which of npm's two metadata documents to request, selected by the Accept header.

Constructors

Abbreviated

The install view (application/vnd.npm.install-v1+json), which drops the time map.

Full

The full packument (application/json), the only form carrying the time map.

The ecosystem's artifact hosts

npmArtifactHosts :: [Text] Source #

npm registries serve their own artifacts, so no extra hosts enter the artifact gate.

Request building

metadataRequest :: Text -> Maybe ClientCredential -> MetadataForm -> PackageName -> Either UrlFormationError Request Source #

Fetch {baseUrl}/{encoded-name} with the requested metadata form and gzip negotiation.

artifactRequestByFile :: BaseRequest -> Maybe ClientCredential -> PackageName -> Text -> Either UrlFormationError Request Source #

Fetch {base}{encoded-pkg}-/{filename} under the client's filename through requestAt.

artifactRequestByUrl :: Maybe ClientCredential -> Text -> Either UrlFormationError Request Source #

Fetch the preserved dist.tarball URL under npm's credential presentation.

artifactFileUrl :: Text -> PackageName -> Text -> Either UrlFormationError Text Source #

Encode the filename as one component in {baseUrl}{encoded-name}-/{encoded-filename}.

packageUrl :: Text -> PackageName -> Either UrlFormationError Text Source #

The metadata and publish URL for a package: {baseUrl}/{encoded-name}.

Shared internals

jsonPutRequest :: Maybe ClientCredential -> Text -> ByteString -> Either UrlFormationError Request Source #

Publish JSON under the injected credential, declaring the media type npm registries require.

withToken :: Maybe ClientCredential -> Request -> Request Source #

Attach npm's credential presentation and preserve the shared redirect and identity controls.