data_modelling_sdk/workspace/
mod.rs

1//! Workspace types shared across all platforms
2//!
3//! These types are used for:
4//! - Workspace management (profiles, domains)
5//! - Data organization ({email}/{domain}/ structure)
6
7use serde::{Deserialize, Serialize};
8
9/// Workspace information
10///
11/// Represents a workspace (model) with its metadata and location.
12///
13/// # Example
14///
15/// ```rust
16/// use data_modelling_sdk::workspace::WorkspaceInfo;
17///
18/// let workspace = WorkspaceInfo {
19///     model_id: "my-model".to_string(),
20///     name: "My Model".to_string(),
21///     git_directory_path: Some("/path/to/git".to_string()),
22///     email: Some("user@example.com".to_string()),
23///     domain: Some("finance".to_string()),
24/// };
25/// ```
26#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
27pub struct WorkspaceInfo {
28    /// Unique identifier for the workspace/model
29    pub model_id: String,
30    /// Display name of the workspace
31    pub name: String,
32    /// Path to the Git repository directory (if using Git)
33    pub git_directory_path: Option<String>,
34    /// Email of the workspace owner
35    pub email: Option<String>,
36    /// Domain name within the workspace
37    pub domain: Option<String>,
38}
39
40impl Default for WorkspaceInfo {
41    fn default() -> Self {
42        Self {
43            model_id: "default".to_string(),
44            name: "Default Workspace".to_string(),
45            git_directory_path: None,
46            email: None,
47            domain: None,
48        }
49    }
50}
51
52/// Profile information (user profile with domains)
53///
54/// Represents a user profile with associated domains.
55///
56/// # Example
57///
58/// ```rust
59/// use data_modelling_sdk::workspace::ProfileInfo;
60///
61/// let profile = ProfileInfo {
62///     email: "user@example.com".to_string(),
63///     domains: vec!["finance".to_string(), "risk".to_string()],
64/// };
65/// ```
66#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
67pub struct ProfileInfo {
68    /// User email address
69    pub email: String,
70    /// List of domain names associated with this profile
71    pub domains: Vec<String>,
72}
73
74/// Request to create a workspace
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct CreateWorkspaceRequest {
77    pub email: String,
78    pub domain: String,
79}
80
81/// Response after creating a workspace
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct CreateWorkspaceResponse {
84    pub success: bool,
85    pub workspace: Option<WorkspaceInfo>,
86    pub error: Option<String>,
87}
88
89/// List profiles response
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct ListProfilesResponse {
92    pub profiles: Vec<ProfileInfo>,
93}
94
95/// Load profile request
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct LoadProfileRequest {
98    pub domain: String,
99    pub email: String,
100}
101
102#[cfg(test)]
103mod tests {
104    use super::*;
105
106    #[test]
107    fn test_workspace_info_default() {
108        let info = WorkspaceInfo::default();
109        assert_eq!(info.model_id, "default");
110        assert_eq!(info.name, "Default Workspace");
111    }
112
113    #[test]
114    fn test_profile_info_serialization() {
115        let profile = ProfileInfo {
116            email: "test@example.com".to_string(),
117            domains: vec!["Risk".to_string(), "Finance".to_string()],
118        };
119
120        let json = serde_json::to_string(&profile).unwrap();
121        let parsed: ProfileInfo = serde_json::from_str(&json).unwrap();
122        assert_eq!(profile, parsed);
123    }
124}