1#![allow(unused_imports)]
25
26pub use openlark_client::{Client, ClientBuilder, Error, Result};
31pub use openlark_core::SDKResult;
32pub use openlark_core::config::Config;
33pub use openlark_core::config::Config as CoreConfig;
34pub use openlark_core::error::{CoreError, ErrorCode, ErrorSeverity, ErrorTrait, ErrorType};
35pub use openlark_core::req_option::RequestOption;
36
37#[cfg(feature = "websocket")]
38pub mod ws_client {
40 pub use openlark_client::ws_client::*;
41}
42
43#[cfg(feature = "auth")]
48pub use openlark_auth as auth;
49
50#[cfg(feature = "communication")]
51pub use openlark_communication as communication;
52
53#[cfg(any(
54 feature = "docs",
55 feature = "docs-ccm",
56 feature = "docs-base",
57 feature = "docs-bitable",
58 feature = "docs-drive",
59 feature = "docs-explorer",
60 feature = "docs-sheets",
61 feature = "docs-full"
62))]
63pub use openlark_docs as docs;
64
65#[cfg(feature = "hr")]
66pub use openlark_hr as hr;
67
68#[cfg(feature = "ai")]
69pub use openlark_ai as ai;
70
71#[cfg(feature = "helpdesk")]
72pub use openlark_helpdesk as helpdesk;
73
74#[cfg(feature = "mail")]
75pub use openlark_mail as mail;
76
77#[cfg(feature = "bot")]
78pub use openlark_bot as bot;
79
80#[cfg(feature = "meeting")]
81pub use openlark_meeting as meeting;
82
83#[cfg(feature = "application")]
84pub use openlark_application as application;
85
86#[cfg(feature = "security")]
87pub use openlark_security as security;
88
89#[cfg(feature = "workflow")]
90pub use openlark_workflow as workflow;
91
92#[cfg(feature = "platform")]
93pub use openlark_platform as platform;
94
95#[cfg(feature = "analytics")]
96pub use openlark_analytics as analytics;
97
98#[cfg(feature = "user")]
99pub use openlark_user as user;
100
101#[cfg(feature = "webhook")]
102pub use openlark_webhook as webhook;
103
104#[cfg(feature = "cardkit")]
105pub use openlark_cardkit as cardkit;
106
107pub mod prelude {
116 pub use crate::SDKResult;
117 pub use crate::{Client, ClientBuilder, CoreConfig, Error, Result};
118 pub use crate::{CoreError, ErrorCode, ErrorSeverity, ErrorTrait, ErrorType, RequestOption};
119 pub use openlark_core::prelude::*;
120}
121
122#[cfg(test)]
123mod tests {
124 use super::*;
125
126 fn build_test_client() -> Result<Client> {
127 Client::builder()
128 .app_id("test_app")
129 .app_secret("test_secret")
130 .build()
131 }
132
133 #[test]
134 fn root_prelude_exposes_canonical_core_entrypoints() {
135 use crate::prelude::*;
136
137 let _builder: ClientBuilder = Client::builder();
138 let _config: CoreConfig = CoreConfig::builder()
139 .app_id("test_app")
140 .app_secret("test_secret")
141 .build();
142 let _request_option: Option<RequestOption> = None;
143 }
144
145 #[test]
146 fn root_minimal_builder_works_without_service_features() {
147 let client = build_test_client().expect("client should build with minimal features");
148 assert_eq!(client.config().app_id(), "test_app");
149 }
150
151 #[cfg(feature = "auth")]
152 #[test]
153 fn root_client_exposes_auth_entrypoint() {
154 let client = build_test_client().expect("client should build with auth feature");
155 let _auth = &client.auth;
156 }
157
158 #[cfg(feature = "communication")]
159 #[test]
160 fn root_client_exposes_communication_namespace() {
161 let client = build_test_client().expect("client should build with communication feature");
162 let _communication = &client.communication;
163 let _endpoint = crate::communication::endpoints::IM_V1_MESSAGES;
164 }
165
166 #[cfg(any(
167 feature = "docs",
168 feature = "docs-ccm",
169 feature = "docs-base",
170 feature = "docs-bitable",
171 feature = "docs-drive",
172 feature = "docs-explorer",
173 feature = "docs-sheets",
174 feature = "docs-full"
175 ))]
176 #[test]
177 fn root_client_exposes_docs_namespace() {
178 let client = build_test_client().expect("client should build with docs feature");
179 let _docs = &client.docs;
180 }
181
182 #[cfg(feature = "hr")]
183 #[test]
184 fn root_client_exposes_hr_entrypoint() {
185 let client = build_test_client().expect("client should build with hr feature");
186 let _hr = &client.hr;
187 }
188
189 #[cfg(feature = "security")]
190 #[test]
191 fn root_client_exposes_security_entrypoint() {
192 let client = build_test_client().expect("client should build with security feature");
193 let _security = &client.security;
194 }
195
196 #[cfg(feature = "docs-bitable")]
197 #[test]
198 fn root_docs_bitable_feature_exposes_query_helper() {
199 let query = crate::docs::BitableRecordQuery::new("app_token", "table_id")
200 .where_equals("状态", "进行中");
201
202 assert_eq!(query.app_token, "app_token");
203 assert_eq!(query.table_id, "table_id");
204 }
205
206 #[cfg(feature = "docs-drive")]
207 #[test]
208 fn root_docs_drive_feature_exposes_drive_helpers() {
209 let upload = crate::docs::DriveUploadFile::new("demo.txt", vec![1, 2, 3]);
210 let range = crate::docs::DriveDownloadRange::from_start(0).with_end(9);
211
212 assert_eq!(upload.file_name, "demo.txt");
213 assert_eq!(upload.size(), 3);
214 assert_eq!(range.to_header_value(), "bytes=0-9");
215 }
216
217 #[cfg(feature = "essential")]
218 #[test]
219 fn root_essential_feature_combines_docs_and_communication_paths() {
220 let client = build_test_client().expect("client should build with essential feature");
221
222 let _communication = &client.communication;
223 let _docs = &client.docs;
224 let recipient = crate::communication::MessageRecipient::open_id("ou_xxx");
225 let query = crate::docs::BitableRecordQuery::new("app_token", "table_id");
226
227 assert_eq!(recipient.receive_id, "ou_xxx");
228 assert_eq!(query.table_id, "table_id");
229 }
230
231 #[cfg(feature = "enterprise")]
232 #[test]
233 fn root_enterprise_feature_combines_quality_critical_domains() {
234 let client = build_test_client().expect("client should build with enterprise feature");
235
236 let _security = &client.security;
237 let _hr = &client.hr;
238 let _workflow = &client.workflow;
239 let action = crate::workflow::ApprovalTaskAction::new(
240 "approval_code",
241 "instance_code",
242 "ou_xxx",
243 "task_123",
244 )
245 .comment("同意");
246
247 assert_eq!(action.task_id, "task_123");
248 assert_eq!(action.comment.as_deref(), Some("同意"));
249 }
250
251 #[cfg(feature = "webhook-full")]
252 #[test]
253 fn root_webhook_full_feature_exposes_signature_and_robot_client() {
254 let client = crate::webhook::WebhookClient::new();
255 let signature = crate::webhook::common::signature::sign(1_700_000_000, "secret");
256
257 let _ = client;
258 assert!(!signature.is_empty());
259 }
260}