21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
|
|
import { apiRequest, type ApiSession } from './client'
|
||
|
|
|
||
|
|
export type SearchResultDTO = {
|
||
|
|
type: 'project' | 'task' | 'note' | 'source' | 'inbox' | 'ai_session'
|
||
|
|
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 })
|
||
|
|
}
|