import { CommitStyle, TagStyle } from "./template"; import { Branch } from "./branch"; import { Refs } from "./refs"; import { Tag } from "./tag"; import { GitgraphTagOptions } from "./user-api/gitgraph-user-api"; export { CommitRenderOptions, DetailedAuthorInfo, CustomCommitData, CommitOptions, Commit, }; interface CommitRenderOptions { renderDot?: (commit: Commit) => TNode; renderMessage?: (commit: Commit) => TNode; renderTooltip?: (commit: Commit) => TNode; } interface DetailedAuthorInfo { name: string; email: string; avatar?: string; timestamp: number; } interface CustomCommitData { id: string; documentId: string; revisionId: number; parentId: string | null; mergedParentId: string | null; name: string; majorVersion: boolean; versionPrefix: string | null; isActiveDocument: boolean; isLatestCommitInBranch: boolean; hideMinorCommits: boolean; userHasAccessToDocument: boolean; majorVersionAuthorsAvatars: string[]; numberOfMinorChanges: number; onMajorVersionClick?: (id: string) => void | Promise; updateCommitNameCallback?: (id: string, name: string) => void | Promise; createNewBranchFromCommitCallback?: (id: string) => void | Promise; mergeFromCommitCallback?: (id: string) => void | Promise; promoteToMajorVersionCallback?: (id: string) => void | Promise; } interface CommitOptions extends CommitRenderOptions { author: DetailedAuthorInfo | string; subject: string; body?: string; customData?: CustomCommitData; hash?: string; parents?: string[]; style: CommitStyle; dotText?: string; onClick?: (commit: Commit) => void; onMessageClick?: (commit: Commit) => void; onMouseOver?: (commit: Commit) => void; onMouseOut?: (commit: Commit) => void; } declare class Commit { /** * Ref names */ refs: Array; /** * Commit x position */ x: number; /** * Commit y position */ y: number; /** * Commit hash */ hash: string; /** * Abbreviated commit hash */ hashAbbrev: string; /** * Parent hashes */ parents: Array["hash"]>; /** * Abbreviated parent hashed */ parentsAbbrev: Array["hashAbbrev"]>; /** * Author */ author: { /** * Author name */ name: string; /** * Author email */ email: string; /** * Author avatar URL */ avatar?: string; /** * Author date */ timestamp: number; }; /** * Committer */ committer: { /** * Commiter name */ name: string; /** * Commiter email */ email: string; /** * Commiter avatar URL */ avatar?: string; /** * Commiter date */ timestamp: number; }; /** * Subject */ subject: string; /** * Body */ body: string; /** * Custom Data */ customData: CustomCommitData; /** * Message */ readonly message: string; /** * Style */ style: CommitStyle; /** * Text inside commit dot */ dotText?: string; /** * List of branches attached */ branches?: Array; /** * Branch that should be rendered */ readonly branchToDisplay: Branch["name"]; /** * List of tags attached */ tags?: Array>; /** * Callback to execute on click. */ onClick: () => void; /** * Callback to execute on click on the commit message. */ onMessageClick: () => void; /** * Callback to execute on mouse over. */ onMouseOver: () => void; /** * Callback to execute on mouse out. */ onMouseOut: () => void; /** * Custom dot render */ renderDot?: (commit: Commit) => TNode; /** * Custom message render */ renderMessage?: (commit: Commit) => TNode; /** * Custom tooltip render */ renderTooltip?: (commit: Commit) => TNode; constructor(options: CommitOptions); setRefs(refs: Refs): this; setTags(tags: Refs, getTagStyle: (name: Tag["name"]) => Partial, getTagRender: (name: Tag["name"]) => GitgraphTagOptions["render"]): this; setBranches(branches: Array): this; setPosition({ x, y }: { x: number; y: number; }): this; withDefaultColor(color: string): Commit; /** * Ideally, we want Commit to be a [Value Object](https://martinfowler.com/bliki/ValueObject.html). * We started with a mutable class. So we'll refactor that little by little. * This private function is a helper to create a new Commit from existing one. */ private cloneCommit; }