Skip to main content

systemprompt_provider_contracts/
sitemap.rs

1use anyhow::Result;
2use async_trait::async_trait;
3use std::collections::HashMap;
4use systemprompt_identifiers::SourceId;
5
6#[derive(Debug)]
7pub struct SitemapContext<'a> {
8    pub base_url: &'a str,
9    pub source_name: &'a str,
10}
11
12#[derive(Debug, Clone)]
13pub struct SitemapUrlEntry {
14    pub loc: String,
15    pub lastmod: String,
16    pub changefreq: String,
17    pub priority: f32,
18}
19
20#[derive(Debug, Clone)]
21pub struct PlaceholderMapping {
22    pub placeholder: String,
23    pub field: String,
24}
25
26#[derive(Debug, Clone)]
27pub struct SitemapSourceSpec {
28    pub source_id: SourceId,
29    pub url_pattern: String,
30    pub placeholders: Vec<PlaceholderMapping>,
31    pub priority: f32,
32    pub changefreq: String,
33}
34
35#[async_trait]
36pub trait SitemapProvider: Send + Sync {
37    fn provider_id(&self) -> &'static str;
38
39    fn source_specs(&self) -> Vec<SitemapSourceSpec> {
40        vec![]
41    }
42
43    fn static_urls(&self, base_url: &str) -> Vec<SitemapUrlEntry> {
44        let _ = base_url;
45        vec![]
46    }
47
48    async fn resolve_placeholders(
49        &self,
50        ctx: &SitemapContext<'_>,
51        content: &serde_json::Value,
52        placeholders: &[PlaceholderMapping],
53    ) -> Result<HashMap<String, String>>;
54
55    fn priority(&self) -> u32 {
56        100
57    }
58}