pub struct EntityService { /* private fields */ }Expand description
Unified entity and member management service
Implementations§
Source§impl EntityService
impl EntityService
Sourcepub fn new(crdt_manager: Arc<CrdtManager>) -> Self
pub fn new(crdt_manager: Arc<CrdtManager>) -> Self
Create a new entity service
Sourcepub async fn create_entity(
&self,
name: String,
entity_type: EntityType,
description: Option<String>,
created_by: String,
initial_members: Vec<String>,
) -> EntityServiceResult<Entity>
pub async fn create_entity( &self, name: String, entity_type: EntityType, description: Option<String>, created_by: String, initial_members: Vec<String>, ) -> EntityServiceResult<Entity>
Create a new entity
Sourcepub async fn get_entity(&self, entity_id: &str) -> EntityServiceResult<Entity>
pub async fn get_entity(&self, entity_id: &str) -> EntityServiceResult<Entity>
Get entity by ID
Sourcepub async fn list_entities(&self) -> EntityServiceResult<Vec<Entity>>
pub async fn list_entities(&self) -> EntityServiceResult<Vec<Entity>>
List all entities
Sourcepub async fn add_member(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
role: &str,
) -> EntityServiceResult<()>
pub async fn add_member( &self, entity_type: EntityType, entity_id: &str, member_id: &str, role: &str, ) -> EntityServiceResult<()>
Add member to entity
Sourcepub async fn remove_member(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
deleted_by: &str,
) -> EntityServiceResult<()>
pub async fn remove_member( &self, entity_type: EntityType, entity_id: &str, member_id: &str, deleted_by: &str, ) -> EntityServiceResult<()>
Remove member from entity
Sourcepub async fn list_members(
&self,
entity_type: EntityType,
entity_id: &str,
) -> EntityServiceResult<Vec<MemberInfo>>
pub async fn list_members( &self, entity_type: EntityType, entity_id: &str, ) -> EntityServiceResult<Vec<MemberInfo>>
List members of entity
Sourcepub async fn set_parent_organization(
&self,
entity_id: &str,
parent_org_id: &str,
) -> EntityServiceResult<()>
pub async fn set_parent_organization( &self, entity_id: &str, parent_org_id: &str, ) -> EntityServiceResult<()>
Set parent organization for a child entity
Sourcepub async fn remove_organization_member(
&self,
org_id: &str,
member_id: &str,
deleted_by: &str,
) -> EntityServiceResult<CascadeRemovalResult>
pub async fn remove_organization_member( &self, org_id: &str, member_id: &str, deleted_by: &str, ) -> EntityServiceResult<CascadeRemovalResult>
Remove member from organization and all child entities (channels, groups, projects)
Sourcepub async fn create_local_entity(
&self,
name: String,
entity_type: EntityType,
description: Option<String>,
created_by: String,
) -> EntityServiceResult<Entity>
pub async fn create_local_entity( &self, name: String, entity_type: EntityType, description: Option<String>, created_by: String, ) -> EntityServiceResult<Entity>
Create a new local-only entity (no network identity)
Sourcepub async fn link_entity_to_network(
&self,
entity_id: &str,
four_words: &str,
) -> EntityServiceResult<Entity>
pub async fn link_entity_to_network( &self, entity_id: &str, four_words: &str, ) -> EntityServiceResult<Entity>
Link an existing entity to a network identity
Sourcepub async fn mark_entity_synced(
&self,
entity_id: &str,
) -> EntityServiceResult<Entity>
pub async fn mark_entity_synced( &self, entity_id: &str, ) -> EntityServiceResult<Entity>
Update entity sync timestamp
pub async fn update_entity( &self, entity_id: &str, name: Option<String>, description: Option<Option<String>>, ) -> EntityServiceResult<Entity>
pub async fn delete_entity(&self, entity_id: &str) -> EntityServiceResult<()>
Sourcepub async fn import_entity(
&self,
id: String,
name: String,
entity_type: EntityType,
description: Option<String>,
created_by: String,
created_at: i64,
joiner_four_words: String,
role: String,
) -> EntityServiceResult<Entity>
pub async fn import_entity( &self, id: String, name: String, entity_type: EntityType, description: Option<String>, created_by: String, created_at: i64, joiner_four_words: String, role: String, ) -> EntityServiceResult<Entity>
Import/join an existing entity by ID (for multi-node sync)
This allows a node to join an entity that was created on another node. The caller provides the entity metadata including the original ID.
Sourcepub async fn set_permission_override(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
resource_type: &str,
access_level: &str,
) -> EntityServiceResult<()>
pub async fn set_permission_override( &self, entity_type: EntityType, entity_id: &str, member_id: &str, resource_type: &str, access_level: &str, ) -> EntityServiceResult<()>
Set a permission override for a member
Stores the override in the entity’s CRDT document under the member’s permission_overrides map. This override takes precedence over role defaults.
Sourcepub async fn remove_permission_override(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
resource_type: &str,
) -> EntityServiceResult<()>
pub async fn remove_permission_override( &self, entity_type: EntityType, entity_id: &str, member_id: &str, resource_type: &str, ) -> EntityServiceResult<()>
Remove a permission override for a member
Removes the override, reverting to the member’s role default for that resource.
Sourcepub async fn get_permission_overrides(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
) -> EntityServiceResult<Vec<(String, String)>>
pub async fn get_permission_overrides( &self, entity_type: EntityType, entity_id: &str, member_id: &str, ) -> EntityServiceResult<Vec<(String, String)>>
Get all permission overrides for a member
Returns a map of resource_type -> access_level for all overrides.
Sourcepub async fn set_member_role(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
new_role: &str,
) -> EntityServiceResult<()>
pub async fn set_member_role( &self, entity_type: EntityType, entity_id: &str, member_id: &str, new_role: &str, ) -> EntityServiceResult<()>
Update a member’s role
Changes the member’s role in the CRDT document. Note that this does not clear existing permission overrides - they continue to take precedence.
Sourcepub async fn get_member_role(
&self,
entity_type: EntityType,
entity_id: &str,
member_id: &str,
) -> EntityServiceResult<String>
pub async fn get_member_role( &self, entity_type: EntityType, entity_id: &str, member_id: &str, ) -> EntityServiceResult<String>
Get a member’s role from the CRDT document