// @ts-ignore
/* eslint-disable */
import request from '@repo/api-client'

/** 获取图谱信息 POST /api/ai/wiki/graph */
export async function postWikiGraph(
  body: {
    knowledge_base_id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      edges: {
        creationTime: string
        creatorUserId: string
        id: string
        isDeleted: boolean
        knowledge_base_id: string
        source: string
        target: string
        updateTime: string
      }[]
      nodes: {
        creationTime: string
        creatorUserId: string
        id: string
        isDeleted: boolean
        knowledge_base_id: string
        linkCount: number
        page_type: string
        slug: string
        title: string
        updateTime: string
      }[]
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/graph', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取首页 POST /api/ai/wiki/index */
export async function postWikiIndex(
  body: {
    knowledge_base_id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      aliases: string[]
      chunk_refs: string[]
      content: string
      creationTime: string
      creatorUserId: string
      id: string
      in_links: string[]
      isDeleted: boolean
      knowledge_base_id: string
      out_links: string[]
      page_metadata: Record<string, any>
      page_type: string
      slug: string
      source_refs: string[]
      status: string
      summary: string
      title: string
      updateTime: string
      version: number
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/index', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取日志信息 POST /api/ai/wiki/log */
export async function postWikiLog(
  body: {
    knowledge_base_id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      aliases: string[]
      chunk_refs: string[]
      content: string
      creationTime: string
      creatorUserId: string
      id: string
      in_links: string[]
      isDeleted: boolean
      knowledge_base_id: string
      out_links: string[]
      page_metadata: Record<string, any>
      page_type: string
      slug: string
      source_refs: string[]
      status: string
      summary: string
      title: string
      updateTime: string
      version: number
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/log', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取页面信息 POST /api/ai/wiki/page */
export async function postWikiPage(
  body: {
    knowledge_base_id: string
    slug: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      aliases: string[]
      chunk_refs: string[]
      content: string
      creationTime: string
      creatorUserId: string
      id: string
      in_links: string[]
      isDeleted: boolean
      knowledge_base_id: string
      out_links: string[]
      page_metadata: Record<string, any>
      page_type: string
      slug: string
      source_refs: string[]
      status: string
      summary: string
      title: string
      updateTime: string
      version: number
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取wiki页面列表 POST /api/ai/wiki/pageList */
export async function postWikiPageList(
  body: {
    knowledge_base_id: string
    pageIndex: number
    pageSize: number
    keyword: string
    page_type: string
    slug: string
    status: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        aliases: string[]
        chunk_refs: string[]
        content: string
        creationTime: string
        creatorUserId: string
        id: string
        in_links: string[]
        isDeleted: boolean
        knowledge_base_id: string
        out_links: string[]
        page_metadata: Record<string, any>
        page_type: string
        slug: string
        source_refs: string[]
        status: string
        summary: string
        title: string
        updateTime: string
        version: number
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取状态 POST /api/ai/wiki/stats */
export async function postWikiStats(
  body: {
    knowledge_base_id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      is_active: boolean
      orphan_count: number
      pages_by_type: {
        concept: number
        entity: number
        index: number
        log: number
        summary: number
      }
      pending_issues: number
      pending_tasks: number
      recent_updates: {
        aliases: string[]
        chunk_refs: string[]
        content: string
        id: string
        in_links: string[]
        knowledge_base_id: string
        out_links: string[]
        page_type: string
        slug: string
        source_refs: string[]
        status: string
        summary: string
        title: string
        version: number
      }[]
      total_links: number
      total_pages: number
    }
    isAuthorized: boolean
  }>('/api/ai/wiki/stats', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}
