import { DropdownOption } from "../entities/dropdown-option.entity";
import { DropdownSetting } from "../entities/dropdown-setting.entity";

/**
 * Contract every DropdownSettings repository must satisfy. Lets services
 * depend on the abstraction and lets tests swap in an in-memory fake.
 */
export const DROPDOWN_SETTINGS_REPOSITORY = Symbol(
  "DROPDOWN_SETTINGS_REPOSITORY",
);

export interface IDropdownSettingsRepository {
  findAll(): Promise<DropdownSetting[]>;
  findById(id: string): Promise<DropdownSetting | null>;
  findByCode(code: string): Promise<DropdownSetting | null>;

  create(data: Partial<DropdownSetting>): Promise<DropdownSetting>;
  update(
    id: string,
    data: Partial<DropdownSetting>,
  ): Promise<DropdownSetting | null>;
  softDelete(id: string): Promise<void>;

  /* Option-level helpers */
  replaceOptions(
    settingId: string,
    options: Array<Partial<DropdownOption>>,
  ): Promise<DropdownOption[]>;
  addOption(
    settingId: string,
    option: Partial<DropdownOption>,
  ): Promise<DropdownOption>;
  updateOption(
    optionId: string,
    data: Partial<DropdownOption>,
  ): Promise<DropdownOption | null>;
  removeOption(optionId: string): Promise<void>;
}
