import { Octokit as GitHubNodeAPI } from "@octokit/rest"; import * as node_fetch from "node-fetch"; import { GitHubPRDSL, GitHubIssueComment, GitHubUser } from "../../dsl/GitHubDSL"; import { api as fetch } from "../../api/fetch"; import { RepoMetaData } from "../../dsl/RepoMetaData"; import { CheckOptions } from "./comms/checks/resultsToCheck"; export type APIToken = string; export interface GitHubFile { filename: string; patch: string; status: string; } /** This represent the GitHub API */ export declare class GitHubAPI { readonly repoMetadata: RepoMetaData; readonly token?: string | undefined; fetch: typeof fetch; additionalHeaders: any; private readonly d; private pr; constructor(repoMetadata: RepoMetaData, token?: string | undefined); /** * Bit weird, yes, but we want something that can be exposed to an end-user. * I wouldn't have a problem with moving this to use this API under the hood * but for now that's just a refactor someone can try. */ getExternalAPI: (accessTokenForApp?: string) => GitHubNodeAPI; /** * Grabs the contents of an individual file on GitHub * * @param {string} path path to the file * @param {string} [ref] an optional sha * @returns {Promise} text contents * */ fileContents: (path: string, repoSlug?: string, ref?: string) => Promise; getDangerCommentIDs: (dangerID: string) => Promise; updateCommentWithID: (id: string, comment: string) => Promise; deleteCommentWithID: (id: string) => Promise; deleteInlineCommentWithID: (id: string) => Promise; getUserID: () => Promise; postPRComment: (comment: string) => Promise; postInlinePRComment: (comment: string, commitId: string, path: string, position: number) => Promise; postInlinePRReview: (commitId: string, comments: { comment: string; path: string; position: number; }[]) => Promise; updateInlinePRComment: (comment: string, commentId: string) => Promise; getPullRequestInfo: () => Promise; getPullRequestCommits: () => Promise; /** * Get list of commits in pull requests. This'll try to iterate all available pages * Until it reaches hard limit of api itself (250 commits). * https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request * */ getAllOfResource: (path: string) => Promise; getUserInfo: () => Promise; getPullRequestComments: () => Promise; getPullRequestInlineComments: (dangerID: string) => Promise<(GitHubIssueComment & { ownedByDanger: boolean; })[]>; getPullRequestFiles: (page?: number) => Promise; getPullRequestDiff: () => Promise; getFileContents: (path: string, repoSlug: string, ref: string) => Promise; getPullRequests: () => Promise; getReviewerRequests: () => Promise; getReviews: () => Promise; getIssue: () => Promise; updateStatus: (passed: boolean | "pending", message: string, url?: string, dangerID?: string, ciCommitHash?: string) => Promise; postCheckRun: (check: CheckOptions, token: string) => Promise; private api; get: (path: string, headers?: any) => Promise; post: (path: string, headers?: any, body?: any, suppressErrors?: boolean) => Promise; patch: (path: string, headers?: any, body?: any, suppressErrors?: boolean) => Promise; }