Skip to main content

PluginAPIInterface

Trait PluginAPIInterface 

Source
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§

Source

fn register_schema_extension( &self, entity_type: EntityType, schema_changes: Vec<SchemaChange>, ) -> Result<(), String>

Register a database schema extension

Source

fn register_model_extension( &self, entity_type: EntityType, model_fields: Vec<ModelField>, ) -> Result<(), String>

Register a model extension

Source

fn register_query_filters( &self, entity_type: EntityType, query_filters: Vec<QueryFilter>, ) -> Result<(), String>

Register query filters

Source

fn get_categories(&self) -> Result<Value, String>

Get all categories (returns array of objects with core + extended fields)

Source

fn create_category(&self, params: Value) -> Result<Value, String>

Create a category; params may include plugin-extended field names and values

Source

fn update_category(&self, params: Value) -> Result<Value, String>

Update a category; params may include plugin-extended fields

Source

fn delete_category(&self, id: i64) -> Result<(), String>

Delete a category by ID

Source

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 results
  • offset: Optional offset for pagination
  • filters: 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)

Source

fn get_manual_entries(&self, start: i64, end: i64) -> Result<Value, String>

Get manual entries in a time range

Source

fn create_manual_entry(&self, params: Value) -> Result<Value, String>

Create a manual entry

Source

fn update_manual_entry(&self, params: Value) -> Result<Value, String>

Update a manual entry

Source

fn delete_manual_entry(&self, id: i64) -> Result<(), String>

Delete a manual entry by ID

Source

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 }

Source

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

Source

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 }

Source

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 }

Source

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)

Source

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 table
  • table: Table name to query
  • filters: 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)
Source

fn call_db_method(&self, method: &str, params: Value) -> Result<Value, String>

👎Deprecated: Use specific methods instead: get_categories(), create_category(), query_own_table(), etc.

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 categories
  • get_activities() for activities
  • get_manual_entries(), create_manual_entry(), update_manual_entry(), delete_manual_entry() for manual entries
  • query_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.

Implementors§