slave 0.4.0

Laravel-inspired CLI for Rust MCP servers: scaffold apps whose business operations are MCP tools over Streamable HTTP, with built-in auth, users, roles and Turso migrations
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::modules::role::models::role::Role;

/// Arguments of `role_list_for_user`.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct UserRolesRequest {
    pub user_id: i64,
}

/// Arguments of `role_assign` and `role_revoke`.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct RoleAssignmentRequest {
    pub user_id: i64,
    /// Role name, for example `admin` or `user`.
    pub role: String,
}

#[derive(Debug, Serialize, JsonSchema)]
pub struct RoleResponse {
    pub id: i64,
    pub name: String,
}

/// A list of roles: all roles, or those held by one user.
#[derive(Debug, Serialize, JsonSchema)]
pub struct RoleListResponse {
    pub roles: Vec<RoleResponse>,
}

impl From<Role> for RoleResponse {
    fn from(role: Role) -> Self {
        Self {
            id: role.id,
            name: role.name,
        }
    }
}

impl From<Vec<Role>> for RoleListResponse {
    fn from(roles: Vec<Role>) -> Self {
        Self {
            roles: roles.into_iter().map(RoleResponse::from).collect(),
        }
    }
}