Skip to main content

systemprompt_cli/commands/web/
types.rs

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