// Import and re-export shared entity types
import type {
  User,
  Contract,
  Approval,
  Customer,
  Reminder,
  Boards,
  Tasks,
  Items,
  ApiResponse,
  PaginatedResponse,
  ErrorResponse,
} from "@shared/types";

export type {
  User,
  Contract,
  Approval,
  Customer,
  Reminder,
  Boards,
  Tasks,
  Items,
  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 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 CreateBoardsInput {
  userId?: string;
  name: string;
  description?: string;
  color?: string;
}

export interface CreateTasksInput {
  userId?: string;
  boardId?: string;
  title: string;
  description?: string;
  dueDate?: string;
  assigneeId?: string;
}

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

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 UpdateBoardsInput {
  userId?: string;
  name?: string;
  description?: string;
  color?: string;
}

export interface UpdateTasksInput {
  userId?: string;
  boardId?: string;
  title?: string;
  description?: string;
  dueDate?: string;
  assigneeId?: string;
}

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

// ─── 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;
}
