import { Env, CISource } from "../ci_source/ci_source"; import { GitJSONDSL, GitDSL } from "../dsl/GitDSL"; import { DangerResults } from "../dsl/DangerResults"; import { ExecutorOptions } from "../runner/Executor"; /** A type that represents the downloaded metadata about a code review session */ export declare type Metadata = any; /** A type that represents a comment */ export declare type Comment = { /** * UUID for the comment * * @type {string} */ id: string; /** * Textual representation of comment * * @type {string} body string */ body: string; /** * Was this posted by the account Danger has access to? * * @type {boolean} true if Danger can edit */ ownedByDanger: boolean; }; export interface Platform extends PlatformCommunicator { /** Mainly for logging and error reporting */ readonly name: string; getReviewInfo: () => Promise; /** Pulls in the platform specific metadata for inspection */ getPlatformDSLRepresentation: () => Promise; /** Pulls in the Code Review Diff, and offers a succinct user-API for it */ getPlatformGitRepresentation: () => Promise; /** Get the contents of a file at a path */ getFileContents: (path: string, slug?: string, ref?: string) => Promise; } export interface PlatformCommunicator { /** Basically, should this platform manually handle the posting of an issue itself instead of the Executor */ supportsHandlingResultsManually: () => boolean; /** Can it update comments? */ supportsCommenting: () => boolean; /** Does the platform support inline comments? */ supportsInlineComments: () => boolean; /** Allows the platform to do whatever it wants, instead of using the default commenting system */ handlePostingResults?: (results: DangerResults, options: ExecutorOptions) => void; /** Gets inline comments for current PR */ getInlineComments: (dangerID: string) => Promise; /** Creates a comment on the PR */ createComment: (dangerID: string, body: string) => Promise; /** Creates an inline comment on the PR if possible */ createInlineComment: (git: GitDSL, comment: string, path: string, line: number) => Promise; /** Updates an inline comment */ updateInlineComment: (comment: string, commentId: string) => Promise; /** Delete an inline comment */ deleteInlineComment: (commentId: string) => Promise; /** Delete the main Danger comment */ deleteMainComment: (dangerID: string) => Promise; /** Replace the main Danger comment, returning the URL to the issue */ updateOrCreateComment: (dangerID: string, newComment: string) => Promise; /** Sets the current PR's status */ updateStatus: (passed: boolean | "pending", message: string, url?: string) => Promise; } /** * Pulls out a platform for Danger to communicate on based on the environment * @param {Env} env The environment. * @param {CISource} source The existing source, to ensure they can run against each other * @returns {Platform} returns a platform if it can be supported */ export declare function getPlatformForEnv(env: Env, source: CISource, requireAuth?: boolean): Platform;