feat: add search space snapshots frontend API

This commit is contained in:
CREDO23 2026-02-02 15:43:07 +02:00
parent ab343b544a
commit 47b7befc55
2 changed files with 50 additions and 0 deletions

View file

@ -44,6 +44,30 @@ export const deleteSnapshotRequest = z.object({
snapshot_id: z.number(),
});
/**
* Search space snapshot info (includes thread context)
*/
export const searchSpaceSnapshotInfo = z.object({
id: z.number(),
share_token: z.string(),
public_url: z.string(),
created_at: z.string(),
message_count: z.number(),
thread_id: z.number(),
thread_title: z.string(),
});
/**
* List snapshots for search space
*/
export const listSearchSpaceSnapshotsRequest = z.object({
search_space_id: z.number(),
});
export const listSearchSpaceSnapshotsResponse = z.object({
snapshots: z.array(searchSpaceSnapshotInfo),
});
// Type exports
export type SnapshotInfo = z.infer<typeof snapshotInfo>;
export type CreateSnapshotRequest = z.infer<typeof createSnapshotRequest>;
@ -51,3 +75,6 @@ export type CreateSnapshotResponse = z.infer<typeof createSnapshotResponse>;
export type ListSnapshotsRequest = z.infer<typeof listSnapshotsRequest>;
export type ListSnapshotsResponse = z.infer<typeof listSnapshotsResponse>;
export type DeleteSnapshotRequest = z.infer<typeof deleteSnapshotRequest>;
export type SearchSpaceSnapshotInfo = z.infer<typeof searchSpaceSnapshotInfo>;
export type ListSearchSpaceSnapshotsRequest = z.infer<typeof listSearchSpaceSnapshotsRequest>;
export type ListSearchSpaceSnapshotsResponse = z.infer<typeof listSearchSpaceSnapshotsResponse>;

View file

@ -5,8 +5,12 @@ import {
createSnapshotResponse,
type DeleteSnapshotRequest,
deleteSnapshotRequest,
type ListSearchSpaceSnapshotsRequest,
type ListSearchSpaceSnapshotsResponse,
type ListSnapshotsRequest,
type ListSnapshotsResponse,
listSearchSpaceSnapshotsRequest,
listSearchSpaceSnapshotsResponse,
listSnapshotsRequest,
listSnapshotsResponse,
} from "@/contracts/types/chat-threads.types";
@ -63,6 +67,25 @@ class ChatThreadsApiService {
`/api/v1/threads/${parsed.data.thread_id}/snapshots/${parsed.data.snapshot_id}`
);
};
/**
* List all snapshots for a search space.
*/
listSearchSpaceSnapshots = async (
request: ListSearchSpaceSnapshotsRequest
): Promise<ListSearchSpaceSnapshotsResponse> => {
const parsed = listSearchSpaceSnapshotsRequest.safeParse(request);
if (!parsed.success) {
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.get(
`/api/v1/searchspaces/${parsed.data.search_space_id}/snapshots`,
listSearchSpaceSnapshotsResponse
);
};
}
export const chatThreadsApiService = new ChatThreadsApiService();