Fix PackageArtifactResponse missing sha256 and version fields

- Add sha256 field to list_package_artifacts response (artifact ID is SHA256)
- Add version field to PackageArtifactResponse schema
- Add version field to frontend PackageArtifact type
- Update getArtifactVersion to prefer direct version field
This commit is contained in:
Mondo Diaz
2026-02-03 16:24:31 -06:00
parent c0c8603d05
commit 1ae989249b
4 changed files with 8 additions and 2 deletions

View File

@@ -4817,9 +4817,13 @@ def list_package_artifacts(
artifact_responses.append(
PackageArtifactResponse(
id=artifact.id,
sha256=artifact.id, # Artifact ID is the SHA256 hash
size=artifact.size,
content_type=artifact.content_type,
original_name=artifact.original_name,
checksum_md5=artifact.checksum_md5,
checksum_sha1=artifact.checksum_sha1,
s3_etag=artifact.s3_etag,
created_at=artifact.created_at,
created_by=artifact.created_by,
format_metadata=artifact.format_metadata,

View File

@@ -256,6 +256,7 @@ class PackageArtifactResponse(BaseModel):
created_at: datetime
created_by: str
format_metadata: Optional[Dict[str, Any]] = None
version: Optional[str] = None # Version from PackageVersion if exists
class Config:
from_attributes = True

View File

@@ -313,9 +313,9 @@ function PackagePage() {
}
};
// Helper to get version from artifact metadata
// Helper to get version from artifact - prefer direct version field, fallback to metadata
const getArtifactVersion = (a: PackageArtifact): string | null => {
return (a.format_metadata?.version as string) || null;
return a.version || (a.format_metadata?.version as string) || null;
};
// Helper to get download ref - prefer version, fallback to artifact ID

View File

@@ -58,6 +58,7 @@ export interface PackageArtifact {
created_at: string;
created_by: string;
format_metadata?: Record<string, unknown> | null;
version?: string | null; // Version from PackageVersion if exists
}
export interface PackageVersion {