@maschinenlesbar.org/deutsche-digitale-bibliothek-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, not a number) makes the constructor throw a DdbValidationError, and so does a transport, sleep or warn that is not a function.

    interface EngineOptions {
        baseUrl?: string;
        bigIntegerKeys?: ReadonlySet<string>;
        defaultHeaders?: 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;
        warn?: (message: string) => void;
    }
    Index
    baseUrl?: string

    Base URL of the API. Defaults to https://api.deutsche-digitale-bibliothek.de/2. Checked by validateBaseUrl: not blank, no surrounding whitespace, http(s) only, no query or fragment; anything else makes the constructor throw a DdbValidationError.

    bigIntegerKeys?: ReadonlySet<string>

    Member names whose number values are known integers past 2^53 that a double can't carry (Solr's 64-bit _version_). The value of a declared member, whatever its size, is delivered as its exact literal as written, as a JSON string ("_version_":5 becomes "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 DdbParseError. Matched by name anywhere in a JSON answer, an escaped name ("\u005fversion_") included. Defaults to none; anything but a set or list of non-empty strings makes the constructor throw a DdbValidationError. The set is copied.

    defaultHeaders?: Record<string, string>

    Extra headers sent on every request to the configured origin. When a redirect crosses to a different origin, all of them are dropped (only the engine's own Accept and User-Agent go along), so no credential — Authorization, Proxy-Authorization, Cookie, X-API-Key, X-Auth-Token or any other — leaks to an arbitrary host named in Location. Names must be HTTP tokens and values pass the same check as userAgent, or the constructor throws a DdbValidationError.

    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, one past this limit, and one whose Location echoes the base URL's credentials surface as a DdbApiError naming the target (those credentials scrubbed from it before it is resolved).

    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. Enforced by the engine for every transport.

    maxRetries?: number

    Number of automatic retries for transient (429/503) responses and reset connections, 0..MAX_RETRIES (10). Each waits retryDelayMs * attempt, or longer if the response's Retry-After asks (up to MAX_RETRY_AFTER_MS; a longer one is not retried, and the error names the requested wait).

    onRetry?: (event: RetryEvent) => void

    Called once per retry, right before the backoff sleep, for each retried 429/503 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 ddb.api (warn above is for the connection, ddb.http).

    retryDelayMs?: number

    Base backoff between retries in milliseconds (grows linearly); used without a Retry-After. At most MAX_RETRY_AFTER_MS.

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

    Injectable sleep, primarily for deterministic tests.

    timeoutMs?: number

    Per-request timeout in milliseconds (0 disables; at most MAX_TIMEOUT_MS, 2^31 - 1 ms), covering the whole response body. Enforced by the engine for every transport.

    transport?: Transport

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

    Contract: a custom transport must not follow redirects — it honours HttpRequest.redirect ("manual", e.g. fetch(url, { redirect: req.redirect })) and returns the 3xx as is, because one that follows them sends every header (defaultHeaders, the base URL's Authorization) to the redirect target before the engine sees the answer, which the library cannot prevent; it can only reject the response afterwards (a HttpResponse.url on another origin is a DdbNetworkError).

    userAgent?: string

    Value of the User-Agent header. Must be non-blank, without control characters (tab allowed) and Latin-1 only (headerValueProblem), or the constructor throws a DdbValidationError.

    warn?: (message: string) => void

    Optional diagnostic sink for non-fatal warnings (e.g. a followed https:->http: redirect downgrade). Defaults to a no-op so the client stays silent as a library; the CLI wires it to stderr.