Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,18 @@ docs-full = [
]

# 人力资源
hr = ["dep:openlark-hr", "openlark-client/hr"]
workflow = ["dep:openlark-workflow"]
hr = ["auth", "dep:openlark-hr", "openlark-client/hr"]
workflow = ["auth", "dep:openlark-workflow", "openlark-client/workflow"]
platform = ["auth", "dep:openlark-platform", "openlark-client/platform"]
application = ["auth", "dep:openlark-application", "openlark-client/application"]
helpdesk = ["auth", "dep:openlark-helpdesk", "openlark-client/helpdesk"]
mail = ["auth", "dep:openlark-mail", "openlark-client/mail"]
analytics = ["auth", "dep:openlark-analytics", "openlark-client/analytics"]
user = ["auth", "dep:openlark-user", "openlark-client/user"]

# === 高级服务模块 (Advanced Services) ===
ai = ["dep:openlark-ai", "openlark-client/ai"]
ai = ["auth", "dep:openlark-ai", "openlark-client/ai"]
meeting = ["auth", "dep:openlark-meeting", "openlark-client/meeting"]
helpdesk = ["dep:openlark-helpdesk"]
mail = ["dep:openlark-mail"]
application = ["dep:openlark-application"]
platform = ["dep:openlark-platform"]
analytics = ["dep:openlark-analytics"]
user = ["dep:openlark-user"]

# === 推荐功能组合 (Recommended Feature Sets) ===
# 核心业务功能
essential = ["auth", "communication", "docs"]
Expand Down
23 changes: 18 additions & 5 deletions crates/openlark-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ openlark-cardkit = { workspace = true, optional = true }
openlark-meeting = { workspace = true, optional = true }
openlark-security = { workspace = true, optional = true }

# Phase 2+ 模块依赖(暂时只保留存在的)
openlark-hr = { workspace = true, optional = true } # 人力资源模块
openlark-ai = { workspace = true, optional = true } # AI服务模块
# openlark-mail = { workspace = true, optional = true } # 暂时注释,未加入workspace
# Phase 2+ 模块依赖
openlark-hr = { workspace = true, optional = true }
openlark-ai = { workspace = true, optional = true }
openlark-workflow = { workspace = true, optional = true }
openlark-platform = { workspace = true, optional = true }
openlark-application = { workspace = true, optional = true }
openlark-helpdesk = { workspace = true, optional = true }
openlark-mail = { workspace = true, optional = true }
openlark-analytics = { workspace = true, optional = true }
openlark-user = { workspace = true, optional = true }

