//! 控制面 store trait。 use crate::error::ControlPlaneError; use crate::model::{ AiPolicyRecord, AiRuntimeEventRecord, AiRuntimeRunRecord, AppendAiRuntimeEventInput, AppendAuditInput, AuditLogRecord, AuthSessionRecord, AuthenticatePasswordInput, CreatePasswordIdentityInput, CreateSessionInput, CreateShareLinkInput, CreatedShareLink, DirectoryGrantInput, DirectoryGrantLookup, DirectoryGrantRecord, NavigationRecentRecord, OutboxEventInput, OutboxEventRecord, ResolvedAccess, ResolvedAuthSession, ShareLinkRecord, SidebarShortcutRecord, SyncStateRecord, UpsertAiPolicyInput, UpsertAiRuntimeRunInput, UpsertNavigationRecentInput, UpsertSidebarShortcutInput, UpsertSyncStateInput, UpsertUserInput, UpsertUserUiPreferenceInput, UserRecord, UserUiPreferenceRecord, WorkspaceRecord, }; pub trait ControlPlaneStore: Send + Sync { fn upsert_user(&self, input: UpsertUserInput) -> Result; fn create_password_identity( &self, input: CreatePasswordIdentityInput, ) -> Result<(), ControlPlaneError>; fn authenticate_password( &self, input: AuthenticatePasswordInput, ) -> Result; fn create_session( &self, input: CreateSessionInput, ) -> Result; fn get_session_by_token_hash( &self, token_hash: &str, ) -> Result, ControlPlaneError>; fn revoke_session(&self, session_id: &str) -> Result<(), ControlPlaneError>; fn ensure_default_workspace( &self, actor_id: &str, ) -> Result; fn grant_directory_access( &self, input: DirectoryGrantInput, ) -> Result; fn list_directory_grants(&self) -> Result, ControlPlaneError>; fn list_directory_grants_for_actor( &self, actor_id: &str, ) -> Result, ControlPlaneError>; fn find_directory_grants( &self, lookup: DirectoryGrantLookup, ) -> Result, ControlPlaneError>; fn revoke_directory_grant( &self, grant_id: &str, expected_revision: Option, ) -> Result<(), ControlPlaneError>; fn resolve_access( &self, actor_id: &str, root_uri: &str, ) -> Result; fn create_share_link( &self, input: CreateShareLinkInput, ) -> Result; fn list_share_links( &self, workspace_id: &str, ) -> Result, ControlPlaneError>; fn resolve_share_link( &self, token_hash: &str, ) -> Result, ControlPlaneError>; fn revoke_share_link(&self, link_id: &str) -> Result<(), ControlPlaneError>; fn append_audit(&self, input: AppendAuditInput) -> Result<(), ControlPlaneError>; fn list_audit_log(&self, limit: usize) -> Result, ControlPlaneError>; fn append_outbox( &self, input: OutboxEventInput, ) -> Result; fn drain_outbox(&self, limit: usize) -> Result, ControlPlaneError>; fn mark_outbox_delivered(&self, event_id: &str) -> Result<(), ControlPlaneError>; fn upsert_sidebar_shortcut( &self, input: UpsertSidebarShortcutInput, ) -> Result; fn list_sidebar_shortcuts( &self, user_id: &str, workspace_id: &str, ) -> Result, ControlPlaneError>; fn list_sidebar_shortcuts_with_global_local( &self, user_id: &str, workspace_id: &str, ) -> Result, ControlPlaneError>; fn delete_sidebar_shortcut( &self, user_id: &str, shortcut_id: &str, ) -> Result<(), ControlPlaneError>; fn upsert_user_ui_preference( &self, input: UpsertUserUiPreferenceInput, ) -> Result; fn list_user_ui_preferences( &self, user_id: &str, workspace_id: Option<&str>, source_kind: Option<&str>, ) -> Result, ControlPlaneError>; fn upsert_navigation_recent( &self, input: UpsertNavigationRecentInput, ) -> Result; fn list_navigation_recent( &self, user_id: &str, kind: Option<&str>, limit: usize, ) -> Result, ControlPlaneError>; fn upsert_ai_policy( &self, input: UpsertAiPolicyInput, ) -> Result; fn get_ai_policy( &self, actor_id: &str, workspace_id: Option<&str>, ) -> Result, ControlPlaneError>; fn upsert_sync_state( &self, input: UpsertSyncStateInput, ) -> Result; fn get_sync_state( &self, workspace_id: &str, remote_kind: &str, ) -> Result, ControlPlaneError>; fn upsert_ai_runtime_run( &self, input: UpsertAiRuntimeRunInput, ) -> Result; fn list_ai_runtime_runs( &self, user_id: &str, workspace_id: Option<&str>, document_id: Option<&str>, session_id: Option<&str>, limit: usize, ) -> Result, ControlPlaneError>; fn append_ai_runtime_event( &self, input: AppendAiRuntimeEventInput, ) -> Result; fn list_ai_runtime_events( &self, user_id: &str, run_id: &str, limit: usize, ) -> Result, ControlPlaneError>; fn rename_ai_runtime_session( &self, user_id: &str, session_id: &str, workspace_id: Option<&str>, title: &str, ) -> Result, ControlPlaneError>; fn auto_title_ai_runtime_session( &self, user_id: &str, session_id: &str, workspace_id: Option<&str>, ) -> Result, ControlPlaneError>; fn delete_ai_runtime_session( &self, user_id: &str, session_id: &str, workspace_id: Option<&str>, ) -> Result; }