Skip to content

Commit cce413a

Browse files
committed
refactor: Use real core types in graph_stub instead of simplified versions
Replace stub type definitions (Version, VersionDiff, IsolationLevel, etc.) with imports from codegraph_core. This ensures the stub managers return properly structured data that matches what the NAPI addon expects. Changes: - Import Version, VersionDiff, IsolationLevel, Snapshot, and ID types from codegraph_core - Remove duplicate simplified type definitions - Add comments explaining stub behavior - Preserve stub implementation logic while using real types This aligns the stub API with the real implementation and fixes compilation issues in the NAPI addon where it expects Version objects with name, description, and author fields.
1 parent 55838af commit cce413a

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed

crates/codegraph-api/src/graph_stub.rs

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -180,35 +180,10 @@ pub struct IntegrityReport {
180180
pub corrupted_data_count: usize,
181181
}
182182

183-
// Stub manager types
184-
// Note: uuid and chrono are already imported at the top of this file
185-
186-
// Define missing types that were incorrectly imported from codegraph_core
187-
pub type TransactionId = Uuid;
188-
pub type SnapshotId = Uuid;
189-
pub type VersionId = Uuid;
190-
191-
#[derive(Debug, Clone)]
192-
pub struct IsolationLevel;
193-
194-
#[derive(Debug, Clone)]
195-
pub struct Snapshot {
196-
pub id: SnapshotId,
197-
pub timestamp: DateTime<Utc>,
198-
}
199-
200-
#[derive(Debug, Clone)]
201-
pub struct Version {
202-
pub id: VersionId,
203-
pub timestamp: DateTime<Utc>,
204-
}
205-
206-
#[derive(Debug, Clone)]
207-
pub struct VersionDiff {
208-
pub added_nodes: Vec<NodeId>,
209-
pub modified_nodes: Vec<NodeId>,
210-
pub deleted_nodes: Vec<NodeId>,
211-
}
183+
// Import the real types from codegraph_core instead of redefining them
184+
pub use codegraph_core::{
185+
IsolationLevel, Snapshot, SnapshotId, TransactionId, Version, VersionDiff, VersionId,
186+
};
212187

213188
#[derive(Clone)]
214189
pub struct ConcurrentTransactionManager;
@@ -218,7 +193,9 @@ impl ConcurrentTransactionManager {
218193
Self
219194
}
220195

221-
pub async fn begin_transaction(&self, _isolation_level: IsolationLevel) -> Result<TransactionId> {
196+
pub async fn begin_transaction(&self, isolation_level: IsolationLevel) -> Result<TransactionId> {
197+
// Stub implementation - just generate a new transaction ID
198+
// In a real implementation, this would create a transaction with the specified isolation level
222199
Ok(Uuid::new_v4())
223200
}
224201

@@ -248,15 +225,24 @@ impl GitLikeVersionManager {
248225
Self
249226
}
250227

251-
pub async fn create_version(&self, _name: String, _description: String, _author: String, _parent_versions: Vec<VersionId>) -> Result<VersionId> {
252-
Ok(Uuid::new_v4())
228+
pub async fn create_version(&self, name: String, description: String, author: String, parent_versions: Vec<VersionId>) -> Result<VersionId> {
229+
let version_id = Uuid::new_v4();
230+
let snapshot_id = Uuid::new_v4();
231+
232+
// In a real implementation, this would store the version
233+
// For now, just return the ID
234+
Ok(version_id)
253235
}
254236

255237
pub async fn list_versions(&self) -> Result<Vec<Version>> {
238+
// Stub implementation - return empty list
239+
// In a real implementation, this would fetch from storage
256240
Ok(Vec::new())
257241
}
258242

259-
pub async fn get_version(&self, _id: VersionId) -> Result<Option<Version>> {
243+
pub async fn get_version(&self, id: VersionId) -> Result<Option<Version>> {
244+
// Stub implementation - return None
245+
// In a real implementation, this would fetch from storage
260246
Ok(None)
261247
}
262248

0 commit comments

Comments
 (0)