mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
refactor: rename snapshot types to PublicChatSnapshot prefix
This commit is contained in:
parent
e62e4faaa5
commit
d890c562d4
9 changed files with 95 additions and 91 deletions
|
|
@ -1,28 +1,30 @@
|
|||
import {
|
||||
type CreateSnapshotRequest,
|
||||
type CreateSnapshotResponse,
|
||||
createSnapshotRequest,
|
||||
createSnapshotResponse,
|
||||
type DeleteSnapshotRequest,
|
||||
deleteSnapshotRequest,
|
||||
type ListSearchSpaceSnapshotsRequest,
|
||||
type ListSearchSpaceSnapshotsResponse,
|
||||
type ListSnapshotsRequest,
|
||||
type ListSnapshotsResponse,
|
||||
listSearchSpaceSnapshotsRequest,
|
||||
listSearchSpaceSnapshotsResponse,
|
||||
listSnapshotsRequest,
|
||||
listSnapshotsResponse,
|
||||
type PublicChatSnapshotCreateRequest,
|
||||
type PublicChatSnapshotCreateResponse,
|
||||
type PublicChatSnapshotDeleteRequest,
|
||||
type PublicChatSnapshotListRequest,
|
||||
type PublicChatSnapshotListResponse,
|
||||
type PublicChatSnapshotsBySpaceRequest,
|
||||
type PublicChatSnapshotsBySpaceResponse,
|
||||
publicChatSnapshotCreateRequest,
|
||||
publicChatSnapshotCreateResponse,
|
||||
publicChatSnapshotDeleteRequest,
|
||||
publicChatSnapshotListRequest,
|
||||
publicChatSnapshotListResponse,
|
||||
publicChatSnapshotsBySpaceRequest,
|
||||
publicChatSnapshotsBySpaceResponse,
|
||||
} from "@/contracts/types/chat-threads.types";
|
||||
import { ValidationError } from "../error";
|
||||
import { baseApiService } from "./base-api.service";
|
||||
|
||||
class ChatThreadsApiService {
|
||||
/**
|
||||
* Create a public snapshot for a thread.
|
||||
* Create a public chat snapshot for a thread.
|
||||
*/
|
||||
createSnapshot = async (request: CreateSnapshotRequest): Promise<CreateSnapshotResponse> => {
|
||||
const parsed = createSnapshotRequest.safeParse(request);
|
||||
createPublicChatSnapshot = async (
|
||||
request: PublicChatSnapshotCreateRequest
|
||||
): Promise<PublicChatSnapshotCreateResponse> => {
|
||||
const parsed = publicChatSnapshotCreateRequest.safeParse(request);
|
||||
|
||||
if (!parsed.success) {
|
||||
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
|
||||
|
|
@ -31,15 +33,17 @@ class ChatThreadsApiService {
|
|||
|
||||
return baseApiService.post(
|
||||
`/api/v1/threads/${parsed.data.thread_id}/snapshots`,
|
||||
createSnapshotResponse
|
||||
publicChatSnapshotCreateResponse
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* List all snapshots for a thread.
|
||||
* List all public chat snapshots for a thread.
|
||||
*/
|
||||
listSnapshots = async (request: ListSnapshotsRequest): Promise<ListSnapshotsResponse> => {
|
||||
const parsed = listSnapshotsRequest.safeParse(request);
|
||||
listPublicChatSnapshots = async (
|
||||
request: PublicChatSnapshotListRequest
|
||||
): Promise<PublicChatSnapshotListResponse> => {
|
||||
const parsed = publicChatSnapshotListRequest.safeParse(request);
|
||||
|
||||
if (!parsed.success) {
|
||||
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
|
||||
|
|
@ -48,15 +52,15 @@ class ChatThreadsApiService {
|
|||
|
||||
return baseApiService.get(
|
||||
`/api/v1/threads/${parsed.data.thread_id}/snapshots`,
|
||||
listSnapshotsResponse
|
||||
publicChatSnapshotListResponse
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a specific snapshot.
|
||||
* Delete a public chat snapshot.
|
||||
*/
|
||||
deleteSnapshot = async (request: DeleteSnapshotRequest): Promise<void> => {
|
||||
const parsed = deleteSnapshotRequest.safeParse(request);
|
||||
deletePublicChatSnapshot = async (request: PublicChatSnapshotDeleteRequest): Promise<void> => {
|
||||
const parsed = publicChatSnapshotDeleteRequest.safeParse(request);
|
||||
|
||||
if (!parsed.success) {
|
||||
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
|
||||
|
|
@ -69,12 +73,12 @@ class ChatThreadsApiService {
|
|||
};
|
||||
|
||||
/**
|
||||
* List all snapshots for a search space.
|
||||
* List all public chat snapshots for a search space.
|
||||
*/
|
||||
listSearchSpaceSnapshots = async (
|
||||
request: ListSearchSpaceSnapshotsRequest
|
||||
): Promise<ListSearchSpaceSnapshotsResponse> => {
|
||||
const parsed = listSearchSpaceSnapshotsRequest.safeParse(request);
|
||||
listPublicChatSnapshotsForSearchSpace = async (
|
||||
request: PublicChatSnapshotsBySpaceRequest
|
||||
): Promise<PublicChatSnapshotsBySpaceResponse> => {
|
||||
const parsed = publicChatSnapshotsBySpaceRequest.safeParse(request);
|
||||
|
||||
if (!parsed.success) {
|
||||
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
|
||||
|
|
@ -83,7 +87,7 @@ class ChatThreadsApiService {
|
|||
|
||||
return baseApiService.get(
|
||||
`/api/v1/searchspaces/${parsed.data.search_space_id}/snapshots`,
|
||||
listSearchSpaceSnapshotsResponse
|
||||
publicChatSnapshotsBySpaceResponse
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue