// Auto-generated types (from Model Contract)

export interface User {
  id?: string;
  username: string;
  passwordHash: string;
  nickname?: string;
  role?: string;
  phone?: string;
  avatarUrl?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Product {
  id?: string;
  userId: string;
  title: string;
  description?: string;
  price?: number;
  stock?: number;
  images?: Record<string, unknown>;
  createdAt?: string;
  updatedAt?: string;
}

export interface Order {
  id?: string;
  userId: string;
  status?: string;
  totalAmount?: number;
  addressId?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Stocktaking {
  id: string;
  userId?: string;
  warehouse?: string;
  productName?: string;
  expectedQty?: number;
  actualQty?: number;
  diff?: number;
  stocktakenAt?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Suppliers {
  id: string;
  userId?: string;
  name: string;
  contact?: string;
  phone?: string;
  email?: string;
  address?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface StockAlerts {
  id: string;
  userId?: string;
  productName: string;
  currentQty?: number;
  threshold?: number;
  alertedAt?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface CreateUserInput {
  username: string;
  passwordHash: string;
  nickname?: string;
  role?: string;
  phone?: string;
  avatarUrl?: string;
}

export interface CreateProductInput {
  userId: string;
  title: string;
  description?: string;
  price?: number;
  stock?: number;
  images?: Record<string, unknown>;
}

export interface CreateOrderInput {
  userId: string;
  status?: string;
  totalAmount?: number;
  addressId?: string;
}

export interface CreateStocktakingInput {
  userId?: string;
  warehouse?: string;
  productName?: string;
  expectedQty?: number;
  actualQty?: number;
  diff?: number;
}

export interface CreateSuppliersInput {
  userId?: string;
  name: string;
  contact?: string;
  phone?: string;
  email?: string;
  address?: string;
}

export interface CreateStockAlertsInput {
  userId?: string;
  productName: string;
  currentQty?: number;
  threshold?: number;
}

export interface UpdateUserInput {
  username?: string;
  passwordHash?: string;
  nickname?: string;
  role?: string;
  phone?: string;
  avatarUrl?: string;
}

export interface UpdateProductInput {
  userId?: string;
  title?: string;
  description?: string;
  price?: number;
  stock?: number;
  images?: Record<string, unknown>;
}

export interface UpdateOrderInput {
  userId?: string;
  status?: string;
  totalAmount?: number;
  addressId?: string;
}

export interface UpdateStocktakingInput {
  userId?: string;
  warehouse?: string;
  productName?: string;
  expectedQty?: number;
  actualQty?: number;
  diff?: number;
}

export interface UpdateSuppliersInput {
  userId?: string;
  name?: string;
  contact?: string;
  phone?: string;
  email?: string;
  address?: string;
}

export interface UpdateStockAlertsInput {
  userId?: string;
  productName?: string;
  currentQty?: number;
  threshold?: number;
}

// ─── Auth ───────────────────────────────────────────
export interface LoginInput {
  username: string;
  password: string;
}

export interface RegisterInput {
  username: string;
  password: string;
  nickname?: string;
}

export interface AuthResponse {
  token: string;
  user: User;
}

// ─── API ────────────────────────────────────────────
export interface ApiResponse<T> {
  data: T;
  message?: string;
}

export interface PaginatedResponse<T> {
  data: T[];
  total: number;
  page: number;
  pageSize: number;
}

export interface ErrorResponse {
  error: string;
  message: string;
  statusCode: number;
}

// ─── JWT ────────────────────────────────────────────
export interface JwtPayload {
  userId: string;
  username: string;
  role: string;
  iat?: number;
  exp?: number;
}
