import { FileUploadField } from "../entities/file-upload-field.entity";
import { FileUploadSetting } from "../entities/file-upload-setting.entity";

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

export interface IFileUploadSettingsRepository {
  findAll(): Promise<FileUploadSetting[]>;
  findById(id: string): Promise<FileUploadSetting | null>;
  findByCode(code: string): Promise<FileUploadSetting | null>;
  findByEntity(entity: string): Promise<FileUploadSetting[]>;

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

  /* Field-level helpers */
  replaceFields(
    settingId: string,
    fields: Array<Partial<FileUploadField>>,
  ): Promise<FileUploadField[]>;
  addField(
    settingId: string,
    field: Partial<FileUploadField>,
  ): Promise<FileUploadField>;
  updateField(
    fieldId: string,
    data: Partial<FileUploadField>,
  ): Promise<FileUploadField | null>;
  removeField(fieldId: string): Promise<void>;
}
