/**
 * Calendar module types — calendar-module.
 * Canonical domain types for calendar events, connections, and providers.
 */

export type CalendarSource =
  | 'manual'
  | 'task'
  | 'project'
  | 'google'
  | 'outlook'
  | 'calendly'
  | 'acuity'
  | 'mocal'

export type SyncStatus = 'local' | 'synced' | 'pending' | 'error'

export type CalendarProvider = 'google' | 'outlook'

export type SchedulingProvider = 'calendly' | 'acuity' | 'mocal'

export type PostBookingAction = 'event' | 'event_task' | 'event_ticket'

export interface CalendarEventObject {
  id: string
  tenantId: string
  createdBy: string
  title: string
  description: string | null
  startAt: string
  endAt: string
  allDay: boolean
  location: string | null
  source: CalendarSource
  taskId: string | null
  projectId: string | null
  customerId: string | null
  externalId: string | null
  externalCalendarId: string | null
  syncedAt: string | null
  syncStatus: SyncStatus
  /** true for events solely authored in an external provider (not editable in Zync) */
  readOnly: boolean
  createdAt: string
  updatedAt: string
}

export interface CalendarConnectionObject {
  id: string
  tenantId: string
  userId: string
  provider: CalendarProvider
  externalUserId: string
  selectedCalendarId: string | null
  syncEnabled: boolean
  lastSyncedAt: string | null
  createdAt: string
  // access_token / refresh_token intentionally omitted — never expose to client
}

export interface SchedulingConnectionObject {
  id: string
  tenantId: string
  provider: SchedulingProvider
  webhookUri: string | null
  settings: Record<string, unknown> | null
  createdAt: string
  // api_key intentionally omitted — never expose to client
}

export interface CalendarSourceFilters {
  tasks: boolean
  projects: boolean
  manual: boolean
  external: boolean
}
