time_tracker_plugin_sdk/
extensions.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum EntityType {
6 Activity,
7 ManualEntry,
8 Category,
9}
10
11#[derive(Debug, Clone, PartialEq)]
13pub enum ExtensionType {
14 DatabaseSchema,
15 Model,
16 DataHook,
17 Query,
18 UIForm,
19}
20
21#[derive(Debug, Clone)]
23pub enum SchemaChange {
24 CreateTable {
26 table: String,
27 columns: Vec<TableColumn>,
28 },
29 AddColumn {
31 table: String,
32 column: String,
33 column_type: String,
34 default: Option<String>,
35 foreign_key: Option<ForeignKey>,
36 },
37 AddIndex {
39 table: String,
40 index: String,
41 columns: Vec<String>,
42 },
43 AddForeignKey {
45 table: String,
46 column: String,
47 foreign_table: String,
48 foreign_column: String,
49 },
50}
51
52#[derive(Debug, Clone)]
54pub struct TableColumn {
55 pub name: String,
56 pub column_type: String,
57 pub primary_key: bool,
58 pub nullable: bool,
59 pub default: Option<String>,
60 pub foreign_key: Option<ForeignKey>,
61}
62
63#[derive(Debug, Clone)]
65pub struct ForeignKey {
66 pub table: String,
67 pub column: String,
68}
69
70#[derive(Debug, Clone)]
72pub struct ModelField {
73 pub name: String,
74 pub type_: String,
75 pub optional: bool,
76}
77
78pub type QueryFilterFn = Box<dyn Fn(Vec<serde_json::Value>, std::collections::HashMap<String, serde_json::Value>) -> Result<Vec<serde_json::Value>, String> + Send + Sync>;
80
81pub struct QueryFilter {
83 pub name: String,
84 pub filter_fn: QueryFilterFn,
85}
86
87impl std::fmt::Debug for QueryFilter {
88 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
89 f.debug_struct("QueryFilter")
90 .field("name", &self.name)
91 .field("filter_fn", &"<function>")
92 .finish()
93 }
94}
95
96#[derive(Debug, Clone)]
98pub struct SchemaExtension {
99 pub entity_type: EntityType,
100 pub schema_changes: Vec<SchemaChange>,
101}