import * as Context from "effect/Context"; import type * as Layer from "effect/Layer"; import type * as HttpClient from "effect/unstable/http/HttpClient"; import type { TlsSettings, TransportFailureVisibility } from "@packall/registry-npm"; export declare namespace Transport { /** * Everything that has to be settled before a transport can exist. * * Both members are here for the same reason: they are properties of the * *connection*, not of a request, so neither can be applied after the fact by * a caller holding a client. `tls` in particular is the whole reason this * takes an object — `strict-ssl` and `cafile` in an `.npmrc` are worth * nothing unless they reach the thing that opens the socket. */ export type Options = { readonly requestTimeoutMs: number; readonly tls: TlsSettings; }; /** The HTTP backend. */ export type Service = { /** * A client whose waits are bounded by `requestTimeoutMs`, trusting what * `tls` says to trust. * * Implementations are expected to bound the *connect* phase too where the * platform allows it. `fetch` does not, so a browser bounds whole requests * and nothing finer; Node can and must — see `./node/transport.ts`. */ readonly layerFor: (options: Options) => Layer.Layer; /** * Whether a bare `GET` of the registry root works as a reachability probe. * * True on Node, where preflight is worth having: it is what turns a dead * VPN into a named error before any real work starts. * * False in a browser, and not as a simplification — `registry.npmjs.org/` * answers 200 but sends no `access-control-allow-origin`, while every path * beneath it does. So the probe fails for a reason that has nothing to do * with whether the registry is reachable, and reporting it as unreachable * would be a lie that sends somebody looking at their network. Skipping it * costs little there: `fetch` rejects promptly on a real network failure, * and every request is bounded anyway. */ readonly canProbeRoot: boolean; /** How much diagnostic information survives when a request rejects. */ readonly failureVisibility: TransportFailureVisibility; }; } /** * Service tag for the HTTP backend. * * A service handing back a *factory* rather than a layer, because the client * cannot be built until `--timeout` has been parsed: on Node the deadline has * to reach into the connect phase, which is a property of the dispatcher and * not of a request. The composition root supplies a way to make a transport, * and the handler makes one once it knows the number. */ export class Transport extends Context.Service()( "@packall/cli/Transport", ) {}