@maschinenlesbar.org/pegel-online-cli
    Preparing search index...

    Interface EngineOptions

    Options for RequestEngine and the client. The numeric options must be integers within their documented range; anything else (negative, fractional, NaN, Infinity, too large) makes the constructor throw a PegelValidationError, as does a transport or sleep that is not a function and a headers value an HTTP header can't carry.

    interface EngineOptions {
        baseUrl?: string;
        bigIntegerKeys?: ReadonlySet<string>;
        headers?: Record<string, string>;
        maxRedirects?: number;
        maxResponseBytes?: number;
        maxRetries?: number;
        onRetry?: (event: RetryEvent) => void;
        onWarning?: (message: string) => void;
        retryDelayMs?: number;
        sleep?: (ms: number) => Promise<void>;
        timeoutMs?: number;
        transport?: Transport;
        userAgent?: string;
    }
    Index
    baseUrl?: string

    Base URL of the API. Defaults to https://www.pegelonline.wsv.de

    bigIntegerKeys?: ReadonlySet<string>

    Member names whose number values may exceed 2^53 (a 64-bit id). The value of a declared member is delivered as its exact literal, as written, as a JSON string ("5"), so its type never depends on its size. A declared member whose value is not a number (a string, null, an object) is left as it is. Every undeclared number keeps the rule: exact, or a PegelParseError. Matched by name anywhere in a JSON answer, an escaped name included. Defaults to none (PEGELONLINE sends no such member); anything but a set or list of non-empty strings makes the constructor throw a PegelValidationError. The set is copied.

    headers?: Record<string, string>

    Extra headers sent on every request. Credential-bearing headers (Authorization, Cookie, X-API-Key, Proxy-Authorization) are automatically stripped when a redirect crosses to a different origin, so they never leak to an arbitrary host named in Location. This client is keyless and sets none, but library consumers may add one.

    maxRedirects?: number

    Number of HTTP redirects (301/302/303/307/308) to follow, 0..20. Defaults to 5. Any other 3xx, one with a missing or malformed Location, and one past this limit surface as a PegelApiError naming the target.

    maxResponseBytes?: number

    Hard cap on response body size in bytes (defends against memory exhaustion from a hostile/buggy endpoint). Defaults to 100 MiB; set to 0 for no limit.

    maxRetries?: number

    Number of automatic retries for transient (429/503) responses and reset connections (ECONNRESET, EPIPE, ECONNABORTED, undici's UND_ERR_SOCKET, anywhere in the error's cause chain; GET and HEAD only), 0..MAX_RETRIES (10). Each waits retryDelayMs * attempt, or longer when the response's Retry-After asks (up to MAX_RETRY_AFTER_MS; a longer one is not retried). Timeouts are not retried.

    onRetry?: (event: RetryEvent) => void

    Called once per retry, right before the backoff sleep, for each retried status and reset connection; never when there is no retry. A throw is swallowed.

    onWarning?: (message: string) => void

    Called with a one-line warning about an answer the engine delivered changed: characters that were not valid text — invalid bytes in the declared (or default UTF-8) charset, or a lone surrogate written as a JSON escape — replaced with U+FFFD. The message names the request and the count (GET <url>: 2 characters of the answer were not valid text …). Without it the replacement is silent. A throw is swallowed. The CLI logs it as a WARN record of pegel.api.

    retryDelayMs?: number

    Base backoff between retries in milliseconds (grows linearly); the floor of every wait, Retry-After or not. At most MAX_RETRY_AFTER_MS.

    sleep?: (ms: number) => Promise<void>

    Injectable sleep, primarily for deterministic tests.

    timeoutMs?: number

    Time limit per request in milliseconds, covering the whole response body, not only idle gaps (0 disables; at most MAX_TIMEOUT_MS, 2^31 - 1 ms).

    transport?: Transport

    Swappable transport. Defaults to the built-in node http/https transport.

    userAgent?: string

    Value of the User-Agent header.