# GitHub API reference

> Exports of @anymux/github.

Source: https://anymux-docs.n.yatsyk.com/docs/github/jsdoc

## Classes

### GitHubFileSystem

```ts
class GitHubFileSystem
```

- `constructor(config: GitHubConfig): GitHubFileSystem`
- `readFile(path: string, options?: { encoding?: BufferEncoding; flag?: string; } | BufferEncoding): Promise<Buffer | string>`
- `writeFile(path: string, data: Buffer | string | Uint8Array, _options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>`
- `appendFile(path: string, data: Buffer | string | Uint8Array, options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>`
- `copyFile(src: string, dest: string, _mode?: number): Promise<void>`
- `mkdir(path: string, _options?: { recursive?: boolean; mode?: number; }): Promise<string | undefined>`
- `readdir(path: string, options?: { encoding?: BufferEncoding; withFileTypes?: false; recursive?: boolean; }): Promise<string[]>`
- `readdir(path: string, options: { encoding?: BufferEncoding; withFileTypes: true; recursive?: boolean; }): Promise<Dirent[]>`
- `readdir(path: string, options?: any): Promise<string[] | Dirent[]>`
- `rmdir(path: string, _options?: { maxRetries?: number; recursive?: boolean; retryDelay?: number; }): Promise<void>`
- `stat(path: string, options?: { bigint?: false; }): Promise<Stats>`
- `stat(path: string, options: { bigint: true; }): Promise<BigIntStats>`
- `stat(path: string, _options?: any): Promise<Stats | BigIntStats>`
- `lstat(path: string, options?: { bigint?: false; }): Promise<Stats>`
- `lstat(path: string, options: { bigint: true; }): Promise<BigIntStats>`
- `lstat(path: string, options?: any): Promise<Stats | BigIntStats>`
- `access(path: string, _mode?: number): Promise<void>`
- `rename(oldPath: string, newPath: string): Promise<void>`
- `unlink(path: string): Promise<void>`
- `exists(path: string): Promise<boolean>`
- `truncate(_path: string, _len?: number): Promise<void>`
- `utimes(_path: string, _atime: string | number | Date, _mtime: string | number | Date): Promise<void>`
- `chmod(_path: string, _mode: string | number): Promise<void>`
- `chown(_path: string, _uid: number, _gid: number): Promise<void>`
- `readlink(_path: string, _options?: { encoding?: BufferEncoding; }): Promise<string>`
- `symlink(_target: string, _path: string, _type?: "dir" | "file" | "junction"): Promise<void>`
- `link(_existingPath: string, _newPath: string): Promise<void>`
- `createReadStream(_path: string, _options?: any): ReadStream`
- `createWriteStream(_path: string, _options?: any): WriteStream`
- `watch(_path: string, _options?: any): FSWatcher`
- `rm(_path: string, _options?: any): Promise<void>`
- `open(_path: string, _flags?: string | number, _mode?: number): Promise<IFileHandle>`
- `opendir(_path: string, _options?: any): Promise<IDir>`
- `realpath(_path: string, _options?: { encoding?: BufferEncoding; }): Promise<string>`
- `cp(_src: string, _dest: string, _options?: any): Promise<void>`
- `mkdtemp(_prefix: string, _options?: { encoding?: BufferEncoding; }): Promise<string>`
- `statfs(path: string, options?: { bigint?: false; }): Promise<StatFs>`
- `statfs(path: string, options: { bigint: true; }): Promise<BigIntStatFs>`
- `statfs(_path: string, _options?: any): Promise<StatFs | BigIntStatFs>`
- `lutimes(_path: string, _atime: string | number | Date, _mtime: string | number | Date): Promise<void>`
- `lchown(_path: string, _uid: number, _gid: number): Promise<void>`
- `lchmod(_path: string, _mode: string | number): Promise<void>`
- `isImplemented(method: string): boolean`

### GitHubGitRepo

```ts
class GitHubGitRepo
```

- `constructor(config: GitHubConfig): GitHubGitRepo`
- `listBranches(): Promise<GitBranch[]>`
- `getBranch(name: string): Promise<GitBranch>`
- `createBranch(name: string, sha: string): Promise<GitBranch>`
- `deleteBranch(name: string): Promise<void>`
- `listCommits(options?: ListCommitsOptions): Promise<GitCommit[]>`
- `getCommit(sha: string): Promise<GitCommit>`
- `listTags(): Promise<GitTag[]>`
- `createTag(name: string, sha: string, message?: string): Promise<GitTag>`
- `deleteTag(name: string): Promise<void>`
- `diff(base: string, head: string): Promise<GitDiffEntry[]>`
- `resolveRef(ref: string): Promise<string>`

### GitHubGitHost

```ts
class GitHubGitHost
```

- `constructor(config: GitHubConfig): GitHubGitHost`
- `listPullRequests(options?: ListPullRequestsOptions): Promise<PullRequest[]>`
- `getPullRequest(number: number): Promise<PullRequest>`
- `createPullRequest(options: CreatePullRequestOptions): Promise<PullRequest>`
- `updatePullRequest(number: number, updates: Partial<Pick<PullRequest, "title" | "body" | "state" | "labels">>): Promise<PullRequest>`
- `mergePullRequest(number: number, options?: { method?: "merge" | "squash" | "rebase"; commitMessage?: string; }): Promise<void>`
- `listIssues(options?: ListIssuesOptions): Promise<Issue[]>`
- `getIssue(number: number): Promise<Issue>`
- `createIssue(options: CreateIssueOptions): Promise<Issue>`
- `updateIssue(number: number, updates: Partial<Pick<Issue, "title" | "body" | "state" | "labels" | "assignees">>): Promise<Issue>`
- `listReviews(pullRequestNumber: number): Promise<Review[]>`
- `createReview(pullRequestNumber: number, review: { body: string; event: "approve" | "request_changes" | "comment"; }): Promise<Review>`
- `listReleases(): Promise<Release[]>`
- `createRelease(options: { tagName: string; name: string; body: string; draft?: boolean; prerelease?: boolean; }): Promise<Release>`
- `listPipelineRuns(options?: { branch?: string; status?: string; }): Promise<PipelineRun[]>`
- `getPipelineRun(id: number): Promise<PipelineRun>`

### GitHubProvider

```ts
class GitHubProvider
```

- `id: string`
- `name: "GitHub"`
- `capabilities: readonly CapabilityType[]`
- `constructor(config: GitHubConfig): GitHubProvider`
- `<T>(type: CapabilityType): T | undefined`
- `hasCapability(type: CapabilityType): boolean`

## Types

### GitHubConfig

```ts
type GitHubConfig = { token?: string; owner?: string; repo?: string; branch?: string; baseUrl?: string; }
```

## Constants

### GitHubConfigSchema

```ts
const GitHubConfigSchema: z.ZodObject<{ token: z.ZodString; owner: z.ZodString; repo: z.ZodString; branch: z.ZodDefault<z.ZodString>; baseUrl: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { token?: string; owner?: string; repo?: string; branch?: string; baseUrl?: string; }, { token?: string; owner?: string; repo?: string; branch?: string; baseUrl?: string; }>
```
