/** * GitHub API client for fetching repository content. * * Provides methods for listing files, fetching content, and reading * version information from Docusaurus-style versioned repos. */ /** * Custom error class for GitHub API errors. * Stores the HTTP status code for proper retry logic. */ export declare class GitHubAPIError extends Error { readonly statusCode?: number | undefined; constructor(message: string, statusCode?: number | undefined); /** Check if this is a client error (4xx) excluding rate limits (429) */ isNonRetryableClientError(): boolean; /** Check if this is a 404 Not Found error */ isNotFound(): boolean; /** Check if this is a rate limit error (429) */ isRateLimited(): boolean; } /** * GitHub file information. */ export interface GitHubFile { /** File path relative to repo root */ path: string; /** File name */ name: string; /** Type: file or directory */ type: 'file' | 'dir'; /** File size in bytes (for files) */ size?: number; } /** * GitHub API options. */ export interface GitHubAPIOptions { /** GitHub personal access token (optional but recommended) */ token?: string; /** Cache TTL in milliseconds (default: 5 minutes) */ cacheTtl?: number; /** Number of retries for failed requests (default: 2) */ retries?: number; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; } /** * GitHub API client with caching, retry logic, and rate limit handling. * * Uses the GitHub REST API to list files and fetch content. * Uses raw.githubusercontent.com for content fetching to avoid rate limits. */ export declare class GitHubAPI { private token?; private cache; private readonly cacheTtl; private readonly retries; private readonly timeout; constructor(options?: GitHubAPIOptions); /** * Get file content using raw.githubusercontent.com (no rate limits). * * @param repo - Repository in "owner/repo" format * @param path - File path * @param ref - Branch, tag, or commit * @returns File content as string */ getFileContent(repo: string, path: string, ref: string): Promise; /** * List all markdown files in a directory (recursive). * * @param repo - Repository in "owner/repo" format * @param path - Directory path * @param ref - Branch, tag, or commit * @param exclude - Patterns to exclude * @returns Array of file information */ listMarkdownFiles(repo: string, path: string, ref: string, exclude?: string[]): Promise; /** * Get JSON file content. * * @param repo - Repository in "owner/repo" format * @param path - JSON file path * @param ref - Branch, tag, or commit * @returns Parsed JSON */ getJsonFile(repo: string, path: string, ref: string): Promise; /** * Check if a path exists in the repository. * * @param repo - Repository in "owner/repo" format * @param path - Path to check * @param ref - Branch, tag, or commit * @returns True if path exists */ pathExists(repo: string, path: string, ref: string): Promise; /** * Get rate limit status. */ getRateLimitStatus(): Promise<{ remaining: number; limit: number; reset: Date; }>; /** * Fetch with retry logic and exponential backoff. * * @param url - URL to fetch * @param processResponse - Function to process the response * @returns Result from processResponse */ private fetchWithRetry; /** * Sleep for a specified duration. */ private sleep; /** * Recursively walk directory using GitHub API. */ private walkDirectory; /** * Process directory contents. */ private processContents; } /** * Create a GitHub API client. */ export declare function createGitHubAPI(options?: GitHubAPIOptions): GitHubAPI; //# sourceMappingURL=api.d.ts.map