/**
 * GitHub REST API Client
 *
 * Pure fetch-based client for GitHub issue operations.
 * Supports Personal Access Token (PAT) auth, rate limit handling,
 * and configurable base URL for GitHub Enterprise.
 *
 * No external dependencies — uses only the standard fetch API.
 */
/**
 * Minimal type matching the fields we use from GitHub's issue response.
 * Does not attempt to type the full GitHub API response.
 */
export interface GitHubIssue {
    /** GitHub's internal issue ID */
    readonly id: number;
    /** Issue number within the repository */
    readonly number: number;
    /** Issue title */
    readonly title: string;
    /** Issue body/description (markdown) */
    readonly body: string | null;
    /** Issue state */
    readonly state: 'open' | 'closed';
    /** Labels attached to the issue */
    readonly labels: readonly GitHubLabel[];
    /** Users assigned to the issue */
    readonly assignees: readonly GitHubUser[];
    /** URL to view the issue in a browser */
    readonly html_url: string;
    /** Creation timestamp (ISO 8601) */
    readonly created_at: string;
    /** Last update timestamp (ISO 8601) */
    readonly updated_at: string;
    /** Closure timestamp (ISO 8601), null if still open */
    readonly closed_at: string | null;
}
/**
 * Minimal GitHub label representation
 */
export interface GitHubLabel {
    readonly id: number;
    readonly name: string;
    readonly color: string;
    readonly description: string | null;
}
/**
 * Minimal GitHub user representation
 */
export interface GitHubUser {
    readonly login: string;
    readonly id: number;
}
/**
 * Options for listing issues
 */
export interface ListIssuesOptions {
    /** Only return issues updated after this ISO 8601 timestamp */
    since?: string;
    /** Filter by state */
    state?: 'open' | 'closed' | 'all';
    /** Results per page (max 100, default 30) */
    per_page?: number;
    /** Page number for manual pagination */
    page?: number;
}
/**
 * Input for creating a new label on a repository
 */
export interface CreateLabelInput {
    /** Label name (required) */
    name: string;
    /** Label color as hex string without '#' prefix (e.g. '0075ca') */
    color: string;
    /** Optional description for the label */
    description?: string;
}
/**
 * Input for creating a new issue
 */
export interface CreateIssueInput {
    /** Issue title (required) */
    title: string;
    /** Issue body/description */
    body?: string;
    /** Label names to attach */
    labels?: string[];
    /** Usernames to assign */
    assignees?: string[];
}
/**
 * Input for updating an existing issue
 */
export interface UpdateIssueInput {
    /** Updated title */
    title?: string;
    /** Updated body */
    body?: string;
    /** Updated state */
    state?: 'open' | 'closed';
    /** Updated label names (replaces all labels) */
    labels?: string[];
    /** Updated assignees (replaces all assignees) */
    assignees?: string[];
}
/**
 * Rate limit information parsed from GitHub response headers
 */
export interface RateLimitInfo {
    /** Total requests allowed per hour */
    readonly limit: number;
    /** Requests remaining in the current window */
    readonly remaining: number;
    /** UTC epoch timestamp when the rate limit resets */
    readonly reset: number;
}
/**
 * Configuration for creating a GitHubApiClient
 */
export interface GitHubApiClientOptions {
    /** Personal Access Token for authentication */
    token: string;
    /** Base URL for GitHub API (default: https://api.github.com) */
    apiBaseUrl?: string;
    /** Remaining requests threshold to trigger warnings (default: 10) */
    rateLimitWarningThreshold?: number;
}
/**
 * Typed error for GitHub API failures.
 * Wraps fetch errors with status code, message, and rate limit info.
 */
export declare class GitHubApiError extends Error {
    /** HTTP status code from GitHub's response */
    readonly status: number;
    /** Human-readable error message from GitHub */
    readonly statusText: string;
    /** Rate limit information at the time of the error */
    readonly rateLimit: RateLimitInfo | null;
    /** Parsed error body from GitHub (if available) */
    readonly responseBody: Record<string, unknown> | null;
    constructor(message: string, status: number, statusText: string, rateLimit?: RateLimitInfo | null, responseBody?: Record<string, unknown> | null, cause?: Error);
    /**
     * Whether this error is due to rate limiting
     */
    get isRateLimited(): boolean;
    /**
     * Whether this error is due to authentication failure
     */
    get isAuthError(): boolean;
    /**
     * Whether this error is a not-found response
     */
    get isNotFound(): boolean;
    /**
     * Returns a JSON-serializable representation of the error
     */
    toJSON(): {
        name: string;
        message: string;
        status: number;
        statusText: string;
        rateLimit: RateLimitInfo | null;
        responseBody: Record<string, unknown> | null;
    };
}
/**
 * Type guard for GitHubApiError
 */
