# ===============================================
# SITES
# ===============================================

extend type Query {
  sites: [Site]

  siteById (
    id: UUID!
  ): Site

  siteByHostname (
    hostname: String!
    exact: Boolean!
  ): Site
}

extend type Mutation {
  createSite (
    hostname: String!
    title: String!
  ): SiteCreateResponse

  updateSite (
    id: UUID!
    patch: SiteUpdateInput!
  ): DefaultResponse

  uploadSiteLogo (
    id: UUID!
    image: Upload!
  ): DefaultResponse

  uploadSiteFavicon (
    id: UUID!
    image: Upload!
  ): DefaultResponse

  uploadSiteLoginBg (
    id: UUID!
    image: Upload!
  ): DefaultResponse

  deleteSite (
    id: UUID!
  ): DefaultResponse
}

# -----------------------------------------------
# TYPES
# -----------------------------------------------

type Site {
  id: UUID
  hostname: String
  isEnabled: Boolean
  title: String
  description: String
  company: String
  contentLicense: String
  footerExtra: String
  pageExtensions: String
  pageCasing: Boolean
  logoText: Boolean
  sitemap: Boolean
  robots: SiteRobots
  features: SiteFeatures
  discoverable: Boolean
  defaults: SiteDefaults
  uploads: SiteUploads
  locales: SiteLocales
  editors: SiteEditors
  theme: SiteTheme
}

type SiteRobots {
  index: Boolean
  follow: Boolean
}

type SiteFeatures {
  browse: Boolean
  ratings: Boolean
  ratingsMode: SitePageRatingMode
  comments: Boolean
  contributions: Boolean
  profile: Boolean
  reasonForChange: SiteReasonForChangeMode
  search: Boolean
}

type SiteDefaults {
  tocDepth: PageTocDepth
}

type SiteUploads {
  conflictBehavior: SiteUploadConflictBehavior
  normalizeFilename: Boolean
}

type SiteLocales {
  primary: String
  active: [LocalizationLocale]
}

type SiteEditors {
  asciidoc: SiteEditor
  markdown: SiteEditor
  wysiwyg: SiteEditor
}

type SiteEditor {
  isActive: Boolean
  config: JSON
}

type SiteTheme {
  dark: Boolean
  codeBlocksTheme: String
  colorPrimary: String
  colorSecondary: String
  colorAccent: String
  colorHeader: String
  colorSidebar: String
  injectCSS: String
  injectHead: String
  injectBody: String
  contentWidth: SiteThemeWidth
  sidebarPosition: SiteThemePosition
  tocPosition: SiteThemePosition
  showSharingMenu: Boolean
  showPrintBtn: Boolean
  baseFont: String
  contentFont: String
}

enum SiteThemeWidth {
  full
  centered
}

enum SiteThemePosition {
  off
  left
  right
}

enum SitePageRatingMode {
  off
  thumbs
  stars
}

enum SiteReasonForChangeMode {
  off
  optional
  required
}

enum SiteUploadConflictBehavior {
  overwrite
  reject
  new
}

type SiteCreateResponse {
  operation: Operation
  site: Site
}

input SiteUpdateInput {
  hostname: String
  isEnabled: Boolean
  title: String
  description: String
  company: String
  contentLicense: String
  footerExtra: String
  pageExtensions: String
  pageCasing: Boolean
  logoText: Boolean
  sitemap: Boolean
  robots: SiteRobotsInput
  features: SiteFeaturesInput
  discoverable: Boolean
  defaults: SiteDefaultsInput
  uploads: SiteUploadsInput
  editors: SiteEditorsInput
  theme: SiteThemeInput
}

input SiteRobotsInput {
  index: Boolean
  follow: Boolean
}

input SiteFeaturesInput {
  browse: Boolean
  ratings: Boolean
  ratingsMode: SitePageRatingMode
  comments: Boolean
  contributions: Boolean
  profile: Boolean
  reasonForChange: SiteReasonForChangeMode
  search: Boolean
}

input SiteDefaultsInput {
  tocDepth: PageTocDepthInput
}

input SiteThemeInput {
  dark: Boolean
  codeBlocksTheme: String
  colorPrimary: String
  colorSecondary: String
  colorAccent: String
  colorHeader: String
  colorSidebar: String
  injectCSS: String
  injectHead: String
  injectBody: String
  contentWidth: SiteThemeWidth
  sidebarPosition: SiteThemePosition
  tocPosition: SiteThemePosition
  showSharingMenu: Boolean
  showPrintBtn: Boolean
  baseFont: String
  contentFont: String
}

input SiteEditorsInput {
  asciidoc: SiteEditorInput
  markdown: SiteEditorInput
  wysiwyg: SiteEditorInput
}

input SiteEditorInput {
  isActive: Boolean
  config: JSON
}

input SiteUploadsInput {
  conflictBehavior: SiteUploadConflictBehavior
  normalizeFilename: Boolean
}
