// 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 Contract {
  id?: string;
  userId: string;
  title: string;
  partyA?: string;
  partyB?: string;
  amount?: number;
  signedAt?: string;
  expiresAt?: string;
  status?: string;
  fileUrl?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Approval {
  id?: string;
  userId: string;
  entityType: string;
  entityId?: string;
  applicantId: string;
  status?: string;
  formData?: Record<string, unknown>;
  createdAt?: string;
  updatedAt?: string;
}

export interface Customer {
  id?: string;
  userId: string;
  name: string;
  email?: string;
  phone?: string;
  company?: string;
  source?: string;
  tags?: Record<string, unknown>;
  createdAt?: string;
  updatedAt?: string;
}

export interface Reminder {
  id?: string;
  userId: string;
  entityType: string;
  entityId?: string;
  remindAt: string;
  message?: string;
  sent?: boolean;
  createdAt?: string;
  updatedAt?: string;
}

export interface Assets {
  id: string;
  userId?: string;
  name: string;
  category?: string;
  purchaseDate?: string;
  purchasePrice?: number;
  currentValue?: number;
  location?: string;
  status?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Items {
  id: string;
  userId?: string;
  title: string;
  description?: string;
  status?: string;
  data?: Record<string, unknown>;
  createdAt?: string;
  updatedAt?: string;
}

export interface Stats {
  id: string;
  userId?: string;
  metric: string;
  value?: number;
  period?: string;
  recordedAt?: string;
  createdAt?: string;
  updatedAt?: string;
}

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

export interface CreateContractInput {
  userId: string;
  title: string;
  partyA?: string;
  partyB?: string;
  amount?: number;
  signedAt?: string;
  expiresAt?: string;
  status?: string;
  fileUrl?: string;
}

export interface CreateApprovalInput {
  userId: string;
  entityType: string;
  entityId?: string;
  applicantId: string;
  status?: string;
  formData?: Record<string, unknown>;
}

export interface CreateCustomerInput {
  userId: string;
  name: string;
  email?: string;
  phone?: string;
  company?: string;
  source?: string;
  tags?: Record<string, unknown>;
}

export interface CreateReminderInput {
  userId: string;
  entityType: string;
  entityId?: string;
  remindAt: string;
  message?: string;
  sent?: boolean;
}

export interface CreateAssetsInput {
  userId?: string;
  name: string;
  category?: string;
  purchaseDate?: string;
  purchasePrice?: number;
  currentValue?: number;
  location?: string;
}

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

export interface CreateStatsInput {
  userId?: string;
  metric: string;
  value?: number;
  period?: string;
}

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

export interface UpdateContractInput {
  userId?: string;
  title?: string;
  partyA?: string;
  partyB?: string;
  amount?: number;
  signedAt?: string;
  expiresAt?: string;
  status?: string;
  fileUrl?: string;
}

export interface UpdateApprovalInput {
  userId?: string;
  entityType?: string;
  entityId?: string;
  applicantId?: string;
  status?: string;
  formData?: Record<string, unknown>;
}

export interface UpdateCustomerInput {
  userId?: string;
  name?: string;
  email?: string;
  phone?: string;
  company?: string;
  source?: string;
  tags?: Record<string, unknown>;
}

export interface UpdateReminderInput {
  userId?: string;
  entityType?: string;
  entityId?: string;
  remindAt?: string;
  message?: string;
  sent?: boolean;
}

export interface UpdateAssetsInput {
  userId?: string;
  name?: string;
  category?: string;
  purchaseDate?: string;
  purchasePrice?: number;
  currentValue?: number;
  location?: string;
}

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

export interface UpdateStatsInput {
  userId?: string;
  metric?: string;
  value?: number;
  period?: 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 ────────────────────────────────────────────
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;
}
