Skip to main content

systemprompt_cli/commands/web/
types.rs

1//! Serializable output types for the `web` command group.
2//!
3//! These structs and enums are the rendered payloads (JSON/YAML/table) for the
4//! content-type, template, asset, and sitemap subcommands, plus the shared
5//! validation output re-exported here.
6
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9use systemprompt_identifiers::CategoryId;
10
11pub use crate::commands::shared::{ValidationIssue, ValidationOutput};
12
13#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
14pub struct ContentTypeListOutput {
15    pub content_types: Vec<ContentTypeSummary>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19pub struct ContentTypeSummary {
20    pub name: String,
21    #[serde(rename = "source_id")]
22    pub source: String,
23    pub category_id: CategoryId,
24    pub enabled: bool,
25    pub path: String,
26    pub url_pattern: Option<String>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
30pub struct ContentTypeDetailOutput {
31    pub name: String,
32    #[serde(rename = "source_id")]
33    pub source: String,
34    pub category_id: CategoryId,
35    pub enabled: bool,
36    pub path: String,
37    pub description: String,
38    pub allowed_content_types: Vec<String>,
39    pub sitemap: Option<SitemapInfo>,
40    pub branding: Option<BrandingInfo>,
41    pub indexing: Option<IndexingInfo>,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
45pub struct SitemapInfo {
46    pub enabled: bool,
47    pub url_pattern: String,
48    pub priority: f32,
49    pub changefreq: String,
50    pub fetch_from: String,
51    pub parent_route: Option<ParentRouteInfo>,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
55pub struct ParentRouteInfo {
56    pub enabled: bool,
57    pub url: String,
58    pub priority: f32,
59    pub changefreq: String,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
63pub struct BrandingInfo {
64    pub name: Option<String>,
65    pub description: Option<String>,
66    pub image: Option<String>,
67    pub keywords: Option<String>,
68}
69
70#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
71pub struct IndexingInfo {
72    pub clear_before: bool,
73    pub recursive: bool,
74    pub override_existing: bool,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
78pub struct ContentTypeCreateOutput {
79    pub name: String,
80    pub message: String,
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
84pub struct ContentTypeEditOutput {
85    pub name: String,
86    pub message: String,
87    pub changes: Vec<String>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
91pub struct ContentTypeDeleteOutput {
92    pub deleted: Vec<String>,
93    pub message: String,
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
97pub struct TemplateListOutput {
98    pub templates: Vec<TemplateSummary>,
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
102pub struct TemplateSummary {
103    pub name: String,
104    pub content_types: Vec<String>,
105    pub file_exists: bool,
106    pub file_path: String,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
110pub struct TemplateDetailOutput {
111    pub name: String,
112    pub content_types: Vec<String>,
113    pub file_path: String,
114    pub file_exists: bool,
115    pub variables: Vec<String>,
116    pub preview_lines: Vec<String>,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
120pub struct TemplateCreateOutput {
121    pub name: String,
122    pub file_path: String,
123    pub message: String,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
127pub struct TemplateEditOutput {
128    pub name: String,
129    pub message: String,
130    pub changes: Vec<String>,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
134pub struct TemplateDeleteOutput {
135    pub deleted: String,
136    pub file_deleted: bool,
137    pub message: String,
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
141pub struct AssetListOutput {
142    pub assets: Vec<AssetSummary>,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
146pub struct AssetSummary {
147    pub path: String,
148    pub asset_type: AssetType,
149    pub size_bytes: u64,
150    pub modified: String,
151}
152
153#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
154#[serde(rename_all = "lowercase")]
155pub enum AssetType {
156    Css,
157    Logo,
158    Favicon,
159    Font,
160    Image,
161    Other,
162}
163
164impl std::fmt::Display for AssetType {
165    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
166        match self {
167            Self::Css => write!(f, "css"),
168            Self::Logo => write!(f, "logo"),
169            Self::Favicon => write!(f, "favicon"),
170            Self::Font => write!(f, "font"),
171            Self::Image => write!(f, "image"),
172            Self::Other => write!(f, "other"),
173        }
174    }
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
178pub struct AssetDetailOutput {
179    pub path: String,
180    pub absolute_path: String,
181    pub asset_type: AssetType,
182    pub size_bytes: u64,
183    pub modified: String,
184    pub referenced_in: Vec<String>,
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
188pub struct SitemapShowOutput {
189    pub routes: Vec<SitemapRoute>,
190    pub total_routes: usize,
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
194pub struct SitemapRoute {
195    pub url: String,
196    pub priority: f32,
197    pub changefreq: String,
198    pub source: String,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
202pub struct SitemapGenerateOutput {
203    pub output_path: String,
204    pub routes_count: usize,
205    pub message: String,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct TemplatesConfig {
210    pub templates: std::collections::HashMap<String, TemplateEntry>,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
214pub struct TemplateEntry {
215    pub content_types: Vec<String>,
216}