import { IsArray, IsIn, IsOptional, IsString, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { GOVERNANCE_DICTIONARY_KINDS, type GovernanceDictionaryKind } from '../governance.service';

export class GovernanceDictionaryDto {
  @IsString()
  actorId!: string;

  @IsIn(GOVERNANCE_DICTIONARY_KINDS)
  kind!: GovernanceDictionaryKind;

  @IsString()
  name!: string;

  @IsOptional()
  @IsString()
  code?: string;

  @IsOptional()
  @IsString()
  group?: string;

  @IsOptional()
  @IsString()
  scope?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  permissions?: string[];
}

export class RemoveGovernanceDictionaryDto {
  @IsString()
  actorId!: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  permissions?: string[];
}

export class ImportGovernanceDictionariesDto {
  @IsString()
  actorId!: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  permissions?: string[];

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => GovernanceDictionaryDto)
  items!: GovernanceDictionaryDto[];
}
