From 9472a8fdcfc68d4dfd2566054eb7814466d81402 Mon Sep 17 00:00:00 2001 From: Jesse Ditson Date: Thu, 19 Dec 2024 12:15:31 -0800 Subject: [PATCH] add source field to mutation events --- src/binary/command/import.rs | 3 +++ src/binary/command/upload.rs | 1 + src/events.rs | 4 ++++ src/lib.rs | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/src/binary/command/import.rs b/src/binary/command/import.rs index da97cb0..8998c9a 100644 --- a/src/binary/command/import.rs +++ b/src/binary/command/import.rs @@ -370,6 +370,7 @@ impl Command { object: object.to_string(), filename: f.to_string(), path: current_path.to_owned(), + source: None, }), None, ) @@ -419,6 +420,7 @@ impl Command { path: current_path.clone(), value: Some(value), field: name.to_string(), + source: None, }), None, ) @@ -456,6 +458,7 @@ impl Command { path: current_path.clone().concat(col_path), value: Some(value), field: col_field, + source: None, }), None, ) diff --git a/src/binary/command/upload.rs b/src/binary/command/upload.rs index d5fd5e8..f3ecada 100644 --- a/src/binary/command/upload.rs +++ b/src/binary/command/upload.rs @@ -191,6 +191,7 @@ impl BinaryCommand for Command { path: ValuePath::empty(), value: Some(field_data.clone()), field: field.to_string(), + source: None, }), None, )?; diff --git a/src/events.rs b/src/events.rs index 2639049..4a7c565 100644 --- a/src/events.rs +++ b/src/events.rs @@ -29,6 +29,7 @@ pub struct EditFieldEvent { pub path: ValuePath, pub field: String, pub value: Option, + pub source: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "typescript", derive(TypeDef))] @@ -36,6 +37,7 @@ pub struct EditOrderEvent { pub object: String, pub filename: String, pub order: i32, + pub source: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -43,6 +45,7 @@ pub struct EditOrderEvent { pub struct DeleteObjectEvent { pub object: String, pub filename: String, + pub source: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -67,6 +70,7 @@ pub struct ChildEvent { pub object: String, pub filename: String, pub path: ValuePath, + pub source: Option, } #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index cab444d..d66a4f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -317,6 +317,7 @@ impl Archival { } Ok(r) } + // Internal fn add_object(&self, event: AddObjectEvent) -> Result> { let obj_def = self @@ -584,6 +585,7 @@ mod lib { path: ValuePath::empty(), field: "name".to_string(), value: Some(FieldValue::String("This is the new name".to_string())), + source: None, }), Some(BuildOptions::default()), )?; @@ -607,6 +609,7 @@ mod lib { ArchivalEvent::DeleteObject(DeleteObjectEvent { object: "section".to_string(), filename: "first".to_string(), + source: None, }), Some(BuildOptions::default()), )?; @@ -648,6 +651,7 @@ mod lib { object: "section".to_string(), filename: "first".to_string(), order: 12, + source: None, }), Some(BuildOptions::default()), )?; @@ -692,6 +696,7 @@ mod lib { object: "post".to_string(), filename: "a-post".to_string(), path: ValuePath::default().append(ValuePathComponent::key("links")), + source: None, }), Some(BuildOptions::default()), ) @@ -744,6 +749,7 @@ mod lib { path: ValuePath::default() .append(ValuePathComponent::key("links")) .append(ValuePathComponent::Index(0)), + source: None, }), Some(BuildOptions::default()), )