1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Trigger system for serverless functions.
//!
//! Triggers enable functions to execute in response to specific events:
//! - `after:mutation`: Fire after mutation completes (async, non-blocking)
//! - `before:mutation`: Fire before mutation (sync, can abort)
//! - `after:storage`: Fire after storage operations
//! - `cron`: Fire on schedule
//! - `http`: Custom HTTP endpoints
//!
//! # Integration Overview
//!
//! The trigger system is designed for modular integration with the FraiseQL server:
//!
//! 1. **Registry Loading**: `TriggerRegistry::load_from_definitions()` parses function definitions
//! from the compiled schema and initializes all trigger types.
//!
//! 2. **Trigger Types**:
//! - `AfterMutationTrigger`: Receives mutation events via observer pipeline (async dispatch)
//! - `BeforeMutationTrigger`: Intercepts mutations before DB write (sync, can abort)
//! - `StorageTrigger`: Responds to storage operations (async dispatch)
//! - `CronTrigger`: Scheduled execution with state persistence
//! - `HttpTriggerRoute`: Custom HTTP endpoints
//!
//! 3. **Lifecycle**:
//! - **Startup**: `TriggerRegistry` initializes cron scheduler, validates triggers
//! - **Runtime**: Triggers dispatch to function observer based on events
//! - **Shutdown**: Cron scheduler stops, pending tasks drain
//!
//! # Usage Example
//!
//! ```ignore
//! // Load all triggers from schema
//! let registry = TriggerRegistry::load_from_definitions(&functions)?;
//!
//! // Query triggers by type
//! let http_routes = registry.http_routes();
//! let before_hooks = registry.before_mutation_triggers_for("createUser");
//! ```
//!
//! # Error Handling
//!
//! `RegistryError` is returned for invalid trigger formats or misconfiguration.
//! All trigger types validate input and return clear error messages.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;