mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-22 13:51:39 +03:00
3da64c0b0e
Issue: https://github.com/StanGirard/quivr/issues/1571 Demo: https://github.com/StanGirard/quivr/assets/63923024/e7a6118e-29f8-44aa-af4b-0ea1b8013a33
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { useAxios } from "@/lib/hooks";
|
|
|
|
import {
|
|
addBrainSubscriptions,
|
|
createBrain,
|
|
deleteBrain,
|
|
getBrain,
|
|
getBrainDocuments,
|
|
getBrains,
|
|
getBrainUsers,
|
|
getDefaultBrain,
|
|
getPublicBrains,
|
|
setAsDefaultBrain,
|
|
Subscription,
|
|
updateBrain,
|
|
updateBrainAccess,
|
|
updateBrainSecrets,
|
|
} from "./brain";
|
|
import {
|
|
CreateBrainInput,
|
|
SubscriptionUpdatableProperties,
|
|
UpdateBrainInput,
|
|
} from "./types";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useBrainApi = () => {
|
|
const { axiosInstance } = useAxios();
|
|
|
|
return {
|
|
getBrainDocuments: async (brainId: string) =>
|
|
getBrainDocuments(brainId, axiosInstance),
|
|
createBrain: async (brain: CreateBrainInput) =>
|
|
createBrain(brain, axiosInstance),
|
|
deleteBrain: async (id: string) => deleteBrain(id, axiosInstance),
|
|
getDefaultBrain: async () => getDefaultBrain(axiosInstance),
|
|
getBrains: async () => getBrains(axiosInstance),
|
|
getBrain: async (id: string) => getBrain(id, axiosInstance),
|
|
addBrainSubscriptions: async (
|
|
brainId: string,
|
|
subscriptions: Subscription[]
|
|
) => addBrainSubscriptions(brainId, subscriptions, axiosInstance),
|
|
getBrainUsers: async (brainId: string) =>
|
|
getBrainUsers(brainId, axiosInstance),
|
|
updateBrainAccess: async (
|
|
brainId: string,
|
|
userEmail: string,
|
|
subscription: SubscriptionUpdatableProperties
|
|
) => updateBrainAccess(brainId, userEmail, subscription, axiosInstance),
|
|
setAsDefaultBrain: async (brainId: string) =>
|
|
setAsDefaultBrain(brainId, axiosInstance),
|
|
updateBrain: async (brainId: string, brain: UpdateBrainInput) =>
|
|
updateBrain(brainId, brain, axiosInstance),
|
|
getPublicBrains: async () => getPublicBrains(axiosInstance),
|
|
updateBrainSecrets: async (
|
|
brainId: string,
|
|
secrets: Record<string, string>
|
|
) => updateBrainSecrets(brainId, secrets, axiosInstance),
|
|
};
|
|
};
|