import { alamos } from "@synnaxlabs/alamos";
import { type channel, type Synnax } from "@synnaxlabs/client";
import { type TimeRange, type AsyncDestructor } from "@synnaxlabs/x";
import { type StreamHandler } from './streamer';
import { type ReadResponse } from './types';
/**
 * A client that can be used to retrieve a channel from the Synnax cluster
 * by its key.
 */
export interface ChannelClient {
    /**
     * Retrieves a channel from the Synnax cluster by its key.
     *
     * @param key - The key of the channel to retrieve.
     * @returns the channel with the given key.
     * @throws QueryError if the channel does not exist.
     */
    retrieveChannel: (key: channel.Key) => Promise<channel.Payload>;
}
/** A client that can be used to read telemetry from the Synnax cluster. */
export interface ReadClient {
    /**
     * Reads telemetry from the given channels for the given time range.
     *
     * @param tr  - The time range to read from.
     * @param keys - The keys of the channels to read from.
     * @returns a record with a read response for each channel in keys, regardless of
     * whether or not data was found for the given chnannel. NOTE: Responses are not
     * guaranteed to have the same topology i.e each response may contain a different
     * number of Series with different lengths. It's up to the caller to use the
     * 'alignment' field of the Series to normalize the data shape if necessary.
     */
    read: (tr: TimeRange, keys: channel.Keys) => Promise<Record<channel.Key, ReadResponse>>;
}
/** A client that can be used to stream telemetry from the Synnax cluster. */
export interface StreamClient {
    stream: (handler: StreamHandler, keys: channel.Keys) => Promise<AsyncDestructor>;
}
/**
 * Client provides an interface for performing basic telemetry operations
 * against a Synnax cluster. This interface is a simplification of the Synnax
 * client to make it easy to stub out for testing.
 */
export interface Client extends ChannelClient, ReadClient, StreamClient {
    key: string;
    /** Close closes the client, releasing all resources from the cache. */
    close: () => Promise<void>;
}
/**
 * Proxy is a Client implementation that proxies all operations to another Client,
 * allowing the underlying Client to be swapped out at runtime. If no Client is
 * set, all operations will throw an error.
 */
export declare class Proxy implements Client {
    key: string;
    _client: Client | null;
    swap(client: Client | null): Promise<void>;
    /** Implements ChannelClient. */
    retrieveChannel(key: channel.Key): Promise<channel.Payload>;
    /** Implements ReadClient. */
    read(tr: TimeRange, channels: channel.Keys): Promise<Record<channel.Key, ReadResponse>>;
    /** Stream implements StreamClient. */
    stream(handler: StreamHandler, keys: channel.Keys): Promise<AsyncDestructor>;
    /** Close implements CLient. */
    close(): Promise<void>;
    private get client();
}
interface CoreProps {
    core: Synnax;
    instrumentation: alamos.Instrumentation;
}
/**
 * Core wraps a Synnax client to implement the pluto telemetry Client interface,
 * adding a transparent caching layer.
 */
export declare class Core implements Client {
    readonly key: string;
    private readonly ins;
    private readonly cache;
    private readonly reader;
    private readonly streamer;
    private readonly channelRetriever;
    constructor({ instrumentation, core }: CoreProps);
    /** Implements ChannelClient. */
    retrieveChannel(key: channel.Key): Promise<channel.Payload>;
    /** Implements ChannelClient */
    read(tr: TimeRange, keys: channel.Keys): Promise<Record<channel.Key, ReadResponse>>;
    stream(handler: StreamHandler, keys: channel.Keys): Promise<AsyncDestructor>;
    /** Implements Client. */
    close(): Promise<void>;
}
export {};
