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

/** 使用原始凭据测试连接 POST /api/ai/vector-store/connect_test_config */
export async function postConnectTestConfig(
  body: {
    engine_type: string
    connection_config: { addr: string; username: string; password: string }
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: { version: string }
    isAuthorized: boolean
  }>('/api/ai/vector-store/connect_test_config', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 测试已保存或环境变量存储的连接 POST /api/ai/vector-store/connect_test_id */
export async function postConnectTestId(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: { version: string }
    isAuthorized: boolean
  }>('/api/ai/vector-store/connect_test_id', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 创建向量存储 POST /api/ai/vector-store/create */
export async function postCreate(
  body: {
    name: string
    engine_type: string
    connection_config: { addr: string; username: string; password: string }
    index_config: { index_name: string; number_of_shards: number; number_of_replicas: number }
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      connection_config: { addr: string; version: string; username: string }
      creationTime: string
      creatorUserId: string
      engine_type: string
      id: string
      index_config: { number_of_shards: number; index_name: string; number_of_replicas: number }
      isDeleted: boolean
      name: string
      source: string
      updateTime: string
      userId: string
    }
    isAuthorized: boolean
  }>('/api/ai/vector-store/create', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 删除向量存储 POST /api/ai/vector-store/delete */
export async function postOpenApiDelete(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/vector-store/delete',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 获取详情 POST /api/ai/vector-store/info */
export async function postInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      connection_config: { addr: string; version: string; username: string }
      creationTime: string
      creatorUserId: string
      engine_type: string
      id: string
      index_config: { number_of_shards: number; index_name: string; number_of_replicas: number }
      isDeleted: boolean
      name: string
      source: string
      updateTime: string
      userId: string
    }
    isAuthorized: boolean
  }>('/api/ai/vector-store/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取分页列表 POST /api/ai/vector-store/pageList */
export async function postPageList(
  body: {
    keyword: string
    pageIndex: number
    pageSize: number
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      connection_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
      }[]
      display_name: string
      index_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
        max: number
        min: number
        enum?: string[]
      }[]
      type: string
    }[]
    isAuthorized: boolean
  }>('/api/ai/vector-store/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取向量选择列表 POST /api/ai/vector-store/selectList */
export async function postSelectList(
  body: {
    keyword?: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      connection_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
      }[]
      display_name: string
      index_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
        max: number
        min: number
        enum?: string[]
      }[]
      type: string
    }[]
    isAuthorized: boolean
  }>('/api/ai/vector-store/selectList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取支持的向量存储类型列表 POST /api/ai/vector-store/types */
export async function postTypes(body: {}, options?: { [key: string]: any }) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      connection_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
      }[]
      display_name: string
      index_fields: {
        default: string
        description: string
        immutable: boolean
        name: string
        required: boolean
        sensitive: boolean
        type: string
        max: number
        min: number
        enum?: string[]
      }[]
      type: string
    }[]
    isAuthorized: boolean
  }>('/api/ai/vector-store/types', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 更新向量存储  POST /api/ai/vector-store/update */
export async function postUpdate(
  body: {
    id: string
    name: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/vector-store/update',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}
