import { CustomEventTarget } from './custom-event-target.js'; import type { SseMessage } from '../../src/types/request.types.js'; import type { OAuthTokens } from '../oauth.types.js'; import type { QueryParams } from '../utils/query-params.types.js'; import type { RetryConfiguration, SseCloseReason } from './streams.types.js'; /** * CleverCloud specificities over an SSE * handle retry on: healthcheck timeout, non 200 * @fires CleverCloudSse#error * @fires CleverCloudSse#open * @fires CleverCloudSse#data */ export default abstract class CleverCloudSse extends CustomEventTarget { protected _apiHost: string; protected _tokens: OAuthTokens; protected _promise: Promise | undefined; protected _lastId: string | undefined; protected _lastContact: Date | undefined; protected _connectionTimeoutId: ReturnType | undefined; protected _heartbeatIntervalId: ReturnType | undefined; protected _retry: RetryConfiguration; protected _retryTimeoutId: ReturnType | undefined; retryCount: number; protected _connectionTimeout: number; state: string; protected _resolve: (reason: SseCloseReason) => void; protected _reject: (error: any) => void; protected _abortController: AbortController | undefined; constructor(apiHost: string, tokens: OAuthTokens, retryConfiguration?: RetryConfiguration, connectionTimeout?: number); /** * Build a URL from a base path and advanced query params */ buildUrl(path?: string, queryParams?: QueryParams): URL; /** * Compute full URL with query params */ abstract getUrl(): URL; /** * start the stream * cannot reject (use onError() for that) */ start(): Promise; protected _start(): Promise; pause(): void; resume(): void; /** * manually close the stream */ close(reason?: SseCloseReason): void; protected _canRetry(error: any): boolean; protected _cleanup(): void; /** * when SSE is opened */ protected _onOpen(response: Response): Promise; /** * Transform a message before an event is emitted */ transform(_event: string, data: any): any; /** * when a message is received through SSE */ protected _onMessage(msg: SseMessage): void; /** * when the SSE is closed * if a limiting parameter is reached, it's stored by the msg loop * but there is no reason given by the server in term of SSE * so we can give the reason sent in last EOS message */ protected _onClose(): void; /** * when the SSE has an error */ protected _onError(error: any): void; } export declare class NetworkError extends Error { cause: any; constructor(message: string, cause?: any); } export declare class HttpError extends Error { status: number; constructor(status: number, details: string); } export declare class ServerError extends Error { cause: any; constructor(message: string, cause?: any); } //# sourceMappingURL=clever-cloud-sse.d.ts.map