// Import and re-export shared entity types
import type {
  User,
  Items,
  StockIn,
  StockOut,
  Stocktaking,
  StockAlerts,
  Warehouse,
  ApiResponse,
  PaginatedResponse,
  ErrorResponse,
} from "@shared/types";

export type {
  User,
  Items,
  StockIn,
  StockOut,
  Stocktaking,
  StockAlerts,
  Warehouse,
  ApiResponse,
  PaginatedResponse,
  ErrorResponse,
};

// Auto-generated types (from Model Contract)

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

export interface CreateItemsInput {
  userId?: string;
  title: string;
  description?: string;
  data?: Record<string, unknown>;
}

export interface CreateStockInInput {
  userId?: string;
  productName: string;
  quantity: number;
  supplier?: string;
  receivedBy?: string;
}

export interface CreateStockOutInput {
  userId?: string;
  productName: string;
  quantity: number;
  recipient?: string;
  approvedBy?: string;
  shippedAt?: string;
}

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

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

export interface CreateWarehouseInput {
  userId?: string;
  productName: string;
  quantity: number;
  supplier?: string;
  receivedBy?: string;
}

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

export interface UpdateItemsInput {
  userId?: string;
  title?: string;
  description?: string;
  data?: Record<string, unknown>;
}

export interface UpdateStockInInput {
  userId?: string;
  productName?: string;
  quantity?: number;
  supplier?: string;
  receivedBy?: string;
}

export interface UpdateStockOutInput {
  userId?: string;
  productName?: string;
  quantity?: number;
  recipient?: string;
  approvedBy?: string;
  shippedAt?: string;
}

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

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

export interface UpdateWarehouseInput {
  userId?: string;
  productName?: string;
  quantity?: number;
  supplier?: string;
  receivedBy?: string;
}

// ─── 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 ────────────────────────────────────────────
// ─── JWT ────────────────────────────────────────────
export interface JwtPayload {
  userId: string;
  username: string;
  role: string;
  iat?: number;
  exp?: number;
}
