"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),utils_1=require("../utils"),error_1=require("@b/utils/error");exports.metadata={summary:"Retrieves a specific role by ID",operationId:"getRole",tags:["Admin","CRM","Role"],parameters:[{index:0,name:"id",in:"path",description:"ID of the role to retrieve",required:!0,schema:{type:"number"}}],permission:"view.role",responses:{200:{description:"Role retrieved successfully",content:{"application/json":{schema:{type:"object",properties:utils_1.baseRoleSchema}}}},404:{description:"Role not found"},500:{description:"Internal server error"}},requiresAuth:!0,logModule:"ADMIN_CRM",logTitle:"Get Role"};exports.default=async e=>{const{params:r,ctx:t}=e;null==t||t.step("Fetching role");const s=await db_1.models.role.findOne({where:{id:r.id},include:[{model:db_1.models.permission,as:"permissions",through:{attributes:[]},attributes:["id","name"]}]});if(!s)throw(0,error_1.createError)({statusCode:404,message:"Role not found"});null==t||t.success("Role retrieved successfully");return s.get({plain:!0})};