summaryrefslogtreecommitdiff
path: root/crates/vcs_data
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-10-30 09:23:02 +0800
committer魏曹先生 <1992414357@qq.com>2025-10-30 09:23:02 +0800
commit941e5d1317b5ed562df2a172de717a5a7408ee15 (patch)
treec679a5c0d16d38e51f3b66caba212c4ba93bd3a0 /crates/vcs_data
parentcc43704e7412ef82f6d41ba211b50e26307a3ddf (diff)
Change auth_member to return MemberId on success
The authentication function now returns the authenticated member's ID instead of just () when successful. This provides callers with access to the authenticated member's identity for subsequent operations.
Diffstat (limited to 'crates/vcs_data')
-rw-r--r--crates/vcs_data/src/constants.rs9
-rw-r--r--crates/vcs_data/src/data/local.rs1
-rw-r--r--crates/vcs_data/src/data/sheet.rs18
-rw-r--r--crates/vcs_data/vcs_data_test/src/test_sheet_creation_management_and_persistence.rs6
4 files changed, 27 insertions, 7 deletions
diff --git a/crates/vcs_data/src/constants.rs b/crates/vcs_data/src/constants.rs
index 7514fe2..cd6eaa3 100644
--- a/crates/vcs_data/src/constants.rs
+++ b/crates/vcs_data/src/constants.rs
@@ -17,7 +17,7 @@ pub const SERVER_FILE_VAULT: &str = "./vault.toml";
// Server - Sheets
pub const REF_SHEET_NAME: &str = "ref";
pub const SERVER_PATH_SHEETS: &str = "./sheets/";
-pub const SERVER_FILE_SHEET: &str = "./sheets/{sheet-name}.yaml";
+pub const SERVER_FILE_SHEET: &str = "./sheets/{sheet_name}.yaml";
// Server - Members
pub const SERVER_PATH_MEMBERS: &str = "./members/";
@@ -35,6 +35,7 @@ pub const SERVER_FILE_VF_META: &str = "./storage/{vf_index}/{vf_id}/meta.yaml";
// Server - Service
pub const SERVER_FILE_LOCKFILE: &str = "./.lock";
+// Server - Documents
pub const SERVER_FILE_README: &str = "./README.md";
// -------------------------------------------------------------------------------------
@@ -45,6 +46,12 @@ pub const CLIENT_PATH_WORKSPACE_ROOT: &str = "./.jv/";
// Client - Workspace (Main)
pub const CLIENT_FILE_WORKSPACE: &str = "./.jv/workspace.toml";
+// Client - Latest Information
+pub const CLIENT_FILE_LATEST_INFO: &str = "./.jv/latest.json";
+
+// Client - Sheets
+pub const CLIENT_FILE_SHEET_COPY: &str = "./.jv/sheets/{sheet_name}.copy.json";
+
// Client - Other
pub const CLIENT_FILE_IGNOREFILES: &str = "IGNORE_RULES.toml";
pub const CLIENT_FILE_README: &str = "./README.md";
diff --git a/crates/vcs_data/src/data/local.rs b/crates/vcs_data/src/data/local.rs
index fb43042..407b171 100644
--- a/crates/vcs_data/src/data/local.rs
+++ b/crates/vcs_data/src/data/local.rs
@@ -10,6 +10,7 @@ use crate::{
};
pub mod config;
+pub mod latest_info;
pub struct LocalWorkspace {
config: Arc<Mutex<LocalConfig>>,
diff --git a/crates/vcs_data/src/data/sheet.rs b/crates/vcs_data/src/data/sheet.rs
index f1cf67c..b558c0d 100644
--- a/crates/vcs_data/src/data/sheet.rs
+++ b/crates/vcs_data/src/data/sheet.rs
@@ -35,7 +35,7 @@ impl PartialEq for InputPackage {
}
}
-const SHEET_NAME: &str = "{sheet-name}";
+const SHEET_NAME: &str = "{sheet_name}";
pub struct Sheet<'a> {
/// The name of the current sheet
@@ -48,7 +48,7 @@ pub struct Sheet<'a> {
pub(crate) vault_reference: &'a Vault,
}
-#[derive(Default, Serialize, Deserialize, ConfigFile)]
+#[derive(Default, Serialize, Deserialize, ConfigFile, Clone)]
pub struct SheetData {
/// The holder of the current sheet, who has full operation rights to the sheet mapping
pub(crate) holder: MemberId,
@@ -61,6 +61,10 @@ pub struct SheetData {
}
impl<'a> Sheet<'a> {
+ pub fn name(&self) -> &SheetName {
+ &self.name
+ }
+
/// Get the holder of this sheet
pub fn holder(&self) -> &MemberId {
&self.data.holder
@@ -344,4 +348,14 @@ impl<'a> Sheet<'a> {
common_components.into_iter().collect()
}
+
+ /// Clone the data of the sheet
+ pub fn clone_data(&self) -> SheetData {
+ self.data.clone()
+ }
+
+ /// Convert the sheet into its data representation
+ pub fn to_data(self) -> SheetData {
+ self.data
+ }
}
diff --git a/crates/vcs_data/vcs_data_test/src/test_sheet_creation_management_and_persistence.rs b/crates/vcs_data/vcs_data_test/src/test_sheet_creation_management_and_persistence.rs
index a8dfb89..7484e4b 100644
--- a/crates/vcs_data/vcs_data_test/src/test_sheet_creation_management_and_persistence.rs
+++ b/crates/vcs_data/vcs_data_test/src/test_sheet_creation_management_and_persistence.rs
@@ -42,8 +42,7 @@ async fn test_sheet_creation_management_and_persistence() -> Result<(), std::io:
assert!(sheet.mapping().is_empty());
// Verify sheet file was created
- const SHEET_NAME_PARAM: &str = "{sheet-name}";
- let sheet_path = dir.join(SERVER_FILE_SHEET.replace(SHEET_NAME_PARAM, &sheet_name));
+ let sheet_path = dir.join(SERVER_FILE_SHEET.replace("{sheet_name}", &sheet_name));
assert!(sheet_path.exists());
// Test 2: Add input packages to the sheet
@@ -296,8 +295,7 @@ async fn test_sheet_data_serialization() -> Result<(), std::io::Error> {
sheet.persist().await?;
// Verify the sheet file was created
- const SHEET_NAME_PARAM: &str = "{sheet-name}";
- let sheet_path = dir.join(SERVER_FILE_SHEET.replace(SHEET_NAME_PARAM, &sheet_name));
+ let sheet_path = dir.join(SERVER_FILE_SHEET.replace("{sheet_name}", &sheet_name));
assert!(sheet_path.exists());
// Clean up