feat(supabase): add credentials handling for Supabase API keys and URL

This commit introduces the ability to fetch and store Supabase API keys and URL credentials when a project is selected. This enables the application to dynamically configure the Supabase connection environment variables, improving the integration with Supabase services. The changes include updates to the Supabase connection logic, new API endpoints, and modifications to the chat and prompt components to utilize the new credentials.
This commit is contained in:
KevIsDev
2025-03-20 11:17:27 +00:00
parent 02974089de
commit bc7e2c5821
11 changed files with 192 additions and 33 deletions

View File

@@ -169,6 +169,10 @@ export const ChatImpl = memo(
supabase: {
isConnected: supabaseConn.isConnected,
hasSelectedProject: !!selectedProject,
credentials: {
supabaseUrl: supabaseConn?.credentials?.supabaseUrl,
anonKey: supabaseConn?.credentials?.anonKey,
},
},
},
sendExtraMessageFields: true,

View File

@@ -21,11 +21,11 @@ export function SupabaseConnection() {
handleCreateProject,
updateToken,
isConnected,
fetchProjectApiKeys,
} = useSupabaseConnection();
const currentChatId = useStore(chatId);
// Add event listener for opening the connection dialog
useEffect(() => {
const handleOpenConnectionDialog = () => {
setIsDialogOpen(true);
@@ -38,7 +38,6 @@ export function SupabaseConnection() {
};
}, [setIsDialogOpen]);
// Load the selected project from localStorage when connected or chat changes
useEffect(() => {
if (isConnected && currentChatId) {
const savedProjectId = localStorage.getItem(`supabase-project-${currentChatId}`);
@@ -70,6 +69,12 @@ export function SupabaseConnection() {
}
}, [isConnected, supabaseConn.token]);
useEffect(() => {
if (isConnected && supabaseConn.selectedProjectId && supabaseConn.token) {
fetchProjectApiKeys(supabaseConn.selectedProjectId).catch(console.error);
}
}, [isConnected, supabaseConn.selectedProjectId, supabaseConn.token]);
return (
<div className="relative">
<div className="flex border border-bolt-elements-borderColor rounded-md overflow-hidden mr-2 text-sm">