import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, ShowExpanded, Sudo } from '../infrastructure'; export interface PackageRegistrySchema extends Record { id: number; package_id: number; created_at: string; updated_at: string; size: number; file_store: number; file_md5?: string; file_sha1?: string; file_name: string; file: { url: string; }; file_sha256: string; verification_retry_at?: string; verified_at?: string; verification_failure?: string; verification_retry_count?: string; verification_checksum?: string; verification_state: number; verification_started_at?: string; new_file_path?: string; } export class PackageRegistry extends BaseResource { publish( projectId: string | number, packageName: string, packageVersion: string, packageFile: { content: Blob; filename: string }, options: { select: 'package_file'; contentType?: string; status?: 'default' | 'hidden'; } & Sudo & ShowExpanded, ): Promise>; publish( projectId: string | number, packageName: string, packageVersion: string, packageFile: { content: Blob; filename: string }, options?: { contentType?: string; status?: 'default' | 'hidden' } & Sudo & ShowExpanded, ): Promise>; publish( projectId: string | number, packageName: string, packageVersion: string, packageFile: { content: Blob; filename: string }, { contentType, ...options }: { contentType?: string; status?: 'default' | 'hidden'; select?: 'package_file' } & Sudo & ShowExpanded = {} as { contentType?: string }, ): Promise { return RequestHelper.put()( this, endpoint`projects/${projectId}/packages/generic/${packageName}/${packageVersion}/${packageFile.filename}`, { isForm: true, file: [packageFile.content, packageFile.filename], ...options, }, ); } download( projectId: string | number, packageName: string, packageVersion: string, filename: string, options?: Sudo & ShowExpanded, ) { return RequestHelper.get<{ message: string }>()( this, endpoint`projects/${projectId}/packages/generic/${packageName}/${packageVersion}/${filename}`, options, ); } }