zeal_sdk/lib.rs
1//! # Zeal Rust SDK
2//!
3//! High-performance Rust SDK for the Zeal Integration Protocol (ZIP), enabling efficient
4//! third-party workflow runtime integration with the Zeal workflow editor.
5//!
6//! ## Features
7//!
8//! - **Zero-copy JSON parsing** with `serde_json` and optional `simd-json`
9//! - **Async/await support** with `tokio` and `futures`
10//! - **WebSocket real-time communication** with `tokio-tungstenite`
11//! - **HTTP/2 client** with `reqwest` and connection pooling
12//! - **Observable streams** with `futures-util` and custom stream combinators
13//! - **Built-in retry logic** with exponential backoff
14//! - **Thread-safe concurrent operations**
15//!
16//! ## Quick Start
17//!
18//! ```ignore
19//! use zeal_sdk::{ZealClient, ClientConfig};
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
23//! let client = ZealClient::new(ClientConfig {
24//! base_url: "http://localhost:3000".to_string(),
25//! ..Default::default()
26//! })?;
27//!
28//! // Register node templates
29//! client.templates().register(
30//! "my-runtime",
31//! vec![/* templates */],
32//! None
33//! ).await?;
34//!
35//! Ok(())
36//! }
37//! ```
38
39pub mod auth;
40pub mod client;
41pub mod config;
42pub mod errors;
43pub mod events;
44pub mod observables;
45pub mod orchestrator;
46pub mod subscription;
47pub mod templates;
48pub mod traces;
49pub mod types;
50pub mod webhooks;
51
52// #[cfg(feature = "telemetry")]
53// pub mod telemetry;
54
55#[cfg(feature = "webhook-server")]
56pub use subscription::start_webhook_server;
57
58// Re-export main types
59pub use client::ZealClient;
60pub use config::{ClientConfig, PerformanceConfig};
61pub use errors::{Result, ZealError};
62pub use subscription::{SubscriptionOptions, WebhookSubscription};
63pub use types::*;
64
65// Re-export key traits and functions
66pub use events::{
67 ConnectionState, ConnectionStateEvent, ElementState, ElementType, ExecutionCompletedEvent,
68 ExecutionFailedEvent, ExecutionStartedEvent, NodeCompletedEvent, NodeExecutingEvent,
69 NodeFailedEvent, NodeWarningEvent, VisualStateElement, VisualStateUpdate, WorkflowCreatedEvent,
70 WorkflowDeletedEvent, WorkflowUpdatedEvent, ZipControlEvent, ZipExecutionEvent,
71 ZipWebSocketEvent, ZipWebhookEvent, ZipWorkflowEvent,
72};
73pub use observables::{ObservableExt, ZealObservable};
74pub use traces::{TraceEvent, TraceEventType, TraceStatus};
75
76/// SDK version
77pub const VERSION: &str = env!("CARGO_PKG_VERSION");
78
79/// Default API path prefix
80pub const API_PREFIX: &str = "/api/zip";
81
82/// Default WebSocket path
83pub const WS_PATH: &str = "/ws/zip";
84
85#[cfg(test)]
86mod tests {
87 use super::*;
88
89 #[test]
90 fn test_version() {
91 assert!(!VERSION.is_empty());
92 }
93
94 #[test]
95 fn test_constants() {
96 assert_eq!(API_PREFIX, "/api/zip");
97 assert_eq!(WS_PATH, "/ws/zip");
98 }
99}