export type AuthUser = {
  id: number;
  username: string;
  role: UserRole;
};

export type UserRole = "admin" | "user";

export type AuthBootstrapResponse =
  | { mode: "login" }
  | { mode: "fixed"; token: string; user: AuthUser };

export type ManagedUser = {
  id: number;
  username: string;
  role: UserRole;
  enabled: boolean;
  expires_at: string | null;
  created_at: string;
  updated_at: string;
};

export type UserListResponse = {
  users: ManagedUser[];
};

export type Folder = {
  id: number;
  parent_id: number | null;
  name: string;
  path: string;
  library_type: "system" | "user";
  owner_user_id: number | null;
  is_system: number;
  owner_username?: string | null;
  model_count: number;
  permissions: PermissionPayload;
};

export type PermissionPayload = {
  read: boolean;
  write: boolean;
};

export type ModelItem = {
  id: number;
  folder_id: number;
  brand_id: number | null;
  type_id: number | null;
  name: string;
  original_filename: string;
  file_path: string;
  file_url: string;
  library_type: "system" | "user";
  owner_user_id: number | null;
  storage_provider: "local" | "cos";
  file_size: number;
  thumbnail_path: string | null;
  thumbnail_provider: "local" | "cos" | null;
  thumbnail_url: string | null;
  operation_tree: string;
  brand_name: string | null;
  type_name: string | null;
  permissions: PermissionPayload;
  properties: Record<string, string>;
};

export type FolderTreeResponse = {
  folders: Folder[];
  tree: unknown[];
};

export type ModelListResponse = {
  total: number;
  page: number;
  pageSize: number;
  items: ModelItem[];
};

export type DictionaryItem = {
  id: number;
  name: string;
};

export type DictionaryResponse = {
  brands: DictionaryItem[];
  types: DictionaryItem[];
};
