// Типы данных — соответствуют db/schema.sql (view works_extended, таблицы auctions/bids). export type WorkStatus = 'draft' | 'published' | 'sold'; export type AuctionMode = 'none' | 'primary' | 'secondary'; export type AuctionType = 'primary' | 'secondary'; export type AuctionStatus = | 'pending' | 'active' | 'ended' | 'sold' | 'cancelled'; export interface Media { id: string; work_id: string; url: string; thumb_url: string | null; type: 'image' | 'video'; sort_order: number; } // Соответствует VIEW works_extended (+ вложенное media при детальном запросе). export interface Work { id: string; title: string; slug: string; description: string | null; medium: string | null; dimensions: string | null; year: number | null; price: string | number | null; // NUMERIC приходит строкой из pg status: WorkStatus; auction_mode: AuctionMode; created_at: string; updated_at: string; // агрегаты из works_extended likes_count?: number; comments_count?: number; avg_rating?: number | null; reviews_count?: number; cover_url?: string | null; cover_thumb?: string | null; // вложенное (детальная выдача) media?: Media[]; } export interface Auction { id: string; work_id: string; type: AuctionType; start_price: string | number; current_price: string | number; reserve_price: string | number | null; min_step: string | number; start_at: string; end_at: string; status: AuctionStatus; winner_id: string | null; created_at: string; // денормализация с бэкенда (join с works) — опционально work?: Work; bids_count?: number; } export interface Bid { id: string; auction_id: string; user_id: string; amount: string | number; created_at: string; } // Форма пагинированного ответа списка (гибко: массив или {items,total}). export interface Paginated { items: T[]; total: number; page?: number; pageSize?: number; }