refactor(web): consume api v1 contracts

This commit is contained in:
2026-07-21 16:29:42 +08:00
parent e91c57e220
commit fe0c4e312e
9 changed files with 332 additions and 165 deletions

View File

@@ -0,0 +1,20 @@
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 })
}