UNPKG

@codefresh-io/cf-git-providers

Version:

An NPM module/CLI for interacting with various git providers

254 lines 6.69 kB
export type BitbucketAuthTypes = 'basic' | 'oauth2' | 'PAT'; export type RefreshTokenHandlerReturn = Promise<{ accessToken: string; refreshToken: string; } | undefined>; export type RefreshTokenHandler = (refreshToken: string) => RefreshTokenHandlerReturn; export type DoRefreshTokenCallback = (requestOptions: any, response: any) => Promise<any>; export type ProviderConstructor = new (opt: { password: string; username?: string; isPrivateToken?: boolean; refreshToken?: string; type: BitbucketAuthTypes; apiPathPrefix?: string; apiHost?: string; apiURL?: string; timeout?: number; expires?: number; insecure?: boolean; refreshTokenHandler?: RefreshTokenHandler; }) => Provider; export type ProviderName = 'github' | 'bitbucket' | 'gitlab' | 'bitbucket-server' | 'gerrit'; export type CommitStatus = 'pending' | 'running' | 'success' | 'failure' | 'error'; export type PermissionScopes = 'repo_read' | 'repo_write' | 'repo_create' | 'admin_repo_hook'; export type GitAuth = { username?: string; password?: string; headers?: { [x: string]: string; }; }; export declare class HttpError extends Error { readonly status: number; constructor(status: number, message?: string); } export interface Provider { getName(): ProviderName; fetchRawFile(opt: { owner: string; repo: string; ref: string; path: string; }): Promise<string>; getUser(opt?: { username?: string; orgRepo?: string; commitHash?: string; }): Promise<User>; getUserByEmail(email: string, orgRepo?: string, commitHash?: string): Promise<User>; getBranch(opt: { owner: string; repo: string; branch: string; }): Promise<Branch>; getRepository(opt: { owner: string; repo: string; }): Promise<Repository>; listBranches(opt: { owner: string; repo: string; limit?: number; page?: number; branchMatchingName?: string; }): Promise<Branch[]>; createBranch(opt: { owner: string; repo: string; branch: string; sha: string; }): Promise<Branch>; listRepositoriesForOwner(opt: { owner: string; sort?: 'name' | 'pushed' | 'created'; direction?: 'desc' | 'asc'; limit?: number; page?: number; }): Promise<Repository[]>; listRepositoriesForOrganization(opt: { organization: string; sort?: 'name' | 'pushed' | 'created'; direction?: 'desc' | 'asc'; limit?: number; page?: number; }): Promise<Repository[]>; listRepositoriesWithAffiliation(opt: { affiliation?: string; sort?: 'name' | 'pushed' | 'created'; direction?: 'desc' | 'asc'; limit?: number; page?: number; filters?: RepositoryFilters; }): Promise<Repository[]>; listWebhooks(opt: { owner: string; repo: string; limit?: number; page?: number; }): Promise<Webhook[]>; listOrganizations(opt: { limit?: number; page?: number; }): Promise<string[]>; createRepositoryWebhook(opt: { owner: string; repo: string; endpoint: string; secret: string; }): Promise<Webhook>; createRepository(opt: { owner: string; repo: string; autoInit?: boolean; private?: boolean; }): Promise<Repository>; createCommitStatus(opt: { owner: string; repo: string; sha: string; targetUrl: string; state: CommitStatus; description: string; context: string; }): Promise<void>; deleteRepositoryWebhook(opt: { owner: string; repo: string; hookId: number; }): Promise<void>; getPullRequestFiles(opt: { owner: string; repo: string; pullNumber: number; }): Promise<string[]>; getPullRequest(opt: { owner: string; repo: string; pullNumber: number; }): Promise<PullRequest>; searchMergedPullRequestByCommitSha(opt: { owner: string; repo: string; sha: string; }): Promise<PullRequest | undefined>; getRepositoryPermissions(opt: { owner: string; repo: string; user?: string; }): Promise<RepositoryPermission>; assertApiScopes(opt: { scopes: PermissionScopes[]; repoUrl?: string; }): Promise<void>; validateToken(): Promise<void>; skipPermissionsValidation(): { skip: boolean; reason?: string; }; toOwnerRepo(fullRepoName: string): [string, string]; getAuth(): GitAuth; isTokenMutable(): boolean; requiresRepoToCheckTokenScopes(): boolean; useAdminForUserPermission(): boolean; createPullRequest(opt: { owner: string; repo: string; title: string; body?: string; head: string; base: string; }): Promise<PullRequest>; } export interface RepositoryPermission { read: boolean; write: boolean; } export interface RateLimit { limit: number; used: number; remaining: number; reset: number; } export interface Repository { id: string; provider: ProviderName; name: string; full_name: string; private: boolean; pushed_at: Date; open_issues: number; clone_url: string; ssh_url: string; owner: { login: string; avatar_url: string; creator: string | null; }; org?: string | null; default_branch: string; permissions: { admin: boolean | null; }; webUrl: string; project?: string; } export interface PullRequest { id: number; url: string; labels: string[]; title: string; body: string; state: string; isMerged: boolean; mergeCommitSHA: string; createdAt: Date; userLogin: string; userAvatarUrl: string; isFork: boolean; headRepo: string; headRepoUrl: string; headBranch: string; headCommitSHA: string; baseRepo: string; baseRepoUrl: string; baseBranch: string; } export interface User { login: string; avatar_url?: string; email?: string; web_url?: string; } export interface Branch { name: string; id: string; commit: Commit; } export interface Commit { sha: string; message?: string; commiter_name?: string; url?: string; } export interface Webhook { id: string; name: string; events: string[]; endpoint: string; repo: string; } export interface RepositoryFilters { name: string; } //# sourceMappingURL=types.d.ts.map