import { CISource, Env } from "../ci_source/ci_source"; import { GitDSL, GitJSONDSL } from "../dsl/GitDSL"; import { DangerResults } from "../dsl/DangerResults"; import { ExecutorOptions } from "../runner/Executor"; import { DangerRunner } from "../runner/runners/runner"; /** 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 * */ id: string; /** * Textual representation of comment * */ body: string; /** * Was this posted by the account Danger has access to? */ 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 code review runs in JSON format */ getPlatformReviewDSLRepresentation: () => Promise; /** Pulls in the platform specific metadata for event runs */ getPlatformReviewSimpleRepresentation?: () => 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; /** Optional: Wrap the danger evaluation with some of your code */ executeRuntimeEnvironment?: (start: DangerRunner["runDangerfileEnvironment"], dangerfilePath: string, environment: any) => Promise; } export interface PlatformCommunicator { /** Basically, should a chance for async platform side-effects before passing the results into the comment section of danger issue create/update/deleter */ platformResultsPreMapper?: (results: DangerResults, options: ExecutorOptions, ciCommitHash?: string) => Promise; /** 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; /** Create a review with inline comments */ createInlineReview?: (git: GitDSL, comments: { comment: string; path: string; line: number; }[]) => 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, dangerID?: string, commitHash?: 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): Platform;