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, Copy, PartialEq, Eq)]
54pub enum AutoTimestamp {
55 Created,
57 Updated,
59}
60
61#[derive(Debug, Clone)]
63pub struct TableColumn {
64 pub name: String,
65 pub column_type: String,
66 pub primary_key: bool,
67 pub nullable: bool,
68 pub default: Option<String>,
69 pub foreign_key: Option<ForeignKey>,
70 pub auto_timestamp: Option<AutoTimestamp>,
72}
73
74#[derive(Debug, Clone)]
76pub struct ForeignKey {
77 pub table: String,
78 pub column: String,
79}
80
81#[derive(Debug, Clone)]
83pub struct ModelField {
84 pub name: String,
85 pub type_: String,
86 pub optional: bool,
87}
88
89pub type QueryFilterFn = Box<dyn Fn(Vec<serde_json::Value>, std::collections::HashMap<String, serde_json::Value>) -> Result<Vec<serde_json::Value>, String> + Send + Sync>;
91
92pub struct QueryFilter {
94 pub name: String,
95 pub filter_fn: QueryFilterFn,
96}
97
98impl std::fmt::Debug for QueryFilter {
99 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
100 f.debug_struct("QueryFilter")
101 .field("name", &self.name)
102 .field("filter_fn", &"<function>")
103 .finish()
104 }
105}
106
107#[derive(Debug, Clone)]
109pub struct SchemaExtension {
110 pub entity_type: EntityType,
111 pub schema_changes: Vec<SchemaChange>,
112}