2026-07-21 16:29:42 +08:00
|
|
|
import { apiRequest, type ApiSession } from './client'
|
|
|
|
|
|
|
|
|
|
export type SearchResultDTO = {
|
2026-07-21 16:44:16 +08:00
|
|
|
type: 'project' | 'task' | 'note'
|
2026-07-21 16:29:42 +08:00
|
|
|
id: string
|
|
|
|
|
projectId: string
|
|
|
|
|
title: string
|
|
|
|
|
snippet: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type SearchResponseDTO = {
|
|
|
|
|
items: SearchResultDTO[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const searchPath = '/api/v1/search'
|
|
|
|
|
|
|
|
|
|
export async function searchWorkspace(session: ApiSession, query: string) {
|
|
|
|
|
const search = new URLSearchParams({ q: query })
|
|
|
|
|
return apiRequest<SearchResponseDTO>(`${searchPath}?${search.toString()}`, { token: session.token })
|
|
|
|
|
}
|