mirror of https://github.com/buster-so/buster.git
remove some unused types
This commit is contained in:
parent
05194b004c
commit
5874bfeef6
|
@ -1,11 +1,6 @@
|
|||
import { mainApi } from '../instances';
|
||||
import { serverFetch } from '../../createServerInstance';
|
||||
import type { BusterChatListItem, BusterChat } from '@/api/asset_interfaces/chat';
|
||||
import type {
|
||||
DuplicateChatParams,
|
||||
GetChatParams,
|
||||
UpdateChatParams
|
||||
} from '../../request_interfaces/chats';
|
||||
|
||||
const CHATS_BASE = '/chats';
|
||||
|
||||
|
@ -44,16 +39,24 @@ export const getListChats_server = async (
|
|||
};
|
||||
|
||||
// Client-side fetch version
|
||||
export const getChat = async ({ id }: GetChatParams): Promise<BusterChat> => {
|
||||
export const getChat = async ({ id }: { id: string }): Promise<BusterChat> => {
|
||||
return mainApi.get<BusterChat>(`${CHATS_BASE}/${id}`).then((res) => res.data);
|
||||
};
|
||||
|
||||
// Server-side fetch version
|
||||
export const getChat_server = async ({ id }: GetChatParams): Promise<BusterChat> => {
|
||||
export const getChat_server = async ({ id }: { id: string }): Promise<BusterChat> => {
|
||||
return await serverFetch<BusterChat>(`${CHATS_BASE}/${id}`);
|
||||
};
|
||||
|
||||
export const updateChat = async ({ id, ...data }: UpdateChatParams): Promise<BusterChat> => {
|
||||
export const updateChat = async ({
|
||||
id,
|
||||
...data
|
||||
}: {
|
||||
id: string;
|
||||
title?: string;
|
||||
is_favorited?: boolean;
|
||||
feedback?: 'negative' | null;
|
||||
}): Promise<BusterChat> => {
|
||||
return mainApi.put<BusterChat>(`${CHATS_BASE}/${id}`, data).then((res) => res.data);
|
||||
};
|
||||
|
||||
|
@ -65,7 +68,12 @@ export const duplicateChat = async ({
|
|||
id,
|
||||
message_id,
|
||||
share_with_same_people
|
||||
}: DuplicateChatParams): Promise<BusterChat> => {
|
||||
}: {
|
||||
id: string;
|
||||
/** The message ID to start the duplication from */
|
||||
message_id: string;
|
||||
share_with_same_people: boolean;
|
||||
}): Promise<BusterChat> => {
|
||||
return mainApi
|
||||
.post(`${CHATS_BASE}/duplicate`, { id, message_id, share_with_same_people })
|
||||
.then((res) => res.data);
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
import type {
|
||||
CreateNewChatParams,
|
||||
StopChatParams,
|
||||
UnsubscribeFromChatParams,
|
||||
DuplicateChatParams
|
||||
} from '../../request_interfaces/chats';
|
||||
import type { CreateNewChatParams, StopChatParams } from '../../request_interfaces/chats';
|
||||
import type { BusterSocketRequestBase } from '../base_interfaces';
|
||||
|
||||
/**
|
||||
|
@ -20,28 +15,7 @@ export type ChatCreateNewChat = BusterSocketRequestBase<'/chats/post', CreateNew
|
|||
*/
|
||||
export type ChatStopChat = BusterSocketRequestBase<'/chats/stop', StopChatParams>;
|
||||
|
||||
/**
|
||||
* Request type for unsubscribing from real-time updates of a specific chat.
|
||||
* @interface ChatUnsubscribeFromChat
|
||||
* @extends BusterSocketRequestBase
|
||||
*/
|
||||
export type ChatUnsubscribeFromChat = BusterSocketRequestBase<
|
||||
'/chats/unsubscribe',
|
||||
UnsubscribeFromChatParams
|
||||
>;
|
||||
|
||||
/**
|
||||
* Request type for duplicating an existing chat.
|
||||
* @interface ChatsDuplicateChat
|
||||
* @extends BusterSocketRequestBase
|
||||
*/
|
||||
export type ChatsDuplicateChat = BusterSocketRequestBase<'/chats/duplicate', DuplicateChatParams>;
|
||||
|
||||
/**
|
||||
* Union type of all possible chat-related request types.
|
||||
*/
|
||||
export type ChatEmits =
|
||||
| ChatCreateNewChat
|
||||
| ChatUnsubscribeFromChat
|
||||
| ChatsDuplicateChat
|
||||
| ChatStopChat;
|
||||
export type ChatEmits = ChatCreateNewChat | ChatStopChat;
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
} from './eventInterfaces';
|
||||
|
||||
export enum ChatsResponses {
|
||||
'/chats/unsubscribe:unsubscribe' = '/chats/unsubscribe:unsubscribe',
|
||||
'/chats/get:getChat' = '/chats/get:getChat',
|
||||
'/chats/post:initializeChat' = '/chats/post:initializeChat',
|
||||
'/chats/post:generatingTitle' = '/chats/post:generatingTitle',
|
||||
|
@ -29,12 +28,6 @@ export type Chat_getChat = {
|
|||
onError?: (error: RustApiError) => void;
|
||||
};
|
||||
|
||||
export type Chat_unsubscribe = {
|
||||
route: '/chats/unsubscribe:unsubscribe';
|
||||
callback: (d: { id: string }[]) => void;
|
||||
onError?: (d: unknown | RustApiError) => void;
|
||||
};
|
||||
|
||||
/***** CHAT PROGRESS EVENTS START ******/
|
||||
|
||||
export type ChatPost_initializeChat = {
|
||||
|
@ -70,7 +63,6 @@ export type ChatPost_complete = {
|
|||
/***** CHAT PROGRESS EVENTS END ******/
|
||||
|
||||
export type ChatResponseTypes =
|
||||
| Chat_unsubscribe
|
||||
| Chat_getChat
|
||||
| ChatPost_initializeChat
|
||||
| ChatPost_generatingTitle
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
export interface GetChatParams {
|
||||
/** The unique identifier of the chat to retrieve */
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface CreateNewChatParams {
|
||||
/** The ID of the dataset to associate with the chat. Null if no dataset is associated */
|
||||
dataset_id?: string | null;
|
||||
|
@ -26,45 +21,3 @@ export interface StopChatParams {
|
|||
/** The ID of the specific message to stop generating */
|
||||
message_id: string;
|
||||
}
|
||||
|
||||
export interface UnsubscribeFromChatParams {
|
||||
/** The unique identifier of the chat to unsubscribe from */
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface DeleteChatParams {
|
||||
/** The unique identifier of the chat to delete */
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface UpdateChatParams {
|
||||
/** The unique identifier of the chat to update */
|
||||
id: string;
|
||||
/** Optional new title to set for the chat */
|
||||
title?: string;
|
||||
/** Optional flag to set the chat's favorite status */
|
||||
is_favorited?: boolean;
|
||||
/** Optional feedback to set for the chat */
|
||||
feedback?: 'negative' | null;
|
||||
}
|
||||
|
||||
export interface ChatsSearchParams {
|
||||
/** The search query string to match against chats */
|
||||
prompt: string;
|
||||
}
|
||||
|
||||
export interface DuplicateChatParams {
|
||||
/** The unique identifier of the source chat to duplicate */
|
||||
id: string;
|
||||
/** The message ID to start the duplication from */
|
||||
message_id: string;
|
||||
/** Whether to share the duplicated chat with the same people as the source chat */
|
||||
share_with_same_people: boolean;
|
||||
}
|
||||
|
||||
export interface DuplicateChatResponse {
|
||||
/** The unique identifier of the duplicated chat */
|
||||
id: string;
|
||||
/** The title of the duplicated chat */
|
||||
title: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue