//! DataLoader utilities for extracting references from records use serde_json::Value; /// Extract URI from a strongRef value /// strongRef format: { "$type": "com.atproto.repo.strongRef", "uri": "at://...", "cid": "..." } pub fn extract_uri_from_strong_ref(value: &Value) -> Option { if let Some(obj) = value.as_object() { // Check if this is a strongRef if let Some(type_val) = obj.get("$type") { if type_val.as_str() == Some("com.atproto.repo.strongRef") { return obj .get("uri") .and_then(|u| u.as_str()) .map(|s| s.to_string()); } } // Also support direct uri field (some lexicons might use this) if let Some(uri) = obj.get("uri") { if let Some(uri_str) = uri.as_str() { if uri_str.starts_with("at://") { return Some(uri_str.to_string()); } } } } None }