← back to Handbag Auth Nextjs

src/types/priceHistory.ts

57 lines

// Price history tracking types for handbags
// Enables daily price snapshots and historical charts

export interface PriceSnapshot {
  id: string;
  handbagId: string;         // Reference to handbag in database
  merchantId: string;        // Which merchant/affiliate
  merchantName: string;
  condition: "new" | "used" | "auction";
  price: number;
  currency: string;
  url: string;               // Product URL (with affiliate code)
  snapshotDate: string;      // ISO date: "2025-11-15"
  timestamp: string;         // ISO datetime
  inStock: boolean;
  notes?: string;
}

export interface HandbagPriceHistory {
  handbagId: string;
  brand: string;
  model: string;
  color?: string;
  size?: string;
  snapshots: PriceSnapshot[];

  // Computed fields
  currentLowestPrice?: number;
  allTimeLowestPrice?: number;
  allTimeHighestPrice?: number;
  averagePrice?: number;
  priceChange30d?: number;   // Percentage change last 30 days
  priceChange90d?: number;   // Percentage change last 90 days
}

export interface MerchantPriceSeries {
  merchantName: string;
  merchantId: string;
  condition: "new" | "used" | "auction";
  dataPoints: Array<{
    date: string;            // "2025-11-15"
    price: number;
    inStock: boolean;
  }>;
}

export interface PriceChartData {
  handbagId: string;
  brand: string;
  model: string;
  dateRange: {
    start: string;
    end: string;
  };
  series: MerchantPriceSeries[];
}