import type { CcStreamCloseReason, CcStreamConfig, CcStreamRequestFactory, CcStreamRetry, CcStreamState } from './cc-stream.types.js'; /** * CcStream manages Server-Sent Events (SSE) connections with automatic retry logic, * heartbeat monitoring, and event handling. It provides a robust streaming solution * for real-time data from the Clever Cloud API. */ export declare class CcStream { #private; /** * Creates a new CcStream instance. * * @param requestFactory - Factory function that creates HTTP requests for the stream * @param config - Configuration options for the stream including retry settings and heartbeat */ constructor(requestFactory: CcStreamRequestFactory, config: CcStreamConfig); /** * Gets the current state of the stream. * * @returns The current stream state ('init', 'connecting', 'open', 'retrying', 'paused', or 'closed') */ get state(): CcStreamState; /** * Gets the current retry count for connection attempts. * * @returns The number of retry attempts made */ get retryCount(): number; /** * Starts the stream. Returns a promise that * - resolves when the stream is closed, * - rejects when a non-retryable error occurs or when the retry limit is reached. */ start(): Promise; /** * Pauses the stream, stopping the current connection and preventing automatic retries. * The stream can be resumed later with the resume() method. * * A stream can be paused while open, while connecting (the attempt is aborted) and while retrying (the retry is * cancelled). */ pause(): void; /** * Resumes a paused stream, attempting to reconnect and continue streaming. * * On a retrying stream, it reconnects right away. Either way, the retry count goes on: only a stream that opens * starts it over, so that resuming cannot retry past `maxRetryCount`. */ resume(): void; /** * Manually closes the stream with an optional reason. * Once closed, the stream cannot be reopened. * * @param reason - The reason for closing the stream */ close(reason?: CcStreamCloseReason): void; /** * Registers a callback to be called when the stream opens successfully. * * @param callback - Function to call when the stream opens * @returns This stream instance for method chaining */ onOpen(callback: () => void): this; /** * Registers a callback to be called when the stream schedules a retry after a failed attempt. * * The stream is `retrying` when the callback runs: calling pause() from it cancels the retry. A failure that * is not retried calls nothing: it closes the stream and rejects the promise start() returned. * * @param callback - Function to call with the retry number and when the next attempt happens * @returns This stream instance for method chaining */ onRetry(callback: (retry: CcStreamRetry) => void): this; /** * Registers an event listener for the specified event type. * This is the generic event listener method used by other on* methods. * * @param type - The event type to listen for * @param callback - Function to call when the event occurs * @param options - Event listener options * @returns This stream instance for method chaining * * @template T Type of the event data */ on(type: string, callback: (event: CcStreamEvent) => void, options?: AddEventListenerOptions | boolean): this; } /** * Custom event class for CcStream events that carries typed data. * Extends the standard Event class to include strongly-typed event data. * * @template T Type of the event data */ export declare class CcStreamEvent extends Event { #private; /** * Creates a new CcStreamEvent with the specified type and data. * * @param type - The event type * @param data - The event data payload */ constructor(type: string, data: T); /** * Gets the data associated with this event. * * @returns The event data */ get data(): T; } //# sourceMappingURL=cc-stream.d.ts.map