import { IStatusCode } from '../utils/types'; export type IStatusCodesState = Record; /** How long a persisted status code reference is used before it is refreshed. */ export declare const STATUS_CODES_TTL_MS: number; /** How long to wait before asking again for a reference that failed to load. */ export declare const STATUS_CODES_RETRY_MS: number; declare const statusCodesState: IStatusCodesState; export declare const StatusCodesLoadState: { readonly Loading: "loading"; readonly Failed: "failed"; readonly Ready: "ready"; }; export type StatusCodesLoadState = (typeof StatusCodesLoadState)[keyof typeof StatusCodesLoadState]; /** * Returns the controller a status code belongs to, which is the part before * the first dash (`arkel-1` → `arkel`). */ export declare const getControllerFromCode: (code: string) => string | null; /** * Calls `callback` whenever codes are added to {@link statusCodesState}, * including a background refresh of a persisted reference. Returns the * unsubscribe function. */ export declare const onStatusCodesChange: (callback: () => void) => (() => void); interface IStatusCodesApiConfig { apiUrl?: string; accessToken?: string; } /** * Makes sure the description and impact level of the given status codes are * in {@link statusCodesState}, loading the reference of each controller once. * A persisted reference is used right away and refreshed in the background * once it is older than {@link STATUS_CODES_TTL_MS}. * * Components follow the result through {@link onStatusCodesChange} and * {@link getStatusCodesLoadState}. */ export declare function loadStatusCodes(codes: string[], config: IStatusCodesApiConfig): Promise; /** * Starts loading the reference of a controller before any status code of it * is known, so it can arrive together with the sensor data. */ export declare function loadStatusCodeReference(controller: string, config: IStatusCodesApiConfig): Promise; /** * Whether the names and levels of the given status codes can be shown. * Codes the reference can't cover (no API config, or no valid controller * prefix) count as ready and show as unknown. */ export declare function getStatusCodesLoadState(codes: string[], config: IStatusCodesApiConfig): StatusCodesLoadState; /** Clears the loaded and persisted status codes. */ export declare function clearStatusCodesCache(): void; export default statusCodesState;