[features]
default = ["auth", "communication"]
Expand All @@ -65,8 +71,15 @@ docs = [
cardkit = ["auth", "dep:openlark-cardkit"]
security = ["auth", "dep:openlark-security"]
hr = ["auth", "dep:openlark-hr"]
ai = ["dep:openlark-ai"]
ai = ["auth", "dep:openlark-ai"]
meeting = ["auth", "dep:openlark-meeting"]
workflow = ["auth", "dep:openlark-workflow"]
platform = ["auth", "dep:openlark-platform"]
application = ["auth", "dep:openlark-application"]
helpdesk = ["auth", "dep:openlark-helpdesk"]
mail = ["auth", "dep:openlark-mail"]
analytics = ["auth", "dep:openlark-analytics"]
user = ["auth", "dep:openlark-user"]

# === 技术特性 ===
websocket = ["tokio-tungstenite", "futures-util", "lark-websocket-protobuf", "url", "prost", "reqwest", "log"]
Expand Down
116 changes: 115 additions & 1 deletion crates/openlark-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl AuthClient {
/// Ok(())
/// }
/// ```
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct Client {
/// 客户端配置
config: Arc<Config>,
Expand Down Expand Up @@ -91,6 +91,67 @@ pub struct Client {
/// Meeting meta 调用链入口:client.meeting.vc.v1.room.create() ...
#[cfg(feature = "meeting")]
pub meeting: openlark_meeting::MeetingClient,

/// AI meta 调用链入口:client.ai.chat.create() ...
#[cfg(feature = "ai")]
pub ai: openlark_ai::AiClient,

/// Workflow meta 调用链入口:client.workflow.task.create() ...
#[cfg(feature = "workflow")]
pub workflow: crate::WorkflowClient,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid Debug-bound breakage from new service aliases

The newly added workflow/application/helpdesk/mail fields use service alias types that do not implement Debug, but Client still derives Debug. Enabling any of those features triggers E0277 and prevents compilation, so these fields should not introduce non-Debug members into a Debug-derived struct without an adaptation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve Client Debug derivation with new feature fields

Client derives Debug, but newly added fields like workflow, application, helpdesk, and mail alias service structs that do not implement Debug. Enabling any of these features triggers E0277 in derive expansion, making those feature-gated builds fail even though they are now advertised as supported.

Useful? React with 👍 / 👎.


/// Platform meta 调用链入口:client.platform.app_engine... ...
#[cfg(feature = "platform")]
pub platform: crate::PlatformClient,

/// Application meta 调用链入口:client.application.applet... ...
#[cfg(feature = "application")]
pub application: crate::ApplicationClient,

/// Helpdesk meta 调用链入口:client.helpdesk.ticket... ...
#[cfg(feature = "helpdesk")]
pub helpdesk: crate::HelpdeskClient,

/// Mail meta 调用链入口:client.mail.group... ...
#[cfg(feature = "mail")]
pub mail: crate::MailClient,

/// Analytics meta 调用链入口:client.analytics.report... ...
#[cfg(feature = "analytics")]
pub analytics: crate::AnalyticsClient,

/// User meta 调用链入口:client.user.setting... ...
#[cfg(feature = "user")]
pub user: crate::UserClient,

/// Security meta 调用链入口:client.security.acs... ...
#[cfg(feature = "security")]
pub security: crate::SecurityClient,
}

impl std::fmt::Debug for Client {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Client")
.field("config", &"<Config>")
.field("registry", &"<Registry>")
.field("core_config", &"<CoreConfig>")
.field("cardkit", &cfg!(feature = "cardkit"))
.field("auth", &cfg!(feature = "auth"))
.field("docs", &cfg!(feature = "docs"))
.field("communication", &cfg!(feature = "communication"))
.field("hr", &cfg!(feature = "hr"))
.field("meeting", &cfg!(feature = "meeting"))
.field("ai", &cfg!(feature = "ai"))
.field("workflow", &cfg!(feature = "workflow"))
.field("platform", &cfg!(feature = "platform"))
.field("application", &cfg!(feature = "application"))
.field("helpdesk", &cfg!(feature = "helpdesk"))
.field("mail", &cfg!(feature = "mail"))
.field("analytics", &cfg!(feature = "analytics"))
.field("user", &cfg!(feature = "user"))
.field("security", &cfg!(feature = "security"))
.finish()
}
}

impl Client {
Expand All @@ -103,6 +164,7 @@ impl Client {
/// export OPENLARK_BASE_URL=https://open.feishu.cn # 可选
/// ```
///
///
/// # 返回值
/// 返回配置好的客户端实例或错误
///
Expand Down Expand Up @@ -195,6 +257,40 @@ impl Client {
#[cfg(feature = "meeting")]
let meeting = openlark_meeting::MeetingClient::new(core_config.clone());

#[cfg(feature = "ai")]
let ai = openlark_ai::AiClient::new(core_config.clone());

#[cfg(feature = "workflow")]
let workflow = crate::WorkflowClient::new(core_config.clone());

#[cfg(feature = "platform")]
let platform = crate::PlatformClient::new(core_config.clone())?;

#[cfg(feature = "application")]
let application = crate::ApplicationClient::new(core_config.clone());

#[cfg(feature = "helpdesk")]
let helpdesk = crate::HelpdeskClient::new(core_config.clone());

#[cfg(feature = "mail")]
let mail = crate::MailClient::new(core_config.clone());

#[cfg(feature = "analytics")]
let analytics = crate::AnalyticsClient::new(core_config.clone())?;

#[cfg(feature = "user")]
let user = crate::UserClient::new(core_config.clone())?;

#[cfg(feature = "security")]
let security = {
let security_config = openlark_security::models::SecurityConfig::new(
config.app_id.clone(),
config.app_secret.clone(),
)
.with_base_url(&config.base_url);
std::sync::Arc::new(openlark_security::SecurityServices::new(security_config))
};

Ok(Client {
config,
registry,
Expand All @@ -211,6 +307,24 @@ impl Client {
hr,
#[cfg(feature = "meeting")]
meeting,
#[cfg(feature = "ai")]
ai,
#[cfg(feature = "workflow")]
workflow,
#[cfg(feature = "platform")]
platform,
#[cfg(feature = "application")]
application,
#[cfg(feature = "helpdesk")]
helpdesk,
#[cfg(feature = "mail")]
mail,
#[cfg(feature = "analytics")]
analytics,
#[cfg(feature = "user")]
user,
#[cfg(feature = "security")]
security,
})
}

Expand Down
62 changes: 62 additions & 0 deletions crates/openlark-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,36 @@ pub use openlark_meeting::MeetingClient;
// 其他服务(当前未启用但已规划)
//(历史上曾尝试在 openlark-client 内重复实现业务服务包装层,但现已收敛为 meta 单入口。)

// 为没有 Client 类型的子 crate 创建类型别名
#[cfg(feature = "ai")]
pub use openlark_ai::AiClient;

#[cfg(feature = "workflow")]
pub type WorkflowClient = openlark_workflow::WorkflowService;

#[cfg(feature = "platform")]
pub type PlatformClient = openlark_platform::PlatformService;

#[cfg(feature = "application")]
pub type ApplicationClient = openlark_application::ApplicationService;

#[cfg(feature = "helpdesk")]
pub type HelpdeskClient = openlark_helpdesk::HelpdeskService;

#[cfg(feature = "mail")]
pub type MailClient = openlark_mail::MailService;

#[cfg(feature = "analytics")]
pub type AnalyticsClient = openlark_analytics::AnalyticsService;

#[cfg(feature = "user")]
pub type UserClient = openlark_user::UserService;

#[cfg(feature = "security")]
/// Security 服务客户端别名(Arc 包装以支持 Client 克隆)
pub type SecurityClient = std::sync::Arc<openlark_security::SecurityServices>;
//(历史上曾尝试在 openlark-client 内重复实现业务服务包装层,但现已收敛为 meta 单入口。)

// ============================================================================
// Core 系统类型重新导出
// ============================================================================
Expand Down Expand Up @@ -458,6 +488,38 @@ pub mod prelude {
// 其他服务(当前未启用但已规划)
//(历史上曾尝试在 openlark-client 内重复实现业务服务包装层,但现已收敛为 meta 单入口。)

#[cfg(feature = "ai")]
pub use openlark_ai::AiClient;

#[cfg(feature = "workflow")]
pub use crate::WorkflowClient;

#[cfg(feature = "platform")]
pub use crate::PlatformClient;

#[cfg(feature = "application")]
pub use crate::ApplicationClient;

#[cfg(feature = "helpdesk")]
pub use crate::HelpdeskClient;

#[cfg(feature = "mail")]
pub use crate::MailClient;

#[cfg(feature = "analytics")]
pub use crate::AnalyticsClient;

#[cfg(feature = "user")]
pub use crate::UserClient;

#[cfg(feature = "security")]
pub use crate::SecurityClient;

// ============================================================================
// 便利类型别名
// ============================================================================
//(历史上曾尝试在 openlark-client 内重复实现业务服务包装层,但现已收敛为 meta 单入口。)

// ============================================================================
// 便利类型别名
// ============================================================================
Expand Down
Loading
Loading