@maschinenlesbar.org/dip-bundestag-cli
    Preparing search index...

    Class RequestEngine

    Index
    bigIntegerKeys: ReadonlySet<string>

    EngineOptions.bigIntegerKeys, copied.

    • Build a fully-qualified URL from a path and optional query parameters.

      Throws a DipValidationError for a path with a "." or ".." segment: URL parsing would resolve it, so /api/v1/vorgang/. would request the list. The resource methods already reject such an id (idProblem, message Invalid vorgang id: ...); this is the backstop for callers of the engine. (Percent-encoded forms such as "%2e%2e" are safe: encodeURIComponent turns their "%" into "%25".)

      Parameters

      Returns string

    • The request URL as error messages show it: absolute (so a message names the host that gave a bad answer, which matters with a custom base URL), userinfo redacted and cut at MAX_QUOTED_LENGTH characters. It never throws: describing a URL for a message does not validate it (buildUrl does).

      Parameters

      Returns string

    • GET an absolute URL (not under the base URL) with the same policy as every other request: timeout, size cap, 429/503 retry with Retry-After, redirect following with cross-origin credential stripping. A non-2xx answer throws DipApiError (its status says which). obtainKey reads its key sources with this.

      Parameters

      • url: string
      • options: { accept: string; headers?: Record<string, string> }

      Returns Promise<RawResponse>

    • Perform a GET expecting JSON and parse it into T. Every error about the answer names the request (GET <url>: …, userinfo redacted), as a network error does.

      The text is never changed silently: bytes that are not valid in the charset, and lone surrogates written as JSON escapes (\ud800), are replaced with U+FFFD, so the result is well-formed text (jq rejects a lone surrogate, and with it the whole output), and onWarning is told how many. One bad character never sinks a whole answer.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • A value from an answer quoted for an error message (quoteValue), the base URL's credentials and the API key scrubbed first, before the cut: a 2xx answer (a shape the client refuses) can echo them as well as an error body. API code quotes server values with this.

      Parameters

      • value: string

      Returns string

    • Perform a request with Accept negotiation, transient-error retries and redirect following. headers are added to this request only (after the default headers); credential headers among them are stripped on a cross-origin redirect like the default ones.

      Parameters

      • method: string
      • path: string
      • options: { accept: string; headers?: Record<string, string>; query?: QueryParams } = ...

      Returns Promise<RawResponse>