agent-supplements-rec 0.1.0

Curated supplement recommendation engine for longevity biomarker optimization
use crate::catalog;
use crate::errors::SupplementsError;
use crate::types::{CatalogFile, Interaction};

/// Check interactions between a set of product IDs.
/// Returns the interactions found and validates that all product IDs exist.
pub fn check_interactions<'a>(
    catalog_file: &'a CatalogFile,
    product_ids: &[String],
) -> Result<Vec<&'a Interaction>, SupplementsError> {
    // Validate all IDs exist
    for id in product_ids {
        if catalog::find_product(catalog_file, id).is_none() {
            return Err(SupplementsError::ProductNotFound(id.clone()));
        }
    }

    let ids: Vec<&str> = product_ids.iter().map(|s| s.as_str()).collect();
    Ok(catalog::find_interactions(catalog_file, &ids))
}