import type { Fetcher } from 'swr' import { get, post, del, put } from './base' import type { CommonResponse, LangGeniusVersionResponse, OauthResponse, TenantInfoResponse, UserProfileOriginResponse, Member, AccountIntegrate, Provider, ProviderAzureToken, IWorkspace } from '@/models/common' import type { ValidateOpenAIKeyResponse, UpdateOpenAIKeyResponse } from '@/models/app' export const login: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise } export const setup: Fetcher }> = ({ body }) => { return post('/setup', { body }) as Promise } export const fetchUserProfile: Fetcher }> = ({ url, params }) => { return get(url, params, { needAllResponseContent: true }) as Promise } export const updateUserProfile: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise } export const fetchTenantInfo: Fetcher = ({ url }) => { return get(url) as Promise } export const logout: Fetcher }> = ({ url, params }) => { return get(url, params) as Promise } export const fetchLanggeniusVersion: Fetcher }> = ({ url, params }) => { return get(url, { params }) as Promise } export const oauth: Fetcher }> = ({ url, params }) => { return get(url, { params }) as Promise } export const oneMoreStep: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise } export const fetchMembers: Fetcher<{ accounts: Member[] | null }, { url: string; params: Record }> = ({ url, params }) => { return get(url, { params }) as Promise<{ accounts: Member[] | null }> } export const fetchProviders: Fetcher }> = ({ url, params }) => { return get(url, { params }) as Promise } export const validateProviderKey: Fetcher = ({ url, body }) => { return post(url, { body }) as Promise } export const updateProviderAIKey: Fetcher = ({ url, body }) => { return post(url, { body }) as Promise } export const fetchAccountIntegrates: Fetcher<{ data: AccountIntegrate[] | null }, { url: string; params: Record }> = ({ url, params }) => { return get(url, { params }) as Promise<{ data: AccountIntegrate[] | null }> } export const inviteMember: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise } export const updateMemberRole: Fetcher }> = ({ url, body }) => { return put(url, { body }) as Promise } export const deleteMemberOrCancelInvitation: Fetcher = ({ url }) => { return del(url) as Promise } export const fetchFilePreview: Fetcher<{ content: string }, { fileID: string }> = ({ fileID }) => { return get(`/files/${fileID}/preview`) as Promise<{ content: string }> } export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: string; params: Record }> = ({ url, params }) => { return get(url, { params }) as Promise<{ workspaces: IWorkspace[] }> } export const switchWorkspace: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise }