import { Document, Types } from 'mongoose';

import { IPaginateModel } from '@/shared/interfaces/model.interface';
import { AuditFields } from '@/shared/types/common';

// Base Role Interface (Clean & concise)
export interface IRoleBase {
  name: string;
  description: string;
  permissions: Types.ObjectId[];
  parentRole?: Types.ObjectId;
  company: Types.ObjectId;
}

// Complete Role Interface with audit fields
export interface IRole extends IRoleBase, AuditFields {}

// Mongoose Document
export interface IRoleDoc extends IRole, Document {}

// Mongoose Model
export interface IRoleModel extends IPaginateModel<IRoleDoc> {
  isRoleNameTaken(name: string): Promise<boolean>;
}

export type NewCreatedRole = IRoleBase &
  Partial<Pick<AuditFields, 'createdBy' | 'updatedBy'>>;
export type UpdateRoleBody = Partial<IRole>;

export interface IRoleFilter {
  search?: string;
  companyId?: Types.ObjectId | string;
}
