import type { SourceCapabilities, SourceCommitStatus, SourceConnection, SourceConnectionTest, SourceCredential, SourceProvider, SourceProviderAdapter, SourceRefPage, SourceRepositoryPage, SourceWebhookRegistration } from './types';
export declare class SourceProviderError extends Error {
    readonly status?: number | undefined;
    readonly retryAfterSeconds?: number | undefined;
    constructor(message: string, status?: number | undefined, retryAfterSeconds?: number | undefined);
}
export interface SourceAdapterOptions {
    fetch?: SourceFetch;
    timeoutMs?: number;
    now?: () => Date;
}
export type SourceFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
declare abstract class HostedSourceAdapter implements SourceProviderAdapter {
    protected readonly connection: SourceConnection;
    protected readonly credential: SourceCredential | undefined;
    abstract readonly provider: SourceProvider;
    readonly capabilities: SourceCapabilities;
    protected readonly fetchFn: SourceFetch;
    protected readonly timeoutMs: number;
    protected readonly nowFn: () => Date;
    constructor(connection: SourceConnection, credential: SourceCredential | undefined, options?: SourceAdapterOptions);
    protected abstract apiRoot(): string;
    protected abstract authorization(): Promise<Record<string, string>>;
    protected request<T>(path: string, init?: RequestInit): Promise<{
        data: T;
        headers: Headers;
    }>;
    abstract testConnection(): Promise<SourceConnectionTest>;
    abstract listRepositories(input?: {
        cursor?: string;
        search?: string;
        limit?: number;
    }): Promise<SourceRepositoryPage>;
    abstract listBranches(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    abstract listTags(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    abstract createWebhook(repository: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    abstract listWebhooks(repository: string): Promise<SourceWebhookRegistration[]>;
    abstract updateWebhook(repository: string, webhookId: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    deleteWebhook(repository: string, webhookId: string): Promise<void>;
    abstract setCommitStatus(repository: string, commitSha: string, status: SourceCommitStatus): Promise<void>;
    protected abstract webhookPath(repository: string, webhookId?: string): string;
}
export declare class GithubSourceAdapter extends HostedSourceAdapter {
    readonly provider: 'github';
    private installationToken?;
    protected apiRoot(): string;
    protected authorization(): Promise<Record<string, string>>;
    testConnection(): Promise<SourceConnectionTest>;
    listRepositories(input?: {
        cursor?: string;
        search?: string;
        limit?: number;
    }): Promise<SourceRepositoryPage>;
    private refs;
    listBranches(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    listTags(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    protected webhookPath(repository: string, webhookId?: string): string;
    private hook;
    createWebhook(repository: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    listWebhooks(repository: string): Promise<SourceWebhookRegistration[]>;
    updateWebhook(repository: string, webhookId: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    setCommitStatus(repository: string, commitSha: string, status: SourceCommitStatus): Promise<void>;
}
export declare class GitlabSourceAdapter extends HostedSourceAdapter {
    readonly provider: 'gitlab';
    protected apiRoot(): string;
    protected authorization(): Promise<Record<string, string>>;
    testConnection(): Promise<SourceConnectionTest>;
    listRepositories(input?: {
        cursor?: string;
        search?: string;
        limit?: number;
    }): Promise<SourceRepositoryPage>;
    private refs;
    listBranches(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    listTags(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    protected webhookPath(repository: string, webhookId?: string): string;
    private hook;
    private body;
    createWebhook(repository: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    listWebhooks(repository: string): Promise<SourceWebhookRegistration[]>;
    updateWebhook(repository: string, webhookId: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    setCommitStatus(repository: string, commitSha: string, status: SourceCommitStatus): Promise<void>;
}
export declare class BitbucketSourceAdapter extends HostedSourceAdapter {
    readonly provider: 'bitbucket';
    protected apiRoot(): string;
    protected authorization(): Promise<Record<string, string>>;
    testConnection(): Promise<SourceConnectionTest>;
    listRepositories(input?: {
        cursor?: string;
        search?: string;
        limit?: number;
    }): Promise<SourceRepositoryPage>;
    private refs;
    listBranches(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    listTags(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    protected webhookPath(repository: string, webhookId?: string): string;
    private hook;
    private body;
    createWebhook(repository: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    listWebhooks(repository: string): Promise<SourceWebhookRegistration[]>;
    updateWebhook(repository: string, webhookId: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    setCommitStatus(repository: string, commitSha: string, status: SourceCommitStatus): Promise<void>;
}
export declare class GiteaSourceAdapter extends HostedSourceAdapter {
    readonly provider: 'gitea';
    readonly capabilities: SourceCapabilities;
    protected apiRoot(): string;
    protected authorization(): Promise<Record<string, string>>;
    testConnection(): Promise<SourceConnectionTest>;
    listRepositories(input?: {
        cursor?: string;
        search?: string;
        limit?: number;
    }): Promise<SourceRepositoryPage>;
    private refs;
    listBranches(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    listTags(repository: string, input?: {
        cursor?: string;
        limit?: number;
    }): Promise<SourceRefPage>;
    protected webhookPath(repository: string, webhookId?: string): string;
    private hook;
    private body;
    createWebhook(repository: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    listWebhooks(repository: string): Promise<SourceWebhookRegistration[]>;
    updateWebhook(repository: string, webhookId: string, input: {
        url: string;
        secret: string;
        events: string[];
    }): Promise<SourceWebhookRegistration>;
    setCommitStatus(repository: string, commitSha: string, status: SourceCommitStatus): Promise<void>;
}
export declare function createSourceAdapter(connection: SourceConnection, credential?: SourceCredential, options?: SourceAdapterOptions): SourceProviderAdapter;
export {};
