Skip to main content

openlark_workflow/
lib.rs

1//! # OpenLark 工作流模块
2//!
3//! OpenLark SDK 的工作流模块,提供飞书任务、审批和看板 API 的完整访问。
4//!
5//! ## 功能特性
6//!
7//! - **任务管理**: 创建、更新、删除、查询待办事项
8//! - **审批流程**: 审批定义、审批实例管理
9//! - **看板管理**: 看板创建、任务卡片管理
10//! - **协作支持**: 添加执行者、关注者、提醒
11//! - **版本支持**: 支持 v1 和 v2 两种 API 版本
12//!
13//! ## 使用示例
14//!
15//! ```rust,no_run
16//! use openlark_workflow::WorkflowService;
17//! use openlark_core::config::Config;
18//!
19//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
20//! let config = Config::builder()
21//!     .app_id("your_app_id")
22//!     .app_secret("your_app_secret")
23//!     .build();
24//!
25//! let workflow_service = WorkflowService::new(config);
26//!
27//! // 创建任务
28//! let result = workflow_service
29//!     .v2()
30//!     .task()
31//!     .create()
32//!     .summary("完成项目文档")
33//!     .execute()
34//!     .await?;
35//! # Ok(())
36//! # }
37//! ```
38
39#![allow(missing_docs)]
40
41mod service;
42
43// 通用模块
44pub mod common;
45
46// 版本模块
47#[cfg(feature = "v1")]
48pub mod v1;
49
50#[cfg(feature = "v2")]
51pub mod v2;
52
53// 看板模块
54#[cfg(feature = "board")]
55pub mod board;
56
57// Prelude 模块
58pub mod prelude;
59
60// 重新导出核心服务
61pub use service::WorkflowService;
62
63/// 工作流模块版本信息
64pub const VERSION: &str = env!("CARGO_PKG_VERSION");
65
66#[cfg(test)]
67#[allow(unused_imports)]
68mod tests {
69    use crate::VERSION;
70
71    #[test]
72    fn test_version() {
73        assert!(!VERSION.is_empty());
74    }
75}
76
77#[cfg(test)]
78mod service_tests {
79    use super::*;
80    use openlark_core::config::Config;
81
82    fn create_test_config() -> Config {
83        Config::builder()
84            .app_id("test_app")
85            .app_secret("test_secret")
86            .build()
87    }
88
89    #[test]
90    fn test_workflow_service_creation() {
91        let config = create_test_config();
92        let service = WorkflowService::new(config);
93        // Service created successfully
94        let _ = service;
95    }
96
97    #[test]
98    fn test_workflow_service_clone() {
99        let config = create_test_config();
100        let service = WorkflowService::new(config);
101        let _cloned = service.clone();
102    }
103
104    #[cfg(feature = "v1")]
105    #[test]
106    fn test_workflow_service_v1() {
107        let config = create_test_config();
108        let service = WorkflowService::new(config);
109        let _v1 = service.v1();
110    }
111
112    #[cfg(feature = "v2")]
113    #[test]
114    fn test_workflow_service_v2() {
115        let config = create_test_config();
116        let service = WorkflowService::new(config);
117        let _v2 = service.v2();
118    }
119
120    #[cfg(feature = "v2")]
121    #[test]
122    fn test_workflow_service_task() {
123        let config = create_test_config();
124        let service = WorkflowService::new(config);
125        let _task = service.task();
126    }
127
128    #[cfg(feature = "v2")]
129    #[test]
130    fn test_workflow_service_tasklist() {
131        let config = create_test_config();
132        let service = WorkflowService::new(config);
133        let _tasklist = service.tasklist();
134    }
135}