import type { SyncResult } from "contentstack"

import type { Lang } from "@/constants/languages"

export type ChangeFrequency =
  | "always"
  | "hourly"
  | "daily"
  | "weekly"
  | "monthly"
  | "yearly"
  | "never"

export interface SitemapEntry {
  url: string
  lastModified: string
  changeFrequency: ChangeFrequency
  priority: number
  alternates: Partial<Record<Lang, string>>
}

export type SitemapData = SitemapEntry[]

export interface SyncItemData {
  uid: string
  locale: Lang
  url?: string
  updated_at: string
  web?: {
    seo_metadata?: {
      noindex?: boolean | null
      sitemap?: {
        change_frequency: SitemapEntry["changeFrequency"]
        priority: SitemapEntry["priority"]
      } | null
    }
  }
}
export interface SyncItem {
  type: string
  data: SyncItemData
}
export interface SyncResponse extends Omit<SyncResult, "items"> {
  items: SyncItem[]
}

export type SyncItemsByUid = {
  mainEntry: SyncItem
  alternates: SyncItem[]
}
