export type KbxRuntimeMode = 'normal' | 'degraded' | 'read-only' | 'offline'

export interface KbxRuntimeNotice {
  mode: KbxRuntimeMode
  title: string
  message?: string
  since?: string
  correlationId?: string
  retryAllowed?: boolean
}

export interface KbxDataFreshness {
  observedAt: string
  staleAfterSeconds?: number
  source?: string
}

export type KbxOperationStatus =
  | 'queued'
  | 'running'
  | 'completed'
  | 'partially-completed'
  | 'failed'
  | 'cancelled'

export interface KbxOperationRun {
  id: string
  type: string
  title: string
  sourceScreenId?: string
  status: KbxOperationStatus
  requestedAt: string
  startedAt?: string
  completedAt?: string
  processed?: number
  total?: number
  succeeded?: number
  failed?: number
  correlationId?: string
  resultMessage?: string
}

export type KbxNotificationSeverity = 'info' | 'success' | 'warning' | 'error'

export interface KbxUserNotification {
  id: string
  severity: KbxNotificationSeverity
  title: string
  message?: string
  createdAt: string
  readAt?: string
  screenId?: string
  entityType?: string
  entityId?: string
  action?: {
    id: string
    label: string
    route?: string
  }
}

export interface KbxConflictFieldChange {
  field: string
  label: string
  mine?: unknown
  latest?: unknown
}

export interface KbxConflictSnapshot {
  code: string
  title: string
  detail?: string
  entityId?: string
  requestedVersion?: number
  currentVersion?: number
  changes?: KbxConflictFieldChange[]
  correlationId?: string
}

export interface KbxDiagnosticReference {
  correlationId: string
  requestId?: string
  occurredAt: string
  screenId?: string
  screenVersion?: string
  appVersion?: string
}
