time_tracker_plugin_sdk/api.rs
1//! Plugin API interface trait
2//!
3//! This trait abstracts the Plugin API so that plugins can work with
4//! any implementation. The concrete implementation in the core app
5//! provides access to Database and ExtensionRegistry.
6
7use crate::extensions::{EntityType, SchemaChange, ModelField, QueryFilter};
8use serde_json;
9
10/// Abstract interface for plugins to interact with Core
11pub trait PluginAPIInterface: Send + Sync {
12 /// Register a database schema extension
13 fn register_schema_extension(
14 &self,
15 entity_type: EntityType,
16 schema_changes: Vec<SchemaChange>,
17 ) -> Result<(), String>;
18
19 /// Register a model extension
20 fn register_model_extension(
21 &self,
22 entity_type: EntityType,
23 model_fields: Vec<ModelField>,
24 ) -> Result<(), String>;
25
26 /// Register query filters
27 fn register_query_filters(
28 &self,
29 entity_type: EntityType,
30 query_filters: Vec<QueryFilter>,
31 ) -> Result<(), String>;
32
33 /// Call a database method by name with JSON parameters
34 /// This allows plugins to access database functionality without direct Database dependency
35 /// Method names match Database methods (e.g., "create_project", "get_projects")
36 /// Parameters are passed as a JSON object, return value is JSON
37 fn call_db_method(&self, method: &str, params: serde_json::Value) -> Result<serde_json::Value, String>;
38}