mirror of
https://github.com/docmost/docmost.git
synced 2026-05-16 05:44:04 +08:00
78b1c1a453
* add cursor pagination function * support custom order modifier * refactor returned object * feat(db): migrate paginated endpoints to cursor-based pagination * sync * support hasPrevPage boolean * feat(client): migrate pagination from offset to cursor-based * support beforeCursor/prevCursor * wrap search results in items array for API consistency
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import {
|
|
IAttachmentSearch,
|
|
IPageSearch,
|
|
IPageSearchParams,
|
|
ISuggestionResult,
|
|
SearchSuggestionParams,
|
|
} from '@/features/search/types/search.types';
|
|
|
|
export async function searchPage(
|
|
params: IPageSearchParams,
|
|
): Promise<IPageSearch[]> {
|
|
const req = await api.post<{ items: IPageSearch[] }>("/search", params);
|
|
return req.data.items;
|
|
}
|
|
|
|
export async function searchSuggestions(
|
|
params: SearchSuggestionParams,
|
|
): Promise<ISuggestionResult> {
|
|
const req = await api.post<ISuggestionResult>("/search/suggest", params);
|
|
return req.data;
|
|
}
|
|
|
|
export async function searchShare(
|
|
params: IPageSearchParams,
|
|
): Promise<IPageSearch[]> {
|
|
const req = await api.post<{ items: IPageSearch[] }>("/search/share-search", params);
|
|
return req.data.items;
|
|
}
|
|
|
|
export async function searchAttachments(
|
|
params: IPageSearchParams,
|
|
): Promise<IAttachmentSearch[]> {
|
|
const req = await api.post<{ items: IAttachmentSearch[] }>("/search-attachments", params);
|
|
return req.data.items;
|
|
}
|