import VError from 'verror'; import { AirbyteLogger } from '../logger'; import { AirbyteCatalogMessage, AirbyteConfig, AirbyteConfiguredCatalog, AirbyteConnectionStatusMessage, AirbyteMessage, AirbyteSourceConfigMessage, AirbyteSourceIdentityMessage, AirbyteState } from '../protocol'; import { AirbyteSource } from './source'; import { AirbyteStreamBase } from './streams/stream-base'; /** * Airbyte Source base class providing additional boilerplate around the Check * and Discover commands, and the logic for processing the Source's streams. The * user needs to implement the spec() and checkConnection() methods and the * streams. */ export declare abstract class AirbyteSourceBase extends AirbyteSource { protected readonly logger: AirbyteLogger; constructor(logger: AirbyteLogger); /** * Validates the provided configuration by testing the configuration values * against the source's technical system. * @param config The user-provided configuration as specified by the source's * spec. This usually contains information required to check connection e.g. * tokens, secrets and keys etc. * @return A tuple of (boolean, VError). If boolean is true, then the * connection check is successful and we can connect to the underlying data * source using the provided configuration. Otherwise, the input config cannot * be used to connect to the underlying data source, and the VError should * describe what went wrong. The VError message will be displayed to the user. */ abstract checkConnection(config: Config): Promise<[boolean, VError | undefined]>; /** * Implements the streams of this source, for creating the source catalog * and processing records from the source's technical system. * @param config The user-provided configuration as specified by the source's * spec. Any stream construction related operation should happen here. * @return A list of the streams in this source connector. */ abstract streams(config: Config): AirbyteStreamBase[]; /** * Source name */ get name(): string; /** * Source type */ abstract get type(): string; /** * Source mode */ mode(config: Config): string | undefined; /** * Implements the Discover operation from the Airbyte Specification. See * https://docs.airbyte.io/architecture/airbyte-specification. */ discover(config: Config): Promise; /** * Implements the Check Connection operation from the Airbyte Specification. * See https://docs.airbyte.io/architecture/airbyte-specification. */ check(config: Config): Promise; /** * Override to return connector-specific metadata during a check * (e.g., visible orgs, scopes, user info). Enabled via the * describe_connection config flag. * @param config The user-provided configuration. * @returns A record of key-value pairs describing the connection. */ protected describeConnection(_config: Config): Promise>; /** * Override to probe only some streams, e.g. the ones a sync would read. * @param config The user-provided configuration. * @returns The streams probeStreams() probes. */ protected probedStreams(config: Config): AirbyteStreamBase[]; /** * Probes each stream by calling stream.probe() and collects results. * Override to customize orchestration (e.g., skip certain streams). * Enabled via the probe_streams config flag. * @param config The user-provided configuration. * @returns A sorted record of stream name to pass/fail/skip result. */ protected probeStreams(config: Config): Promise>; /** * Builds the source config message emitted by read() as the single * runtime-config signal of a sync. The destination uses it to drive * source-config side effects (e.g. mock-data-feed reset) exactly once. */ sourceConfigMessage(state: AirbyteState, redactedConfig: AirbyteConfig, config: Config, redactedUserConfig?: AirbyteConfig): AirbyteSourceConfigMessage; /** * Builds the source identity message the runner emits before the pre-read * connection check (see AirbyteSourceRunner.readCommand), so the destination * can resolve account identity (faros_source_id) even when the check fails * and read() is never reached. It carries the same metadata as the config * message but is a distinct type, so the destination performs account init * from it without re-running source-config runtime side effects. */ sourceIdentityMessage(state: AirbyteState, redactedConfig: AirbyteConfig, config: Config, redactedUserConfig?: AirbyteConfig): AirbyteSourceIdentityMessage; /** * Implements the Read operation from the Airbyte Specification. See * https://docs.airbyte.io/architecture/airbyte-specification. */ read(config: Config, redactedConfig: AirbyteConfig, catalog: AirbyteConfiguredCatalog, state: AirbyteState, redactedUserConfig?: AirbyteConfig): AsyncGenerator; private readStream; private doReadStream; private checkpointState; private sliceFailureState; private sliceWarningState; private adjustLoggerLevel; /** * Validate common config options shared by all sources. * Returns an error message if validation fails, null otherwise. */ private validateCommonConfig; /** * Validate stream_freshness_hours JSON structure. * Returns an error message if invalid, null if valid. */ private validateFreshnessHoursConfig; /** * Parse and validate stream_freshness_hours config. * Returns a map of stream name to freshness hours. * Throws if config structure is invalid. */ private parseFreshnessHours; }