Skip to main content

systemprompt_files/repository/file/
request.rs

1use systemprompt_identifiers::{ContextId, FileId, SessionId, TraceId, UserId};
2
3#[derive(Debug, Clone)]
4pub struct InsertFileRequest {
5    pub id: FileId,
6    pub path: String,
7    pub public_url: String,
8    pub mime_type: String,
9    pub size_bytes: Option<i64>,
10    pub ai_content: bool,
11    pub metadata: serde_json::Value,
12    pub user_id: Option<UserId>,
13    pub session_id: Option<SessionId>,
14    pub trace_id: Option<TraceId>,
15    pub context_id: Option<ContextId>,
16}
17
18impl InsertFileRequest {
19    pub fn new(
20        id: FileId,
21        path: impl Into<String>,
22        public_url: impl Into<String>,
23        mime_type: impl Into<String>,
24    ) -> Self {
25        Self {
26            id,
27            path: path.into(),
28            public_url: public_url.into(),
29            mime_type: mime_type.into(),
30            size_bytes: None,
31            ai_content: false,
32            metadata: serde_json::Value::Object(serde_json::Map::new()),
33            user_id: None,
34            session_id: None,
35            trace_id: None,
36            context_id: None,
37        }
38    }
39
40    pub const fn with_size(mut self, size: i64) -> Self {
41        self.size_bytes = Some(size);
42        self
43    }
44
45    pub const fn with_ai_content(mut self, ai_content: bool) -> Self {
46        self.ai_content = ai_content;
47        self
48    }
49
50    pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
51        self.metadata = metadata;
52        self
53    }
54
55    pub fn with_user_id(mut self, user_id: UserId) -> Self {
56        self.user_id = Some(user_id);
57        self
58    }
59
60    pub fn with_session_id(mut self, session_id: SessionId) -> Self {
61        self.session_id = Some(session_id);
62        self
63    }
64
65    pub fn with_trace_id(mut self, trace_id: TraceId) -> Self {
66        self.trace_id = Some(trace_id);
67        self
68    }
69
70    pub fn with_context_id(mut self, context_id: ContextId) -> Self {
71        self.context_id = Some(context_id);
72        self
73    }
74}