import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { BaseRequestOptions, GitlabAPIResponse, MappedOmit, PaginationRequestOptions, PaginationTypes, ShowExpanded, Sudo, } from '../infrastructure'; import type { SimpleUserSchema } from './Users'; import type { CommitSchema } from './Commits'; import type { MilestoneSchema } from '../templates/ResourceMilestones'; export interface ReleaseEvidence { sha: string; filepath: string; collected_at: string; } export interface ReleaseAssetSource { format: string; url: string; } export interface ReleaseAssetLink { id: number; name: string; url: string; external: boolean; link_type: string; } export interface ReleaseSchema extends Record { name: string | null; tag_name: string; description: string | null; created_at: string; released_at: string | null; upcoming_release: boolean | null; author: MappedOmit; commit: CommitSchema; milestones: MilestoneSchema[] | null; commit_path: string; tag_path: string; assets: { count: number; sources?: ReleaseAssetSource[] | null; links: ReleaseAssetLink[] | null; evidence_file_path: string; }; evidences: ReleaseEvidence[] | null; _links: { closed_issues_url: string; closed_merge_requests_url: string; edit_url: string; merged_merge_requests_url: string; opened_issues_url: string; opened_merge_requests_url: string; self: string; }; } export class ProjectReleases extends BaseResource { all( projectId: string | number, options?: PaginationRequestOptions

& BaseRequestOptions & { includeHtmlDescription: true }, ): Promise>; all( projectId: string | number, options?: PaginationRequestOptions

& BaseRequestOptions, ): Promise>; all( projectId: string | number, options?: PaginationRequestOptions

& BaseRequestOptions & { includeHtmlDescription?: boolean }, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases`, options, ); } create( projectId: string | number, options?: BaseRequestOptions, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/releases`, options, ); } createEvidence( projectId: string | number, tagName: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.post()( this, endpoint`projects/${projectId}/releases/${tagName}/evidence`, options, ); } edit( projectId: string | number, tagName: string, options?: BaseRequestOptions, ): Promise> { return RequestHelper.put()( this, endpoint`projects/${projectId}/releases/${tagName}`, options, ); } download( projectId: string | number, tagName: string, filepath: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases/${tagName}/downloads/${filepath}`, options, ); } downloadLatest( projectId: string | number, filepath: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases/permalink/latest/downloads/${filepath}`, options, ); } remove( projectId: string | number, tagName: string, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.del()(this, endpoint`projects/${projectId}/releases/${tagName}`, options); } show( projectId: string | number, tagName: string, options?: { includeHtmlDescription?: boolean } & Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases/${tagName}`, options, ); } showLatest( projectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases/permalink/latest`, options, ); } showLatestEvidence( projectId: string | number, options?: Sudo & ShowExpanded, ): Promise> { return RequestHelper.get()( this, endpoint`projects/${projectId}/releases/permalink/latest/evidence`, options, ); } }