IF Commons GitHub

transport

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-anyfs-onedrive-layers FR-003

How the store reaches a service: a function from a request to an answer, so that the live network (fetch, which Bun and Node 26 both have) and a recorded, documented or simulated service are the same to the client above it. An answer is the status, the headers in lower case and the bytes; a redirect is an answer and never followed (a redirect is an answer for the client to judge, so that a bearer token is never sent to an address nobody checked), and a connection that fails is the reason and not a thrown error.

import { fetchTransport } from "./transport.ts";
const send = fetchTransport();
// await send({ method: "GET", url: "https://graph.microsoft.com/v1.0/me/drive/root", headers: {} }, { timeoutMs: 5000 });

Source: commons/anyfs-onedrive/src/transport.ts

0 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

fetchTransportfunctionno test imports it
function fetchTransport(): Transport

The transport over fetch.

HttpMethodtypeno test imports it
type HttpMethod = "GET" | "PUT" | "DELETE";

The methods the store uses.

HttpRequesttypeno test imports it
type HttpRequest = { readonly method: HttpMethod; readonly url: string; readonly headers: Readonly<Record<string, string>>; readonly body?: Uint8Array };

A request to a service.

HttpResponsetypeno test imports it
type HttpResponse = { readonly status: number; readonly headers: Readonly<Record<string, string>>; readonly body: Uint8Array };

What a service answered.

SendOptionstypeno test imports it
type SendOptions = { readonly timeoutMs: number };

What a request is allowed.

Transporttypeno test imports it
type Transport = (request: HttpRequest, options: SendOptions) => Promise<Result<HttpResponse, string>>;

The transport: an answer, or why there was none.

Titles, headings, exports, tables, columns and requirements. Esc closes.