/** * Fetches JSON data from the REST-API. * @template T * @param {string} uri - The URI to fetch JSON data from. * @param {Options} [options] - The options for the fetch request with some extensions. * @returns {Promise} A promise that resolves to the JSON response. * @throws {FetchError} If the response is not successful or cannot be parsed as JSON. */ export default function fetchRestApi(uri: string, options?: Options): Promise; /** * @typedef {Object} ExtensionOptions * @property {{ [key: string]: unknown }} [data] - The data to be included in the request as JSON. * @property {'offline' | 'online'} [model] - Selects which REST API model path to use. * * @typedef {RequestInit & ExtensionOptions} Options */ /** * Custom error class for fetch-related errors with additional HTTP context. */ export class FetchError extends Error { /** * @param {string} message - The error message. * @param {Object} [options] - Error options. * @param {number} [options.status] - HTTP status code. * @param {boolean} [options.aborted=false] - Whether the request was aborted. * @param {Object.} [options.additionalProps] - Additional properties. */ constructor(message: string, { status, aborted, ...additionalProps }?: { status?: number; aborted?: boolean; additionalProps?: { [x: string]: unknown; }; }); status: number; aborted: boolean; } export type ExtensionOptions = { /** * - The data to be included in the request as JSON. */ data?: { [key: string]: unknown; }; /** * - Selects which REST API model path to use. */ model?: "offline" | "online"; }; export type Options = RequestInit & ExtensionOptions;