Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

refactor: move operation to delta folder

appflowy2039cc00b5a9
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index c2d3fa7339..7ace722d28 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -1778,6 +1778,7 @@ dependencies = [
"md5",
"serde",
"serde_json",
+ "serde_repr",
"strum",
"strum_macros",
"thiserror",
diff --git a/shared-lib/lib-ot/src/core/delta/builder.rs b/shared-lib/lib-ot/src/core/delta/builder.rs
index d8bede927f..dd8aa131b8 100644
--- a/shared-lib/lib-ot/src/core/delta/builder.rs
+++ b/shared-lib/lib-ot/src/core/delta/builder.rs
@@ -1,5 +1,5 @@
+use crate::core::delta::operation::Attributes;
use crate::core::delta::{trim, Delta};
-use crate::core::operation::Attributes;
use crate::core::Operation;
/// A builder for creating new [Delta] objects.
diff --git a/shared-lib/lib-ot/src/core/delta/cursor.rs b/shared-lib/lib-ot/src/core/delta/cursor.rs
index a068f1c029..fc118ea017 100644
--- a/shared-lib/lib-ot/src/core/delta/cursor.rs
+++ b/shared-lib/lib-ot/src/core/delta/cursor.rs
@@ -1,7 +1,7 @@
#![allow(clippy::while_let_on_iterator)]
+use crate::core::delta::operation::{Attributes, Operation};
use crate::core::delta::Delta;
use crate::core::interval::Interval;
-use crate::core::operation::{Attributes, Operation};
use crate::errors::{ErrorBuilder, OTError, OTErrorCode};
use std::{cmp::min, iter::Enumerate, slice::Iter};
diff --git a/shared-lib/lib-ot/src/core/delta/delta.rs b/shared-lib/lib-ot/src/core/delta/delta.rs
index a95fd7c236..fed6d51733 100644
--- a/shared-lib/lib-ot/src/core/delta/delta.rs
+++ b/shared-lib/lib-ot/src/core/delta/delta.rs
@@ -1,8 +1,8 @@
use crate::errors::{ErrorBuilder, OTError, OTErrorCode};
+use crate::core::delta::operation::{Attributes, Operation, OperationTransform, PhantomAttributes};
use crate::core::delta::{DeltaIterator, MAX_IV_LEN};
use crate::core::interval::Interval;
-use crate::core::operation::{Attributes, Operation, OperationTransform, PhantomAttributes};
use crate::core::ot_str::OTString;
use crate::core::DeltaBuilder;
use bytes::Bytes;
diff --git a/shared-lib/lib-ot/src/core/delta/delta_serde.rs b/shared-lib/lib-ot/src/core/delta/delta_serde.rs
index 7dff063211..c90cb17d7e 100644
--- a/shared-lib/lib-ot/src/core/delta/delta_serde.rs
+++ b/shared-lib/lib-ot/src/core/delta/delta_serde.rs
@@ -1,5 +1,5 @@
+use crate::core::delta::operation::Attributes;
use crate::core::delta::Delta;
-use crate::core::operation::Attributes;
use serde::{
de::{SeqAccess, Visitor},
ser::SerializeSeq,
diff --git a/shared-lib/lib-ot/src/core/delta/iterator.rs b/shared-lib/lib-ot/src/core/delta/iterator.rs
index 53fb4f879b..88542a87cc 100644
--- a/shared-lib/lib-ot/src/core/delta/iterator.rs
+++ b/shared-lib/lib-ot/src/core/delta/iterator.rs
@@ -1,7 +1,7 @@
use super::cursor::*;
+use crate::core::delta::operation::{Attributes, Operation};
use crate::core::delta::{Delta, NEW_LINE};
use crate::core::interval::Interval;
-use crate::core::operation::{Attributes, Operation};
use crate::rich_text::TextAttributes;
use std::ops::{Deref, DerefMut};
diff --git a/shared-lib/lib-ot/src/core/delta/mod.rs b/shared-lib/lib-ot/src/core/delta/mod.rs
index 45c675e855..0cb57be7ed 100644
--- a/shared-lib/lib-ot/src/core/delta/mod.rs
+++ b/shared-lib/lib-ot/src/core/delta/mod.rs
@@ -4,6 +4,7 @@ mod cursor;
mod delta;
mod delta_serde;
mod iterator;
+pub mod operation;
pub use builder::*;
pub use cursor::*;
diff --git a/shared-lib/lib-ot/src/core/operation/builder.rs b/shared-lib/lib-ot/src/core/delta/operation/builder.rs
similarity index 94%
rename from shared-lib/lib-ot/src/core/operation/builder.rs
rename to shared-lib/lib-ot/src/core/delta/operation/builder.rs
index b5a06484eb..900e4077e0 100644
--- a/shared-lib/lib-ot/src/core/operation/builder.rs
+++ b/shared-lib/lib-ot/src/core/delta/operation/builder.rs
@@ -1,4 +1,4 @@
-use crate::core::operation::{Attributes, Operation, PhantomAttributes};
+use crate::core::delta::operation::{Attributes, Operation, PhantomAttributes};
use crate::rich_text::TextAttributes;
pub type RichTextOpBuilder = OperationsBuilder<TextAttributes>;
diff --git a/shared-lib/lib-ot/src/core/operation/mod.rs b/shared-lib/lib-ot/src/core/delta/operation/mod.rs
similarity index 100%
rename from shared-lib/lib-ot/src/core/operation/mod.rs
rename to shared-lib/lib-ot/src/core/delta/operation/mod.rs
diff --git a/shared-lib/lib-ot/src/core/operation/operation.rs b/shared-lib/lib-ot/src/core/delta/operation/operation.rs
similarity index 100%
rename from shared-lib/lib-ot/src/core/operation/operation.rs
rename to shared-lib/lib-ot/src/core/delta/operation/operation.rs
diff --git a/shared-lib/lib-ot/src/core/operation/operation_serde.rs b/shared-lib/lib-ot/src/core/delta/operation/operation_serde.rs
similarity index 99%
rename from shared-lib/lib-ot/src/core/operation/operation_serde.rs
rename to shared-lib/lib-ot/src/core/delta/operation/operation_serde.rs
index b7ff7b3c20..0b41a19914 100644
--- a/shared-lib/lib-ot/src/core/operation/operation_serde.rs
+++ b/shared-lib/lib-ot/src/core/delta/operation/operation_serde.rs
@@ -1,4 +1,4 @@
-use crate::core::operation::{Attributes, Insert, Operation, Retain};
+use crate::core::delta::operation::{Attributes, Insert, Operation, Retain};
use crate::core::ot_str::OTString;
use serde::{
de,
diff --git a/shared-lib/lib-ot/src/core/mod.rs b/shared-lib/lib-ot/src/core/mod.rs
index 262233c85a..ce75045eb4 100644
--- a/shared-lib/lib-ot/src/core/mod.rs
+++ b/shared-lib/lib-ot/src/core/mod.rs
@@ -1,11 +1,10 @@
mod delta;
mod document;
mod interval;
-mod operation;
mod ot_str;
+pub use delta::operation::*;
pub use delta::*;
pub use document::*;
pub use interval::*;
-pub use operation::*;
pub use ot_str::*;