use crate::sbom_generation::domain::LicenseInfo;
use crate::shared::Result;
use async_trait::async_trait;
pub type PyPiMetadata = (
Option<String>,
Option<String>,
Vec<String>,
Option<String>,
Option<String>,
);
#[async_trait]
pub trait LicenseRepository: Send + Sync {
async fn fetch_license_info(&self, package_name: &str, version: &str) -> Result<PyPiMetadata>;
async fn enrich_with_license(&self, package_name: &str, version: &str) -> Result<LicenseInfo> {
let (license, license_expression, classifiers, description, sha256_hash) =
self.fetch_license_info(package_name, version).await?;
use crate::sbom_generation::policies::LicensePriority;
Ok(LicensePriority::create_license_info(
license,
license_expression,
&classifiers,
description,
)
.with_sha256_hash(sha256_hash))
}
}