import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation"; import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri"; import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service"; import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service"; import { IRequestService } from "@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request.service"; /** * GitHub `owner/repo` parsed from a clone URL. Only `https://github.com/...` URLs * are supported in the browser implementation. */ export interface IGitHubRepoRef { readonly owner: string; readonly repo: string; } /** * Parse a clone URL into an `owner/repo` pair. * @returns the parsed reference, or `undefined` if the URL is not a recognised * GitHub HTTPS clone URL. */ export declare function parseGitHubCloneUrl(cloneUrl: string): IGitHubRepoRef | undefined; /** * Resolve a ref (branch / tag / SHA / undefined for default branch) to a * commit SHA via the GitHub commits API. */ export declare function resolveGitHubRefToSha(requestService: IRequestService, repo: IGitHubRepoRef, ref: string | undefined, authToken: string | undefined, token: CancellationToken): Promise; /** * Thrown when GitHub responds with 401/403 to indicate the caller needs to * sign in (or has insufficient permissions) for a private repository. */ export declare class GitHubAuthRequiredError extends Error { constructor(message: string); } /** * Thrown when GitHub responds with 403 + `X-RateLimit-Remaining: 0` to * indicate the caller has exhausted the request quota for the current * window. Distinct from {@link GitHubAuthRequiredError} so callers don't * push users to sign in when the actual fix is "wait". */ export declare class GitHubRateLimitError extends Error { readonly retryAfterSeconds?: number | undefined; constructor(message: string, retryAfterSeconds?: number | undefined); } /** * Fetches the file tree of a GitHub repository at the given SHA and writes * each blob into {@link targetDir} via {@link IFileService}. * * Uses two CORS-friendly endpoints on `api.github.com` (the `/tarball/` host * has no CORS, and `raw.githubusercontent.com` rejects the OPTIONS preflight * forced by an `Authorization` header): * * - `GET /repos/{owner}/{repo}/git/trees/{sha}?recursive=1` for the listing. * - `GET /repos/{owner}/{repo}/git/blobs/{blob_sha}` for each blob (base64). * * Extraction is staged to a sibling directory and atomically swapped into * place on success; failures clean up the staging dir and leave `targetDir` * untouched. Symlinks (`mode === '120000'`) and submodules (`type === 'commit'`) * are skipped — neither is representable in the workbench virtual file system. */ export declare function fetchAndExtractGitHubRepo(requestService: IRequestService, fileService: IFileService, logService: ILogService, repo: IGitHubRepoRef, sha: string, targetDir: URI, authToken: string | undefined, token: CancellationToken): Promise;