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 ContentTypeSummary {
15    pub name: String,
16    #[serde(rename = "source_id")]
17    pub source: String,
18    pub category_id: CategoryId,
19    pub enabled: bool,
20    pub path: String,
21    pub url_pattern: Option<String>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
25pub struct ContentTypeDetailOutput {
26    pub name: String,
27    #[serde(rename = "source_id")]
28    pub source: String,
29    pub category_id: CategoryId,
30    pub enabled: bool,
31    pub path: String,
32    pub description: String,
33    pub allowed_content_types: Vec<String>,
34    pub sitemap: Option<SitemapInfo>,
35    pub branding: Option<BrandingInfo>,
36    pub indexing: Option<IndexingInfo>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
40pub struct SitemapInfo {
41    pub enabled: bool,
42    pub url_pattern: String,
43    pub priority: f32,
44    pub changefreq: String,
45    pub fetch_from: String,
46    pub parent_route: Option<ParentRouteInfo>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
50pub struct ParentRouteInfo {
51    pub enabled: bool,
52    pub url: String,
53    pub priority: f32,
54    pub changefreq: String,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
58pub struct BrandingInfo {
59    pub name: Option<String>,
60    pub description: Option<String>,
61    pub image: Option<String>,
62    pub keywords: Option<String>,
63}
64
65#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
66pub struct IndexingInfo {
67    pub clear_before: bool,
68    pub recursive: bool,
69    pub override_existing: bool,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
73pub struct ContentTypeCreateOutput {
74    pub name: String,
75    pub message: String,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
79pub struct ContentTypeEditOutput {
80    pub name: String,
81    pub message: String,
82    pub changes: Vec<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
86pub struct ContentTypeDeleteOutput {
87    pub deleted: Vec<String>,
88    pub message: String,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
92pub struct TemplateSummary {
93    pub name: String,
94    pub content_types: Vec<String>,
95    pub file_exists: bool,
96    pub file_path: String,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
100pub struct TemplateDetailOutput {
101    pub name: String,
102    pub content_types: Vec<String>,
103    pub file_path: String,
104    pub file_exists: bool,
105    pub variables: Vec<String>,
106    pub preview_lines: Vec<String>,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
110pub struct TemplateCreateOutput {
111    pub name: String,
112    pub file_path: String,
113    pub message: String,
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
117pub struct TemplateEditOutput {
118    pub name: String,
119    pub message: String,
120    pub changes: Vec<String>,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
124pub struct TemplateDeleteOutput {
125    pub deleted: String,
126    pub file_deleted: bool,
127    pub message: String,
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
131pub struct AssetSummary {
132    pub path: String,
133    pub asset_type: AssetType,
134    pub size_bytes: u64,
135    pub modified: String,
136}
137
138#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
139#[serde(rename_all = "lowercase")]
140pub enum AssetType {
141    Css,
142    Logo,
143    Favicon,
144    Font,
145    Image,
146    Other,
147}
148
149impl std::fmt::Display for AssetType {
150    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
151        match self {
152            Self::Css => write!(f, "css"),
153            Self::Logo => write!(f, "logo"),
154            Self::Favicon => write!(f, "favicon"),
155            Self::Font => write!(f, "font"),
156            Self::Image => write!(f, "image"),
157            Self::Other => write!(f, "other"),
158        }
159    }
160}
161
162#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
163pub struct AssetDetailOutput {
164    pub path: String,
165    pub absolute_path: String,
166    pub asset_type: AssetType,
167    pub size_bytes: u64,
168    pub modified: String,
169    pub referenced_in: Vec<String>,
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
173pub struct SitemapRoute {
174    pub url: String,
175    pub priority: f32,
176    pub changefreq: String,
177    pub source: String,
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
181pub struct SitemapGenerateOutput {
182    pub output_path: String,
183    pub routes_count: usize,
184    pub message: String,
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize)]
188pub struct TemplatesConfig {
189    pub templates: std::collections::HashMap<String, TemplateEntry>,
190}
191
192#[derive(Debug, Clone, Serialize, Deserialize)]
193pub struct TemplateEntry {
194    pub content_types: Vec<String>,
195}