mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
wrap search results in items array for API consistency
This commit is contained in:
@@ -10,8 +10,8 @@ import {
|
||||
export async function searchPage(
|
||||
params: IPageSearchParams,
|
||||
): Promise<IPageSearch[]> {
|
||||
const req = await api.post<IPageSearch[]>("/search", params);
|
||||
return req.data;
|
||||
const req = await api.post<{ items: IPageSearch[] }>("/search", params);
|
||||
return req.data.items;
|
||||
}
|
||||
|
||||
export async function searchSuggestions(
|
||||
@@ -24,13 +24,13 @@ export async function searchSuggestions(
|
||||
export async function searchShare(
|
||||
params: IPageSearchParams,
|
||||
): Promise<IPageSearch[]> {
|
||||
const req = await api.post<IPageSearch[]>("/search/share-search", params);
|
||||
return req.data;
|
||||
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<IAttachmentSearch[]>("/search-attachments", params);
|
||||
return req.data;
|
||||
const req = await api.post<{ items: IAttachmentSearch[] }>("/search-attachments", params);
|
||||
return req.data.items;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ export class SearchService {
|
||||
userId?: string;
|
||||
workspaceId: string;
|
||||
},
|
||||
): Promise<SearchResponseDto[]> {
|
||||
): Promise<{ items: SearchResponseDto[] }> {
|
||||
const { query } = searchParams;
|
||||
|
||||
if (query.length < 1) {
|
||||
return;
|
||||
return { items: [] };
|
||||
}
|
||||
const searchQuery = tsquery(query.trim() + '*');
|
||||
|
||||
@@ -62,7 +62,7 @@ export class SearchService {
|
||||
)
|
||||
.where('deletedAt', 'is', null)
|
||||
.orderBy('rank', 'desc')
|
||||
.limit(searchParams.limit | 25)
|
||||
.limit(searchParams.limit || 25)
|
||||
.offset(searchParams.offset || 0);
|
||||
|
||||
if (!searchParams.shareId) {
|
||||
@@ -86,7 +86,7 @@ export class SearchService {
|
||||
const shareId = searchParams.shareId;
|
||||
const share = await this.shareRepo.findById(shareId);
|
||||
if (!share || share.workspaceId !== opts.workspaceId) {
|
||||
return [];
|
||||
return { items: [] };
|
||||
}
|
||||
|
||||
const pageIdsToSearch = [];
|
||||
@@ -108,10 +108,10 @@ export class SearchService {
|
||||
.where('id', 'in', pageIdsToSearch)
|
||||
.where('workspaceId', '=', opts.workspaceId);
|
||||
} else {
|
||||
return [];
|
||||
return { items: [] };
|
||||
}
|
||||
} else {
|
||||
return [];
|
||||
return { items: [] };
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
@@ -127,7 +127,7 @@ export class SearchService {
|
||||
return result;
|
||||
});
|
||||
|
||||
return searchResults;
|
||||
return { items: searchResults };
|
||||
}
|
||||
|
||||
async searchSuggestions(
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: 9888832270...b363767b69
Reference in New Issue
Block a user