export declare function isGitHubApiError(error: unknown): error is GitHubApiError;
/**
 * Fetch-based GitHub REST API client for issue operations.
 *
 * Features:
 * - Personal Access Token (PAT) authentication
 * - Rate limit tracking with warnings when approaching limit
 * - Configurable base URL for GitHub Enterprise
 * - Typed errors with status code and rate limit info
 * - Automatic pagination for listing issues
 *
 * @example
 * ```typescript
 * const client = new GitHubApiClient({ token: 'ghp_...' });
 * const issue = await client.getIssue('owner', 'repo', 42);
 * const issues = await client.listIssues('owner', 'repo', { state: 'open' });
 * ```
 */
export declare class GitHubApiClient {
    private readonly token;
    private readonly apiBaseUrl;
    private readonly rateLimitWarningThreshold;
    /** Most recently observed rate limit info (updated after each request) */
    private lastRateLimit;
    constructor(options: GitHubApiClientOptions);
    /**
     * Returns the most recently observed rate limit info, or null if no requests have been made.
     */
    getRateLimit(): RateLimitInfo | null;
    /**
     * Fetch a single issue by number.
     *
     * GET /repos/{owner}/{repo}/issues/{issue_number}
     */
    getIssue(owner: string, repo: string, issueNumber: number): Promise<GitHubIssue>;
    /**
     * List issues for a repository.
     *
     * GET /repos/{owner}/{repo}/issues?since=...&state=all
     *
     * When no explicit `page` is provided, this method automatically iterates
     * through all pages using the Link header and returns every matching issue.
     * When a `page` is specified, only that single page is returned.
     */
    listIssues(owner: string, repo: string, options?: ListIssuesOptions): Promise<GitHubIssue[]>;
    /**
     * Create a new issue.
     *
     * POST /repos/{owner}/{repo}/issues
     */
    createIssue(owner: string, repo: string, input: CreateIssueInput): Promise<GitHubIssue>;
    /**
     * Update an existing issue.
     *
     * PATCH /repos/{owner}/{repo}/issues/{issue_number}
     */
    updateIssue(owner: string, repo: string, issueNumber: number, updates: UpdateIssueInput): Promise<GitHubIssue>;
    /**
     * List all labels for a repository.
     *
     * GET /repos/{owner}/{repo}/labels
     *
     * Auto-paginates through all pages to return the complete label set.
     */
    getLabels(owner: string, repo: string): Promise<GitHubLabel[]>;
    /**
     * Create a new label on a repository.
     *
     * POST /repos/{owner}/{repo}/labels
     */
    createLabel(owner: string, repo: string, input: CreateLabelInput): Promise<GitHubLabel>;
    /**
     * Performs a single HTTP request to the GitHub API.
     */
    private request;
    /**
     * Performs a paginated request, following Link headers to collect all pages.
     */
    private paginatedRequest;
    /**
     * Handles non-OK responses by throwing a GitHubApiError.
     */
    private handleErrorResponse;
    /**
     * Logs a warning when rate limit is approaching exhaustion.
     */
    private checkRateLimitWarning;
}
/**
 * Parses rate limit information from GitHub response headers.
 * Returns null if the headers are not present.
 */
declare function parseRateLimitHeaders(headers: Headers): RateLimitInfo | null;
/**
 * Parses the GitHub Link header to find the "next" page URL.
 * Returns null if there is no next page.
 *
 * The Link header format is:
 *   <https://api.github.com/...?page=2>; rel="next", <https://api.github.com/...?page=5>; rel="last"
 */
declare function parseLinkHeaderNext(linkHeader: string | null): string | null;
export { parseRateLimitHeaders, parseLinkHeaderNext };
//# sourceMappingURL=github-api.d.ts.map