Skip to content

Commit

Permalink
add source field to mutation events
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseditson committed Dec 19, 2024
1 parent 5030178 commit 9472a8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/binary/command/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ impl Command {
object: object.to_string(),
filename: f.to_string(),
path: current_path.to_owned(),
source: None,
}),
None,
)
Expand Down Expand Up @@ -419,6 +420,7 @@ impl Command {
path: current_path.clone(),
value: Some(value),
field: name.to_string(),
source: None,
}),
None,
)
Expand Down Expand Up @@ -456,6 +458,7 @@ impl Command {
path: current_path.clone().concat(col_path),
value: Some(value),
field: col_field,
source: None,
}),
None,
)
Expand Down
1 change: 1 addition & 0 deletions src/binary/command/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl BinaryCommand for Command {
path: ValuePath::empty(),
value: Some(field_data.clone()),
field: field.to_string(),
source: None,
}),
None,
)?;
Expand Down
4 changes: 4 additions & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@ pub struct EditFieldEvent {
pub path: ValuePath,
pub field: String,
pub value: Option<FieldValue>,
pub source: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "typescript", derive(TypeDef))]
pub struct EditOrderEvent {
pub object: String,
pub filename: String,
pub order: i32,
pub source: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "typescript", derive(TypeDef))]
pub struct DeleteObjectEvent {
pub object: String,
pub filename: String,
pub source: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -67,6 +70,7 @@ pub struct ChildEvent {
pub object: String,
pub filename: String,
pub path: ValuePath,
pub source: Option<String>,
}

#[cfg(test)]
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl<F: FileSystemAPI + Clone + Debug> Archival<F> {
}
Ok(r)
}

// Internal
fn add_object(&self, event: AddObjectEvent) -> Result<ArchivalEventResponse, Box<dyn Error>> {
let obj_def = self
Expand Down Expand Up @@ -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()),
)?;
Expand All @@ -607,6 +609,7 @@ mod lib {
ArchivalEvent::DeleteObject(DeleteObjectEvent {
object: "section".to_string(),
filename: "first".to_string(),
source: None,
}),
Some(BuildOptions::default()),
)?;
Expand Down Expand Up @@ -648,6 +651,7 @@ mod lib {
object: "section".to_string(),
filename: "first".to_string(),
order: 12,
source: None,
}),
Some(BuildOptions::default()),
)?;
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -744,6 +749,7 @@ mod lib {
path: ValuePath::default()
.append(ValuePathComponent::key("links"))
.append(ValuePathComponent::Index(0)),
source: None,
}),
Some(BuildOptions::default()),
)
Expand Down

0 comments on commit 9472a8f

Please # to comment.