Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Supabase updates #2100

Merged
merged 7 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/adapter-supabase/seed.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INSERT INTO public.accounts (id, name, email, avatarUrl, details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', '[email protected]', '', '{}');
INSERT INTO public.rooms (id) VALUES ('00000000-0000-0000-0000-000000000000');
INSERT INTO public.participants (userId, roomId) VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000');
INSERT INTO public.accounts (id, name, email, "avatarUrl", details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', '[email protected]', '', '{}');
INSERT INTO public.rooms (id, "createdAt") VALUES ('00000000-0000-0000-0000-000000000000', NOW());
INSERT INTO public.participants (id, "createdAt", "userId", "roomId", "userState", last_messsage_read) VALUES ('00000000-0000-0000-0000-000000000000', NOW(), 'Default Agent', '00000000-0000-0000-0000-000000000000', NULL, NULL);
30 changes: 15 additions & 15 deletions packages/adapter-supabase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.from("rooms")
.select("id")
.eq("id", roomId)
.single();
.maybeSingle();

if (error) {
throw new Error(`Error getting room: ${error.message}`);
elizaLogger.error(`Error getting room: ${error.message}`);
return null;
}

return data ? (data.id as UUID) : null;
}

Expand Down Expand Up @@ -56,7 +56,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.single();

if (error) {
console.error("Error getting participant user state:", error);
elizaLogger.error("Error getting participant user state:", error);
return null;
}

Expand All @@ -75,7 +75,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.eq("userId", userId);

if (error) {
console.error("Error setting participant user state:", error);
elizaLogger.error("Error setting participant user state:", error);
throw new Error("Failed to set participant user state");
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
const { data, error } = await query;

if (error) {
console.error("Error retrieving memories by room IDs:", error);
elizaLogger.error("Error retrieving memories by room IDs:", error);
return [];
}

Expand Down Expand Up @@ -155,7 +155,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.from("accounts")
.upsert([account]);
if (error) {
console.error(error.message);
elizaLogger.error(error.message);
return false;
}
return true;
Expand All @@ -175,7 +175,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.eq("id", params.roomId);

if (response.error) {
console.error("Error!" + response.error);
elizaLogger.error("Error!" + response.error);
return [];
}
const { data } = response;
Expand All @@ -194,7 +194,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
)
.flat();
} catch (error) {
console.error("error", error);
elizaLogger.error("error", error);
throw error;
}
}
Expand Down Expand Up @@ -267,7 +267,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
});

if (error) {
console.error("Error inserting log:", error);
elizaLogger.error("Error inserting log:", error);
throw new Error(error.message);
}
}
Expand Down Expand Up @@ -357,7 +357,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.single();

if (error) {
console.error("Error retrieving memory by ID:", error);
elizaLogger.error("Error retrieving memory by ID:", error);
return null;
}

Expand Down Expand Up @@ -571,7 +571,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.insert({ userId: userId, roomId: roomId });

if (error) {
console.error(`Error adding participant: ${error.message}`);
elizaLogger.error(`Error adding participant: ${error.message}`);
return false;
}
return true;
Expand All @@ -585,7 +585,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.eq("roomId", roomId);

if (error) {
console.error(`Error removing participant: ${error.message}`);
elizaLogger.error(`Error removing participant: ${error.message}`);
return false;
}
return true;
Expand Down Expand Up @@ -695,7 +695,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
.single();

if (error) {
console.error('Error fetching cache:', error);
elizaLogger.error('Error fetching cache:', error);
return undefined;
}

Expand All @@ -717,7 +717,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
});

if (error) {
console.error('Error setting cache:', error);
elizaLogger.error('Error setting cache:', error);
return false;
}

Expand Down
Loading