mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 18:36:23 +02:00
feat(search-spaces): add getSearchSpace endpoint to API service
This commit is contained in:
parent
1d6bfe1e29
commit
646065d745
1 changed files with 19 additions and 0 deletions
|
|
@ -1,9 +1,12 @@
|
|||
import {
|
||||
type CreateSearchSpaceRequest,
|
||||
type GetSearchSpaceRequest,
|
||||
type GetSearchSpacesRequest,
|
||||
createSearchSpaceRequest,
|
||||
createSearchSpaceResponse,
|
||||
getCommunityPromptsResponse,
|
||||
getSearchSpaceRequest,
|
||||
getSearchSpaceResponse,
|
||||
getSearchSpacesRequest,
|
||||
getSearchSpacesResponse,
|
||||
} from "@/contracts/types/search-space.types";
|
||||
|
|
@ -64,6 +67,22 @@ class SearchSpacesApiService {
|
|||
getCommunityPrompts = async () => {
|
||||
return baseApiService.get(`/api/v1/searchspaces/prompts/community`, getCommunityPromptsResponse);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a single search space by ID
|
||||
*/
|
||||
getSearchSpace = async (request: GetSearchSpaceRequest) => {
|
||||
const parsedRequest = getSearchSpaceRequest.safeParse(request);
|
||||
|
||||
if (!parsedRequest.success) {
|
||||
console.error("Invalid request:", parsedRequest.error);
|
||||
|
||||
const errorMessage = parsedRequest.error.errors.map((err) => err.message).join(", ");
|
||||
throw new ValidationError(`Invalid request: ${errorMessage}`);
|
||||
}
|
||||
|
||||
return baseApiService.get(`/api/v1/searchspaces/${request.id}`, getSearchSpaceResponse);
|
||||
};
|
||||
}
|
||||
|
||||
export const searchSpacesApiService = new SearchSpacesApiService();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue