Add separate version tracking for artifacts
This commit is contained in:
@@ -32,6 +32,7 @@ import {
|
||||
OIDCConfig,
|
||||
OIDCConfigUpdate,
|
||||
OIDCStatus,
|
||||
PackageVersion,
|
||||
} from './types';
|
||||
|
||||
const API_BASE = '/api/v1';
|
||||
@@ -239,12 +240,21 @@ export async function listPackageArtifacts(
|
||||
}
|
||||
|
||||
// Upload
|
||||
export async function uploadArtifact(projectName: string, packageName: string, file: File, tag?: string): Promise<UploadResponse> {
|
||||
export async function uploadArtifact(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
file: File,
|
||||
tag?: string,
|
||||
version?: string
|
||||
): Promise<UploadResponse> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
if (tag) {
|
||||
formData.append('tag', tag);
|
||||
}
|
||||
if (version) {
|
||||
formData.append('version', version);
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/upload`, {
|
||||
method: 'POST',
|
||||
@@ -443,3 +453,38 @@ export function getOIDCLoginUrl(returnTo?: string): string {
|
||||
const query = params.toString();
|
||||
return `${API_BASE}/auth/oidc/login${query ? `?${query}` : ''}`;
|
||||
}
|
||||
|
||||
// Version API
|
||||
export async function listVersions(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
params: ListParams = {}
|
||||
): Promise<PaginatedResponse<PackageVersion>> {
|
||||
const query = buildQueryString(params as Record<string, unknown>);
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/versions${query}`);
|
||||
return handleResponse<PaginatedResponse<PackageVersion>>(response);
|
||||
}
|
||||
|
||||
export async function getVersion(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
version: string
|
||||
): Promise<PackageVersion> {
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/versions/${version}`);
|
||||
return handleResponse<PackageVersion>(response);
|
||||
}
|
||||
|
||||
export async function deleteVersion(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
version: string
|
||||
): Promise<void> {
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/versions/${version}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include',
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ detail: 'Unknown error' }));
|
||||
throw new Error(error.detail || `HTTP ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user