mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
feat(frontend): add client routes
This commit is contained in:
@@ -117,7 +117,7 @@ async def get_or_create_user_route(user_data: dict = Depends(auth_middleware)):
|
||||
"/auth/user/email", tags=["auth"], dependencies=[Depends(auth_middleware)]
|
||||
)
|
||||
async def update_user_email_route(
|
||||
user_id: Annotated[str, Depends(get_user_id)], email: str
|
||||
user_id: Annotated[str, Depends(get_user_id)], email: str = Body(...)
|
||||
) -> dict[str, str]:
|
||||
await update_user_email(user_id, email)
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ import {
|
||||
StoreReview,
|
||||
TransactionHistory,
|
||||
User,
|
||||
NotificationPreferenceDTO,
|
||||
UserPasswordCredentials,
|
||||
NotificationPreference,
|
||||
} from "./types";
|
||||
import { createBrowserClient } from "@supabase/ssr";
|
||||
import getServerSupabase from "../supabase/getServerSupabase";
|
||||
@@ -81,6 +83,10 @@ export default class BackendAPI {
|
||||
return this._request("POST", "/auth/user", {});
|
||||
}
|
||||
|
||||
updateUserEmail(email: string): Promise<{ email: string }> {
|
||||
return this._request("POST", "/auth/user/email", { email });
|
||||
}
|
||||
|
||||
getUserCredit(page?: string): Promise<{ credits: number }> {
|
||||
try {
|
||||
return this._get(`/credits`, undefined, page);
|
||||
@@ -89,6 +95,16 @@ export default class BackendAPI {
|
||||
}
|
||||
}
|
||||
|
||||
getUserPreferences(): Promise<NotificationPreference> {
|
||||
return this._get("/auth/user/preferences");
|
||||
}
|
||||
|
||||
updateUserPreferences(
|
||||
preferences: NotificationPreferenceDTO,
|
||||
): Promise<NotificationPreference> {
|
||||
return this._request("POST", "/auth/user/preferences", preferences);
|
||||
}
|
||||
|
||||
getAutoTopUpConfig(): Promise<{ amount: number; threshold: number }> {
|
||||
return this._get("/credits/auto-top-up");
|
||||
}
|
||||
|
||||
@@ -346,6 +346,30 @@ export type UserPasswordCredentials = BaseCredentials & {
|
||||
password: string;
|
||||
};
|
||||
|
||||
// Mirror of backend/backend/data/notifications.py:NotificationType
|
||||
export type NotificationType =
|
||||
| "agent_run"
|
||||
| "zero_balance"
|
||||
| "low_balance"
|
||||
| "block_execution_failed"
|
||||
| "continuous_agent_error"
|
||||
| "daily_summary"
|
||||
| "weekly_summary"
|
||||
| "monthly_summary";
|
||||
|
||||
// Mirror of backend/backend/data/notifications.py:NotificationPreference
|
||||
export type NotificationPreferenceDTO = {
|
||||
email: string;
|
||||
preferences: { [key in NotificationType]: boolean };
|
||||
daily_limit: number;
|
||||
};
|
||||
|
||||
export type NotificationPreference = NotificationPreferenceDTO & {
|
||||
user_id: string;
|
||||
emails_sent_today: number;
|
||||
last_reset_date: Date;
|
||||
};
|
||||
|
||||
/* Mirror of backend/data/integrations.py:Webhook */
|
||||
export type Webhook = {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user