import type { CredentialReferenceId } from "@awp/contracts";
import { type CandidateManifest } from "@awp/domain";
import type { GitHubMergeState, GitHubPublicationState, GitHubRepositoryState, GitHubTrustedClient } from "./client-types.js";
export interface GitHubCredentialLease {
    readonly token: string;
    dispose(): void;
}
export interface GitHubCredentialResolver {
    resolve(referenceId: CredentialReferenceId, purpose: string): Promise<GitHubCredentialLease>;
}
interface FetchResponse {
    readonly ok: boolean;
    readonly status: number;
    readonly statusText: string;
    text(): Promise<string>;
}
export type GitHubFetch = (url: string, init: {
    method: string;
    headers: Readonly<Record<string, string>>;
    body?: string;
}) => Promise<FetchResponse>;
export declare class GitHubHttpError extends Error {
    readonly status: number;
    constructor(status: number, message: string);
}
export interface GitHubRepositoryIdentity {
    readonly repositoryKey: string;
    readonly owner: string;
    readonly repository: string;
}
export declare function parseGitHubRepositoryUrl(source: string): GitHubRepositoryIdentity;
export declare class GitHubTrustedHttpClient implements GitHubTrustedClient {
    private readonly credentials;
    private readonly fetcher;
    private readonly apiBase;
    constructor(credentials: GitHubCredentialResolver, fetcher?: GitHubFetch, apiBase?: string);
    inspectRepository(repositoryKey: string, credentialReferenceId: CredentialReferenceId): Promise<GitHubRepositoryState>;
    findPublicationByIdempotencyKey(input: {
        readonly repositoryKey: string;
        readonly targetRef: string;
        readonly idempotencyKey: string;
        readonly credentialReferenceId: CredentialReferenceId;
    }): Promise<GitHubPublicationState | undefined>;
    publishCandidate(input: {
        readonly repositoryKey: string;
        readonly targetRef: string;
        readonly expectedBaseRevision: string;
        readonly candidateDigest: string;
        readonly candidateManifest: CandidateManifest;
        readonly diff: string;
        readonly changeSetId: string;
        readonly factoryRunId: string;
        readonly idempotencyKey: string;
        readonly credentialReferenceId: CredentialReferenceId;
    }): Promise<GitHubPublicationState>;
    readPublication(nativeId: string, credentialReferenceId: CredentialReferenceId): Promise<GitHubPublicationState | undefined>;
    findMergeByIdempotencyKey(input: {
        readonly repositoryKey: string;
        readonly targetRef: string;
        readonly expectedTargetRevision: string;
        readonly expectedBaseRevision: string;
        readonly publicationNativeId: string;
        readonly candidateDigest: string;
        readonly candidateManifest: CandidateManifest;
        readonly idempotencyKey: string;
        readonly credentialReferenceId: CredentialReferenceId;
    }): Promise<GitHubMergeState | undefined>;
    mergePublication(input: {
        readonly repositoryKey: string;
        readonly targetRef: string;
        readonly expectedTargetRevision: string;
        readonly expectedBaseRevision: string;
        readonly publicationNativeId: string;
        readonly candidateDigest: string;
        readonly candidateManifest: CandidateManifest;
        readonly idempotencyKey: string;
        readonly credentialReferenceId: CredentialReferenceId;
    }): Promise<GitHubMergeState>;
    readMerge(nativeId: string, credentialReferenceId: CredentialReferenceId): Promise<GitHubMergeState | undefined>;
    private mergeState;
    private publicationState;
    private readRefSha;
    private repoUrl;
    private request;
}
export {};
//# sourceMappingURL=http-client.d.ts.map