mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +02:00
feat: added shared chats
This commit is contained in:
parent
764dd05582
commit
f22d649239
22 changed files with 1881 additions and 506 deletions
|
|
@ -11,7 +11,7 @@ enum ResponseType {
|
|||
}
|
||||
|
||||
export type RequestOptions = {
|
||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
||||
headers?: Record<string, string>;
|
||||
contentType?: "application/json" | "application/x-www-form-urlencoded";
|
||||
signal?: AbortSignal;
|
||||
|
|
@ -273,6 +273,21 @@ class BaseApiService {
|
|||
});
|
||||
}
|
||||
|
||||
async patch<T>(
|
||||
url: string,
|
||||
responseSchema?: ZodType<T>,
|
||||
options?: Omit<RequestOptions, "method" | "responseType">
|
||||
) {
|
||||
return this.request(url, responseSchema, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
...options,
|
||||
responseType: ResponseType.JSON,
|
||||
});
|
||||
}
|
||||
|
||||
async getBlob(url: string, options?: Omit<RequestOptions, "method" | "responseType">) {
|
||||
return this.request(url, undefined, {
|
||||
...options,
|
||||
|
|
|
|||
|
|
@ -9,10 +9,17 @@ import { baseApiService } from "@/lib/apis/base-api.service";
|
|||
// Types matching backend schemas
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Chat visibility levels - matches backend ChatVisibility enum
|
||||
*/
|
||||
export type ChatVisibility = "PRIVATE" | "SEARCH_SPACE";
|
||||
|
||||
export interface ThreadRecord {
|
||||
id: number;
|
||||
title: string;
|
||||
archived: boolean;
|
||||
visibility: ChatVisibility;
|
||||
created_by_id: string | null;
|
||||
search_space_id: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
|
|
@ -35,6 +42,9 @@ export interface ThreadListItem {
|
|||
id: number;
|
||||
title: string;
|
||||
archived: boolean;
|
||||
visibility: ChatVisibility;
|
||||
created_by_id: string | null;
|
||||
is_own_thread: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
|
@ -127,6 +137,25 @@ export async function deleteThread(threadId: number): Promise<void> {
|
|||
await baseApiService.delete(`/api/v1/threads/${threadId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update thread visibility (share/unshare)
|
||||
*/
|
||||
export async function updateThreadVisibility(
|
||||
threadId: number,
|
||||
visibility: ChatVisibility
|
||||
): Promise<ThreadRecord> {
|
||||
return baseApiService.patch<ThreadRecord>(`/api/v1/threads/${threadId}/visibility`, undefined, {
|
||||
body: { visibility },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full thread details including visibility
|
||||
*/
|
||||
export async function getThreadFull(threadId: number): Promise<ThreadRecord> {
|
||||
return baseApiService.get<ThreadRecord>(`/api/v1/threads/${threadId}/full`);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Thread List Manager (for thread list sidebar)
|
||||
// =============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue