import type { Fetcher } from 'swr' import { del, get, patch, post, put } from './base' import type { AccountIntegrate, CommonResponse, DataSourceNotion, IWorkspace, LangGeniusVersionResponse, Member, OauthResponse, PluginProvider, Provider, ProviderAnthropicToken, ProviderAzureToken, TenantInfoResponse, UserProfileOriginResponse, } from '@/models/common' import type { UpdateOpenAIKeyResponse, ValidateOpenAIKeyResponse, } 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 } export const fetchDataSource: Fetcher<{ data: DataSourceNotion[] }, { url: string }> = ({ url }) => { return get(url) as Promise<{ data: DataSourceNotion[] }> } export const syncDataSourceNotion: Fetcher = ({ url }) => { return get(url) as Promise } export const updateDataSourceNotionAction: Fetcher = ({ url }) => { return patch(url) as Promise } export const fetchPluginProviders: Fetcher = (url) => { return get(url) as Promise } export const validatePluginProviderKey: Fetcher = ({ url, body }) => { return post(url, { body }) as Promise } export const updatePluginProviderAIKey: Fetcher = ({ url, body }) => { return post(url, { body }) as Promise } export const invitationCheck: Fetcher = ({ url, params }) => { return get(url, { params }) as Promise } export const activateMember: Fetcher = ({ url, body }) => { return post(url, { body }) as Promise }