import { SeriesBlock } from "./block.js"; import { Channel } from "./channel.js"; /** * Client to fetch or publish timeseries. * * @param url - The URL to connect to. * If the URL is not set, connect to a default server * or one set by ARRAKIS_SERVER. */ export default class Client { /** The URL to connect to the Arrakis server */ readonly initialUrl: string; /** * Creates a new Client instance. * * @param url - The URL to connect to. If not provided, will use the ARRAKIS_SERVER * environment variable or default to /arrakis */ constructor(url?: string | null); /** * Count channels matching a set of conditions * * @param {string} [pattern] - Channel pattern to match channels with, using regular expressions * @param {string|Array} [dataType] - If set, find all channels with these data types * @param {number} [minRate] - Minimum sample rate for channels * @param {number} [maxRate] - Maximum sample rate for channels * @param {string|Array} [publisher] - If set, find all channels associated with these publishers * @returns {Promise} A promise that resolves to the number of channels matching query */ count(pattern?: string, dataType?: string | Array, minRate?: number, maxRate?: number, publisher?: string | Array): Promise; /** * Find channels matching a set of conditions and stream results via Server-Sent Events (SSE) * * @param {string} [pattern] - Channel pattern to match channels with, using regular expressions * @param {string|Array} [dataType] - If set, find all channels with these data types * @param {number} [minRate] - Minimum sample rate for channels * @param {number} [maxRate] - Maximum sample rate for channels * @param {string|Array} [publisher] - If set, find all channels associated with these publishers * @returns {AsyncGenerator} An async generator that yields channel objects as they are received via SSE */ find(pattern?: string, dataType?: string | Array, minRate?: number, maxRate?: number, publisher?: string | Array): AsyncGenerator; /** * Stream timeseries data for a list of channels within a time range * * @param {string[]} channels - A list of channels to request * @param {number} [start] - GPS start time, in seconds; streams from now if omitted * @param {number} [end] - GPS end time, in seconds; streams indefinitely if omitted * @returns {AsyncGenerator} An async generator yielding `SeriesBlock`s as they stream in */ stream(channels: string[], start?: number, end?: number): AsyncGenerator; /** * Fetch timeseries data for a list of channels within a time range * * @param {string[]} channels - A list of channels to request * @param {number} start - GPS start time, in seconds * @param {number} end - GPS end time, in seconds * @returns {Promise} A promise that resolves to the block of timeseries data */ fetch(channels: string[], start: number, end: number): Promise; /** * Get channel metadata for channels requested * * @param {string[]} channels - List of channels to request * @returns {Promise>} A promise that resolves to a mapping of channel names to channel metadata */ describe(channels: string[]): Promise>; /** * Build a human-readable message from a failed HTTP response (JSON `{ detail }` or raw body). */ private static fetchErrorMessage; /** * Parses and validates a URL, falling back to environment variable or default server * @param {string | null | undefined} url - The URL to parse, or null/undefined to use environment/default * @returns {string} The parsed and validated URL */ private static parseUrl; }