UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

83 lines • 3.79 kB
import type { ApiResponse } from '../api/client.ts'; import { ApiError } from '../api/errors.ts'; export interface GitHubTransport { get(path: string, params?: Record<string, string>): Promise<unknown>; request(method: string, path: string, body?: unknown, params?: Record<string, string>, headers?: Record<string, string>): Promise<unknown>; requestWithResponse?(method: string, path: string, body?: unknown, params?: Record<string, string>, headers?: Record<string, string>): Promise<ApiResponse>; /** GET a path's raw media type as its bytes arrive. */ stream?(path: string): AsyncIterable<Uint8Array>; } /** * The GraphQL endpoint of the install whose REST base is `baseUrl`. * * gh pairs the two by host (internal/ghinstance, GraphQLEndpoint and * RESTPrefix): github.com serves REST at https://api.github.com/ and GraphQL * at https://api.github.com/graphql, while a GitHub Enterprise Server serves * REST at https://HOST/api/v3/ and GraphQL at https://HOST/api/graphql, which * is not under the REST base. Octokit's own graphql client draws the same * line. * * Args: * baseUrl (string): the REST base the install is configured with. * * Returns: * string: the URL GraphQL queries are posted to. */ export declare function graphqlUrl(baseUrl: string): string; export declare class HttpGitHubTransport implements GitHubTransport { readonly baseUrl: string; private readonly kit; private readonly fetcher; constructor(opts: { token: string; baseUrl?: string; timeout?: number; }); get(path: string, params?: Record<string, string>): Promise<unknown>; request(method: string, path: string, body?: unknown, params?: Record<string, string>, headers?: Record<string, string>): Promise<unknown>; requestWithResponse(method: string, path: string, body?: unknown, params?: Record<string, string>, headers?: Record<string, string>): Promise<ApiResponse>; stream(path: string): AsyncGenerator<Uint8Array, void>; private send; } /** * A GitHub call that got no response: the connection was refused, the host * did not resolve, or the transport failed before any status arrived. It is * not a `GitHubApiError`, because there is no status to report, and it is * never retried. */ export declare class GitHubConnectionError extends Error { constructor(message: string); } /** * A GitHub call that answered with a status the caller cannot use. * * `body` is the response text as it arrived, `data` that text decoded (the * text itself when it is not JSON), `url` the final request URL, query * included, and `headers` the response's, lowercased, which `gh api -i` * prints for a failing response as for any other. */ export declare class GitHubApiError extends ApiError { readonly status: number; readonly body: string; readonly url: string; readonly data: unknown; readonly headers: Record<string, string>; constructor(message: string, status: number, body?: string, url?: string, headers?: Record<string, string>); } export interface GitHubTreeItem { path: string; type: 'blob' | 'tree' | 'commit'; sha: string; size?: number; } export interface GitHubRepoInfo { default_branch: string; } export declare function fetchRepoInfo(transport: GitHubTransport, owner: string, repo: string): Promise<GitHubRepoInfo>; export declare function fetchBlob(transport: GitHubTransport, owner: string, repo: string, sha: string): Promise<Uint8Array>; /** * A blob's bytes as they download, in GitHub's raw media type, or whole from * a transport that cannot stream. */ export declare function streamBlob(transport: GitHubTransport, owner: string, repo: string, sha: string): AsyncGenerator<Uint8Array, void>; //# sourceMappingURL=client.d.ts.map