UNPKG

@codefresh-io/cf-git-providers

Version:

An NPM module/CLI for interacting with various git providers

138 lines 4.54 kB
import { Provider, Repository, Branch, Webhook, ProviderName, User, PullRequest, RepositoryPermission, PermissionScopes, GitAuth } from './types'; import { RetryConfigMap } from '../helpers/request-retry'; interface RefsScopesPermission { [key: string]: Record<string, ActionType>; } interface AccessInfo { repo: string; ref: string; user: string; groups: any; childRefs?: RefsScopesPermission; } declare const ACCESS_ACTION: { [key: string]: 'ALLOW' | 'DENY' | 'BLOCK' | 'UNKNOWN'; }; type ActionType = typeof ACCESS_ACTION[keyof typeof ACCESS_ACTION]; export default class Gerrit implements Provider { private baseUrl; private hostname; private authenticationHeader; private timeout; private agent?; private auth; private retryConfig?; constructor(opts: { password: string; username?: string; refreshToken?: string; apiURL?: string; apiUrl?: string; timeout?: number; insecure?: boolean; retryConfig?: RetryConfigMap; }); private performAPICall; private paginateForResult; getName(): ProviderName; createRepository(opts: { owner: string; repo: string; autoInit?: boolean; private?: boolean; }): Promise<Repository>; fetchRawFile(opts: { owner: string; repo: string; ref: string; path: string; }): Promise<string>; getBranch(opts: { owner: string; repo: string; branch: string; }): Promise<Branch>; getRepository(opts: { owner: string; repo: string; }): Promise<Repository>; listBranches(opts: { owner: string; repo: string; }): Promise<Branch[]>; createBranch(): Promise<Branch>; listRepositoriesForOwner(): Promise<Repository[]>; createRepositoryWebhook(): Promise<Webhook>; listWebhooks(): Promise<Webhook[]>; deleteRepositoryWebhook(): Promise<void>; listRepositoriesWithAffiliation(opts: { limit?: number; page?: number; }): Promise<Repository[]>; listOrganizations(opts: { limit?: number; page?: number; }): Promise<string[]>; getRepositoryPermissions(opts: { owner: string; repo: string; user?: string; }): Promise<RepositoryPermission>; getBranchAccess(opts: AccessInfo): Promise<RepositoryPermission>; listRepositoriesForOrganization(): Promise<Repository[]>; createCommitStatus(): Promise<void>; getUser(opts?: { username?: string; }): Promise<User>; getUserByEmail(email: string): Promise<User>; getPullRequestFiles(): Promise<string[]>; createPullRequest(): Promise<PullRequest>; getPullRequest(): Promise<PullRequest>; searchMergedPullRequestByCommitSha(): Promise<PullRequest | undefined>; assertApiScopes(opts: { scopes: PermissionScopes[]; repoUrl?: string; }): Promise<void>; validateToken(): Promise<void>; skipPermissionsValidation(): { skip: boolean; reason?: string; }; toUser(user: any, email?: string): Promise<User>; toBranch(rawBranch: any, repo: string): Promise<Branch>; toRepo(rawRepo: any): Promise<Repository>; getAvatar(account: string): Promise<any>; getProjectGitliesInfo(rawRepo: any): Promise<any>; getDefaultBranch(repoId: string, returnFullRef?: boolean): Promise<any>; getCommits(repoId: string, branch: string, pluginApiUrl?: string): Promise<any>; getCommit(repoId: string, sha: string): Promise<any>; getPlainUser(opts?: { username?: string; }): Promise<any>; getUserGroups(user: string): Promise<any>; toOwnerRepo(fullRepoName: string): [string, string]; getAuth(): GitAuth; isTokenMutable(): boolean; requiresRepoToCheckTokenScopes(): boolean; useAdminForUserPermission(): boolean; private _parseBatch; private _getGroupHigestAction; private _getMatchingRefsForBranch; private _getExclusiveResult; private _getExclusivesScopes; private _getRepoRefsPermission; private _getRefsScopesPermission; private _extractBranchName; private _parseBody; private _handleError; private _mergeRefs; private _getInheritRepoRefsPermission; private _mergeScope; private _mapActionToBool; private _getWildCardPriority; private _getSortedPathByPriority; private _getFinalBranchPermission; private _getRepoParentAccessInfo; } export {}; //# sourceMappingURL=gerrit.d.ts.map