import { BaseResource } from '@gitbeaker/requester-utils' ; import { CommitSchema } from './Commits' ; import { RequestHelper , BaseRequestOptions , endpoint , Sudo } from '../infrastructure' ; export interface RepositoryFileExtendedSchema extends Record < string , unknown > { file_name : string ; file_path : string ; size : number ; encoding : string ; content : string ; content_sha256 : string ; ref : string ; blob_id : string ; commit_id : string ; last_commit_id : string ; } export interface RepositoryFileBlameSchema extends Record < string , unknown > { commit : CommitSchema ; lines ? : string [ ] ; } export interface RepositoryFileSchema extends Record < string , unknown > { file_path : string ; branch : string ; } export class RepositoryFiles < C extends boolean = false > extends BaseResource < C > { create ( projectId , filePath , branch , content , commitMessage , options ? ) { return RequestHelper . post < RepositoryFileSchema > ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }` , { branch , content , commitMessage , ... options , } ) ; } edit ( projectId , filePath , branch , content , commitMessage , options ? ) { return RequestHelper . put < RepositoryFileSchema > ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }` , { branch , content , commitMessage , ... options , } ) ; } remove ( projectId , filePath , branch , commitMessage , options ? ) { return RequestHelper . del ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }` , { branch , commitMessage , ... options , } ) ; } show ( projectId , filePath , ref , options ? ) { return RequestHelper . get < RepositoryFileExtendedSchema > ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }` , { ref , ... options , } ) ; } showBlame ( projectId , filePath , options ? ) { return RequestHelper . get < RepositoryFileBlameSchema [ ] > ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }/blame` , options ) ; } showRaw ( projectId , filePath , options ? ) { return RequestHelper . get ( ) ( this , endpoint `projects/${ projectId }/repository/files/${ filePath }/raw` , options ) as unknown as Promise < Blob > ; } }