stately_files/response.rs
1//! Response types for file management endpoints.
2
3use serde::Serialize;
4use utoipa::{ToResponse, ToSchema};
5
6/// Response from file upload or save operations.
7#[derive(Debug, Serialize, ToSchema, ToResponse)]
8pub struct FileUploadResponse {
9 /// Whether the operation was successful.
10 pub success: bool,
11 /// Relative path from uploads directory (e.g., "config.json").
12 pub path: String,
13 /// The UUID version identifier for this upload.
14 pub uuid: String,
15 /// Full absolute path on the server filesystem.
16 pub full_path: String,
17}
18
19/// Response from listing files in a directory.
20#[derive(Debug, Serialize, ToSchema, ToResponse)]
21pub struct FileListResponse {
22 /// List of files and directories.
23 pub files: Vec<FileInfo>,
24}
25
26/// Type of file system entry.
27#[derive(Debug, Clone, Copy, Serialize, ToSchema)]
28#[serde(rename_all = "snake_case")]
29pub enum FileEntryType {
30 /// A directory that may contain other files or directories.
31 Directory,
32 /// A regular file (not versioned).
33 File,
34 /// A versioned file with multiple versions stored.
35 VersionedFile,
36}
37
38/// Information about a file or directory entry.
39#[derive(Debug, Serialize, ToSchema)]
40pub struct FileInfo {
41 /// Entry name (filename or directory name).
42 pub name: String,
43 /// Size in bytes. For versioned files, this is the size of the latest version.
44 /// For directories, this is 0.
45 pub size: u64,
46 /// Type of this entry.
47 #[serde(rename = "type")]
48 pub entry_type: FileEntryType,
49 /// Creation timestamp as Unix epoch seconds.
50 /// For versioned files, this is when the first version was created.
51 pub created: Option<u64>,
52 /// Last modified timestamp as Unix epoch seconds.
53 /// For versioned files, this is when the latest version was created.
54 pub modified: Option<u64>,
55 /// List of all versions, sorted newest first.
56 /// Only populated for versioned files.
57 #[serde(skip_serializing_if = "Option::is_none")]
58 pub versions: Option<Vec<FileVersion>>,
59}
60
61/// Information about a specific file version.
62#[derive(Debug, Serialize, ToSchema)]
63pub struct FileVersion {
64 /// UUID v7 identifier for this version.
65 pub uuid: String,
66 /// Size of this version in bytes.
67 pub size: u64,
68 /// Creation timestamp as Unix epoch seconds.
69 pub created: Option<u64>,
70}