import { internal } from '@launchdarkly/js-sdk-common'; import DataSourceStatusErrorInfo from '../DataSourceStatusErrorInfo'; /** * Possible states for a status result from an FDv2 data source. * * - `interrupted`: Transient error; synchronizer will retry automatically. * - `shutdown`: Graceful shutdown; no further results will be produced. * - `terminal_error`: Unrecoverable error; no further results will be produced. * - `goodbye`: Server-initiated disconnect; no further results will be produced. */ export type SourceState = 'interrupted' | 'shutdown' | 'terminal_error' | 'goodbye'; /** * A change set result containing a processed FDv2 payload. */ export interface ChangeSetResult { type: 'changeSet'; payload: internal.Payload; fdv1Fallback: boolean; environmentId?: string; /** Freshness timestamp from cache, if this result originated from cached data. */ freshness?: number; } /** * A status result indicating a state transition (error, shutdown, goodbye). */ export interface StatusResult { type: 'status'; state: SourceState; errorInfo?: DataSourceStatusErrorInfo; reason?: string; fdv1Fallback: boolean; } /** * The result type for FDv2 initializers and synchronizers. * * An initializer produces a single result, while a synchronizer produces a * stream of results. Each result is either a change set (containing a payload * of flag data) or a status (indicating a state transition like an error or * shutdown). */ export type FDv2SourceResult = ChangeSetResult | StatusResult; /** * Creates a change set result containing processed flag data. */ export declare function changeSet(payload: internal.Payload, fdv1Fallback: boolean, environmentId?: string, freshness?: number): FDv2SourceResult; /** * Creates an interrupted status result. Indicates a transient error; the * synchronizer will attempt to recover automatically. * * When used with an initializer, this is still a terminal state. */ export declare function interrupted(errorInfo: DataSourceStatusErrorInfo, fdv1Fallback: boolean): FDv2SourceResult; /** * Creates a shutdown status result. Indicates the data source was closed * gracefully and will not produce any further results. */ export declare function shutdown(): FDv2SourceResult; /** * Creates a terminal error status result. Indicates an unrecoverable error; * the data source will not produce any further results. */ export declare function terminalError(errorInfo: DataSourceStatusErrorInfo, fdv1Fallback: boolean): FDv2SourceResult; /** * Creates a goodbye status result. Indicates the server has instructed the * client to disconnect. */ export declare function goodbye(reason: string, fdv1Fallback: boolean): FDv2SourceResult; /** * Helper to create a {@link DataSourceStatusErrorInfo} from an HTTP status code. */ export declare function errorInfoFromHttpError(statusCode: number): DataSourceStatusErrorInfo; /** * Helper to create a {@link DataSourceStatusErrorInfo} from a network error. */ export declare function errorInfoFromNetworkError(message: string): DataSourceStatusErrorInfo; /** * Helper to create a {@link DataSourceStatusErrorInfo} from invalid data. */ export declare function errorInfoFromInvalidData(message: string): DataSourceStatusErrorInfo; /** * Helper to create a {@link DataSourceStatusErrorInfo} for unknown errors. */ export declare function errorInfoFromUnknown(message: string): DataSourceStatusErrorInfo; //# sourceMappingURL=FDv2SourceResult.d.ts.map