mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +02:00
feat(search-spaces): add updateSearchSpace endpoint to API service
This commit is contained in:
parent
646065d745
commit
80357d450b
1 changed files with 21 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ import {
|
|||
type CreateSearchSpaceRequest,
|
||||
type GetSearchSpaceRequest,
|
||||
type GetSearchSpacesRequest,
|
||||
type UpdateSearchSpaceRequest,
|
||||
createSearchSpaceRequest,
|
||||
createSearchSpaceResponse,
|
||||
getCommunityPromptsResponse,
|
||||
|
|
@ -9,6 +10,8 @@ import {
|
|||
getSearchSpaceResponse,
|
||||
getSearchSpacesRequest,
|
||||
getSearchSpacesResponse,
|
||||
updateSearchSpaceRequest,
|
||||
updateSearchSpaceResponse,
|
||||
} from "@/contracts/types/search-space.types";
|
||||
import { ValidationError } from "../error";
|
||||
import { baseApiService } from "./base-api.service";
|
||||
|
|
@ -83,6 +86,24 @@ class SearchSpacesApiService {
|
|||
|
||||
return baseApiService.get(`/api/v1/searchspaces/${request.id}`, getSearchSpaceResponse);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update an existing search space
|
||||
*/
|
||||
updateSearchSpace = async (request: UpdateSearchSpaceRequest) => {
|
||||
const parsedRequest = updateSearchSpaceRequest.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.put(`/api/v1/searchspaces/${request.id}`, updateSearchSpaceResponse, {
|
||||
body: parsedRequest.data.data,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const searchSpacesApiService = new SearchSpacesApiService();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue