pub trait PluginAPIInterface: Send + Sync {
Show 19 methods
// Required methods
fn register_schema_extension(
&self,
entity_type: EntityType,
schema_changes: Vec<SchemaChange>,
) -> Result<(), String>;
fn register_model_extension(
&self,
entity_type: EntityType,
model_fields: Vec<ModelField>,
) -> Result<(), String>;
fn register_query_filters(
&self,
entity_type: EntityType,
query_filters: Vec<QueryFilter>,
) -> Result<(), String>;
fn get_categories(&self) -> Result<Value, String>;
fn create_category(&self, params: Value) -> Result<Value, String>;
fn update_category(&self, params: Value) -> Result<Value, String>;
fn delete_category(&self, id: i64) -> Result<(), String>;
fn get_activities(
&self,
start: i64,
end: i64,
limit: Option<i64>,
offset: Option<i64>,
filters: Option<ActivityFilters>,
) -> Result<Value, String>;
fn get_manual_entries(&self, start: i64, end: i64) -> Result<Value, String>;
fn create_manual_entry(&self, params: Value) -> Result<Value, String>;
fn update_manual_entry(&self, params: Value) -> Result<Value, String>;
fn delete_manual_entry(&self, id: i64) -> Result<(), String>;
fn insert_own_table(
&self,
table: &str,
data: Value,
) -> Result<Value, String>;
fn query_own_table(
&self,
table: &str,
filters: Option<Value>,
order_by: Option<&str>,
limit: Option<i64>,
) -> Result<Value, String>;
fn update_own_table(
&self,
table: &str,
id: i64,
data: Value,
) -> Result<Value, String>;
fn delete_own_table(&self, table: &str, id: i64) -> Result<Value, String>;
fn aggregate_own_table(
&self,
table: &str,
filters: Option<Value>,
aggregations: Value,
) -> Result<Value, String>;
fn query_plugin_table(
&self,
plugin_id: &str,
table: &str,
filters: Option<Value>,
order_by: Option<&str>,
limit: Option<i64>,
) -> Result<Value, String>;
fn call_db_method(
&self,
method: &str,
params: Value,
) -> Result<Value, String>;
}Expand description
Abstract interface for plugins to interact with Core
Required Methods§
Sourcefn register_schema_extension(
&self,
entity_type: EntityType,
schema_changes: Vec<SchemaChange>,
) -> Result<(), String>
fn register_schema_extension( &self, entity_type: EntityType, schema_changes: Vec<SchemaChange>, ) -> Result<(), String>
Register a database schema extension
Sourcefn register_model_extension(
&self,
entity_type: EntityType,
model_fields: Vec<ModelField>,
) -> Result<(), String>
fn register_model_extension( &self, entity_type: EntityType, model_fields: Vec<ModelField>, ) -> Result<(), String>
Register a model extension
Sourcefn register_query_filters(
&self,
entity_type: EntityType,
query_filters: Vec<QueryFilter>,
) -> Result<(), String>
fn register_query_filters( &self, entity_type: EntityType, query_filters: Vec<QueryFilter>, ) -> Result<(), String>
Register query filters
Sourcefn get_categories(&self) -> Result<Value, String>
fn get_categories(&self) -> Result<Value, String>
Get all categories (returns array of objects with core + extended fields)
Sourcefn create_category(&self, params: Value) -> Result<Value, String>
fn create_category(&self, params: Value) -> Result<Value, String>
Create a category; params may include plugin-extended field names and values
Sourcefn update_category(&self, params: Value) -> Result<Value, String>
fn update_category(&self, params: Value) -> Result<Value, String>
Update a category; params may include plugin-extended fields
Sourcefn get_activities(
&self,
start: i64,
end: i64,
limit: Option<i64>,
offset: Option<i64>,
filters: Option<ActivityFilters>,
) -> Result<Value, String>
fn get_activities( &self, start: i64, end: i64, limit: Option<i64>, offset: Option<i64>, filters: Option<ActivityFilters>, ) -> Result<Value, String>
Get activities in a time range with optional filters
§Parameters
start: Start timestamp (Unix timestamp in seconds)end: End timestamp (Unix timestamp in seconds)limit: Optional maximum number of resultsoffset: Optional offset for paginationfilters: Optional filters to apply (exclude_idle, category_ids)
§Returns
Array of activity objects (id, started_at, duration_sec, is_idle, category_id, and any plugin-extended fields)
Sourcefn get_manual_entries(&self, start: i64, end: i64) -> Result<Value, String>
fn get_manual_entries(&self, start: i64, end: i64) -> Result<Value, String>
Get manual entries in a time range
Sourcefn insert_own_table(&self, table: &str, data: Value) -> Result<Value, String>
fn insert_own_table(&self, table: &str, data: Value) -> Result<Value, String>
Insert a row into a table owned by this plugin
Returns: { "id": row_id }
Sourcefn query_own_table(
&self,
table: &str,
filters: Option<Value>,
order_by: Option<&str>,
limit: Option<i64>,
) -> Result<Value, String>
fn query_own_table( &self, table: &str, filters: Option<Value>, order_by: Option<&str>, limit: Option<i64>, ) -> Result<Value, String>
Query rows from a table owned by this plugin Returns: array of row objects
Sourcefn update_own_table(
&self,
table: &str,
id: i64,
data: Value,
) -> Result<Value, String>
fn update_own_table( &self, table: &str, id: i64, data: Value, ) -> Result<Value, String>
Update a row in a table owned by this plugin
Returns: { "updated": count }
Sourcefn delete_own_table(&self, table: &str, id: i64) -> Result<Value, String>
fn delete_own_table(&self, table: &str, id: i64) -> Result<Value, String>
Delete a row from a table owned by this plugin
Returns: { "deleted": count }
Sourcefn aggregate_own_table(
&self,
table: &str,
filters: Option<Value>,
aggregations: Value,
) -> Result<Value, String>
fn aggregate_own_table( &self, table: &str, filters: Option<Value>, aggregations: Value, ) -> Result<Value, String>
Run aggregations on a table owned by this plugin
Returns: object with keys such as total_count, sum_<col>, avg_<col>, groups (when group_by is used)
Sourcefn query_plugin_table(
&self,
plugin_id: &str,
table: &str,
filters: Option<Value>,
order_by: Option<&str>,
limit: Option<i64>,
) -> Result<Value, String>
fn query_plugin_table( &self, plugin_id: &str, table: &str, filters: Option<Value>, order_by: Option<&str>, limit: Option<i64>, ) -> Result<Value, String>
Query a table owned by another plugin
§Parameters
plugin_id: ID of the plugin that owns the tabletable: Table name to queryfilters: Optional filter conditions (same format as select_table - JSON object with column names to values)order_by: Optional ordering (e.g., “created_at DESC”)limit: Optional row limit (max 10000)
§Returns
Array of row objects (same format as select_table)
§Errors
- Plugin not found
- Table not owned by specified plugin
- Table not exposed for cross-plugin queries
- Permission denied (not in allowed_plugins list)
Sourcefn call_db_method(&self, method: &str, params: Value) -> Result<Value, String>
👎Deprecated: Use specific methods instead: get_categories(), create_category(), query_own_table(), etc.
fn call_db_method(&self, method: &str, params: Value) -> Result<Value, String>
Call a database method by name with JSON parameters
§Deprecated
This method is deprecated. Use specific methods instead:
get_categories(),create_category(),update_category(),delete_category()for categoriesget_activities()for activitiesget_manual_entries(),create_manual_entry(),update_manual_entry(),delete_manual_entry()for manual entriesquery_own_table(),insert_own_table(),update_own_table(),delete_own_table(),aggregate_own_table()for plugin tables
This method will be removed in a future major version.