// Core domain types based on implementation.md architecture

export interface User {
  id: number;
  username: string;
  role: string;
  createdAt: string;
  lastLogin: string;
}

export interface Project {
  id: number;
  name: string;
  description: string;
  ccNetProjectName: string;
  status: string;
  createdAt: string;
  updatedAt: string;
}

export interface Build {
  id: number;
  projectId: number;
  buildNumber: string;
  status: BuildStatus;
  startTime: string;
  endTime: string;
  logPath: string;
  artifactPath: string;
}

export enum BuildStatus {
  Success = 'Success',
  Failure = 'Failure',
  InProgress = 'InProgress',
  Unknown = 'Unknown'
}

export interface BuildCommit {
  id: number;
  buildId: number;
  commitHash: string;
  comment: string;
  user: string;
  commitDate: string;
  fogBugzCaseId?: string;
  modifiedFiles: string[];
  releaseNote?: string;
}

export interface Package {
  id: number;
  title: string;
  version: string;
  description: string;
  projectId: number;
  sourceBuildId: number;
  status: PackageStatus;
  publishDate?: string;
  createdAt: string;
  updatedAt: string;
  project?: Project;
  sourceBuild?: Build;
  configuration?: PackageConfiguration;
}

export enum PackageStatus {
  Draft = 'Draft',
  Ready = 'Ready',
  Publishing = 'Publishing',
  Published = 'Published',
  Failed = 'Failed'
}

export interface PackageConfiguration {
  id: number;
  packageId: number;
  buildFolder: string;
  zipContents: boolean;
  deleteOldPublishedBuilds: boolean;
  releaseNoteTemplate: string;
  storageSettings: Record<string, any>;
  helpCenterSettings: Record<string, any>;
  createdAt: string;
  updatedAt: string;
}

export interface FogBugzCase {
  id: number;
  caseId: number;
  title: string;
  project: string;
  area: string;
  status: string;
  lastUpdated: string;
  isOpen: boolean;
  events?: FogBugzEvent[];
}

export interface FogBugzEvent {
  id: number;
  caseId: number;
  eventType: string;
  user: string;
  comment: string;
  statusString: string;
  eventDate: string;
  releaseNote?: string;
  zendeskNumber?: number;
}

export interface Publication {
  id: number;
  packageId: number;
  status: PublicationStatus;
  publishedAt?: string;
  releaseNotesPath?: string;
  publicationDetails: Record<string, any>;
  steps?: PublishingStep[];
  package?: Package;
}

export enum PublicationStatus {
  Queued = 'Queued',
  InProgress = 'InProgress',
  Completed = 'Completed',
  Failed = 'Failed',
  Cancelled = 'Cancelled'
}

export interface PublishingStep {
  id: number;
  publicationId: number;
  stepName: string;
  status: StepStatus;
  details?: string;
  startedAt?: string;
  completedAt?: string;
  progressPercent: number;
}

export enum StepStatus {
  Pending = 'Pending',
  InProgress = 'InProgress',
  Completed = 'Completed',
  Failed = 'Failed',
  Skipped = 'Skipped'
}

// API Response types
export interface ApiResponse<T> {
  data: T;
  success: boolean;
  message?: string;
  errors?: string[];
}

export interface PaginatedResponse<T> {
  data: T[];
  totalCount: number;
  pageSize: number;
  currentPage: number;
  totalPages: number;
}

// SignalR Hub types
export interface PublishingProgressUpdate {
  publicationId: number;
  stepName: string;
  progressPercent: number;
  status: StepStatus;
  details?: string;
  timestamp: string;
}

export interface BuildStatusUpdate {
  projectId: number;
  buildId: number;
  status: BuildStatus;
  buildNumber: string;
  timestamp: string;
}

// Form types
export interface CreatePackageRequest {
  title: string;
  version: string;
  description: string;
  projectId: number;
  sourceBuildId: number;
  configuration: {
    buildFolder: string;
    zipContents: boolean;
    deleteOldPublishedBuilds: boolean;
    releaseNoteTemplate: string;
    storageSettings: Record<string, any>;
    helpCenterSettings: Record<string, any>;
  };
}

export interface PublishPackageRequest {
  packageId: number;
  buildId: number;
}

// Filter and search types
export interface PackageFilter {
  projectId?: number;
  status?: PackageStatus;
  searchTerm?: string;
  dateFrom?: string;
  dateTo?: string;
}

export interface BuildFilter {
  projectId?: number;
  status?: BuildStatus;
  user?: string;
  searchTerm?: string;
  dateFrom?: string;
  dateTo?: string;
}