import type { JsonApiResource } from "next-drupal"

// Drupal JSON:API resource types.

export interface DrupalNode extends JsonApiResource {
  title: string
  status: boolean
  created: string
  changed: string
  path: {
    alias: string
    pid: number
    langcode: string
  }
  body?: {
    value: string
    format: string
    processed: string
    summary: string
  }
  field_image?: DrupalMedia
  uid?: {
    id: string
    display_name: string
  }
  metatag?: DrupalMetatag[]
}

export interface DrupalMedia extends JsonApiResource {
  name: string
  field_media_image?: DrupalFile
}

export interface DrupalFile extends JsonApiResource {
  uri: {
    value: string
    url: string
  }
  resourceIdObjMeta?: {
    alt: string
    title: string
    width: number
    height: number
  }
}

export interface DrupalMetatag {
  tag: string
  attributes: Record<string, string>
}

export interface DrupalMenuLinkContent {
  id: string
  title: string
  url: string
  parent: string
  weight: number
  expanded: boolean
  enabled: boolean
  items?: DrupalMenuLinkContent[]
}

export interface DrupalServiceNode extends DrupalNode {
  /** Service type from Drupal (modelling, development, deployment, etc.). JSON:API exposes as field__service__type. */
  field__service__type?: string
}

export interface DrupalAboutNode extends DrupalNode {
  /** JSON:API resource type: node--about. */
  field_email?: string
}
