From 564484a550a0026cbbec65690eb7c84a6e47ac1e Mon Sep 17 00:00:00 2001 From: Benjamin Bolte Date: Thu, 7 Nov 2024 15:54:04 -0800 Subject: [PATCH] move more stuff around --- frontend/src/gen/api.ts | 669 +++++++++----------------------- store/app/main.py | 2 - store/app/routers/auth/email.py | 76 +++- store/app/routers/email.py | 68 ---- 4 files changed, 249 insertions(+), 566 deletions(-) delete mode 100644 store/app/routers/email.py diff --git a/frontend/src/gen/api.ts b/frontend/src/gen/api.ts index 60db3aba..769faecc 100644 --- a/frontend/src/gen/api.ts +++ b/frontend/src/gen/api.ts @@ -21,7 +21,7 @@ export interface paths { patch?: never; trace?: never; }; - "/auth/signup": { + "/auth/api/logout": { parameters: { query?: never; header?: never; @@ -30,26 +30,9 @@ export interface paths { }; get?: never; put?: never; - /** Register User */ - post: operations["register_user_auth_signup_post"]; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/auth/login": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - get?: never; - put?: never; - /** Login User */ - post: operations["login_user_auth_login_post"]; - delete?: never; + post?: never; + /** Logout User Endpoint */ + delete: operations["logout_user_endpoint_auth_api_logout_delete"]; options?: never; head?: never; patch?: never; @@ -134,7 +117,7 @@ export interface paths { patch?: never; trace?: never; }; - "/auth/logout": { + "/auth/email/create": { parameters: { query?: never; header?: never; @@ -143,23 +126,26 @@ export interface paths { }; get?: never; put?: never; - post?: never; - /** Logout User Endpoint */ - delete: operations["logout_user_endpoint_auth_logout_delete"]; + /** + * Create Signup Token + * @description Creates a signup token and emails it to the user. + */ + post: operations["create_signup_token_auth_email_create_post"]; + delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/artifacts/url/{artifact_type}/{listing_id}/{name}": { + "/auth/email/get/{id}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - /** Artifact Url */ - get: operations["artifact_url_artifacts_url__artifact_type___listing_id___name__get"]; + /** Get Signup Token */ + get: operations["get_signup_token_auth_email_get__id__get"]; put?: never; post?: never; delete?: never; @@ -168,41 +154,41 @@ export interface paths { patch?: never; trace?: never; }; - "/artifacts/info/{artifact_id}": { + "/auth/email/delete/{id}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - /** Get Artifact Info */ - get: operations["get_artifact_info_artifacts_info__artifact_id__get"]; + get?: never; put?: never; post?: never; - delete?: never; + /** Delete Signup Token */ + delete: operations["delete_signup_token_auth_email_delete__id__delete"]; options?: never; head?: never; patch?: never; trace?: never; }; - "/artifacts/list/{listing_id}": { + "/auth/email/signup": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - /** List Artifacts */ - get: operations["list_artifacts_artifacts_list__listing_id__get"]; + get?: never; put?: never; - post?: never; + /** Register User */ + post: operations["register_user_auth_email_signup_post"]; delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/artifacts/upload/{listing_id}": { + "/auth/email/login": { parameters: { query?: never; header?: never; @@ -211,24 +197,24 @@ export interface paths { }; get?: never; put?: never; - /** Upload */ - post: operations["upload_artifacts_upload__listing_id__post"]; + /** Login User */ + post: operations["login_user_auth_email_login_post"]; delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/artifacts/edit/{artifact_id}": { + "/artifacts/url/{artifact_type}/{listing_id}/{name}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - get?: never; - /** Edit Artifact */ - put: operations["edit_artifact_artifacts_edit__artifact_id__put"]; + /** Artifact Url */ + get: operations["artifact_url_artifacts_url__artifact_type___listing_id___name__get"]; + put?: never; post?: never; delete?: never; options?: never; @@ -236,33 +222,33 @@ export interface paths { patch?: never; trace?: never; }; - "/artifacts/delete/{artifact_id}": { + "/artifacts/info/{artifact_id}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - get?: never; + /** Get Artifact Info */ + get: operations["get_artifact_info_artifacts_info__artifact_id__get"]; put?: never; post?: never; - /** Delete Artifact */ - delete: operations["delete_artifact_artifacts_delete__artifact_id__delete"]; + delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/artifacts/list/{listing_id}/main": { + "/artifacts/list/{listing_id}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - get?: never; - /** Set Main Image */ - put: operations["set_main_image_artifacts_list__listing_id__main_put"]; + /** List Artifacts */ + get: operations["list_artifacts_artifacts_list__listing_id__get"]; + put?: never; post?: never; delete?: never; options?: never; @@ -270,7 +256,7 @@ export interface paths { patch?: never; trace?: never; }; - "/email/signup/create": { + "/artifacts/upload/{listing_id}": { parameters: { query?: never; header?: never; @@ -279,27 +265,24 @@ export interface paths { }; get?: never; put?: never; - /** - * Create Signup Token - * @description Creates a signup token and emails it to the user. - */ - post: operations["create_signup_token_email_signup_create_post"]; + /** Upload */ + post: operations["upload_artifacts_upload__listing_id__post"]; delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/email/signup/get/{id}": { + "/artifacts/edit/{artifact_id}": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - /** Get Signup Token */ - get: operations["get_signup_token_email_signup_get__id__get"]; - put?: never; + get?: never; + /** Edit Artifact */ + put: operations["edit_artifact_artifacts_edit__artifact_id__put"]; post?: never; delete?: never; options?: never; @@ -307,7 +290,7 @@ export interface paths { patch?: never; trace?: never; }; - "/email/signup/delete/{id}": { + "/artifacts/delete/{artifact_id}": { parameters: { query?: never; header?: never; @@ -317,8 +300,25 @@ export interface paths { get?: never; put?: never; post?: never; - /** Delete Signup Token */ - delete: operations["delete_signup_token_email_signup_delete__id__delete"]; + /** Delete Artifact */ + delete: operations["delete_artifact_artifacts_delete__artifact_id__delete"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/artifacts/list/{listing_id}/main": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + /** Set Main Image */ + put: operations["set_main_image_artifacts_list__listing_id__main_put"]; + post?: never; + delete?: never; options?: never; head?: never; patch?: never; @@ -1304,75 +1304,7 @@ export interface paths { patch?: never; trace?: never; }; - "/teleop/offer": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - get?: never; - put?: never; - /** Handle Offer */ - post: operations["handle_offer_teleop_offer_post"]; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/teleop/answer": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - get?: never; - put?: never; - /** Handle Answer */ - post: operations["handle_answer_teleop_answer_post"]; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/teleop/offer/{room_id}": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - /** Get Offer */ - get: operations["get_offer_teleop_offer__room_id__get"]; - put?: never; - post?: never; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/teleop/answer/{room_id}": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - /** Get Answer */ - get: operations["get_answer_teleop_answer__room_id__get"]; - put?: never; - post?: never; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; - "/teleop/ice-candidate": { + "/teleop/rtc/store": { parameters: { query?: never; header?: never; @@ -1381,23 +1313,26 @@ export interface paths { }; get?: never; put?: never; - /** Handle Ice Candidate */ - post: operations["handle_ice_candidate_teleop_ice_candidate_post"]; + /** Store Ice Candidate */ + post: operations["store_ice_candidate_teleop_rtc_store_post"]; delete?: never; options?: never; head?: never; patch?: never; trace?: never; }; - "/teleop/ice-candidates/{room_id}": { + "/teleop/rtc/poll/ice-candidates": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - /** Get Ice Candidates */ - get: operations["get_ice_candidates_teleop_ice_candidates__room_id__get"]; + /** + * Poll Ice Candidates + * @description Defines the polling endpoint for ICE candidates. + */ + get: operations["poll_ice_candidates_teleop_rtc_poll_ice_candidates_get"]; put?: never; post?: never; delete?: never; @@ -1406,31 +1341,10 @@ export interface paths { patch?: never; trace?: never; }; - "/teleop/clear/{room_id}": { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - get?: never; - put?: never; - /** Clear Room */ - post: operations["clear_room_teleop_clear__room_id__post"]; - delete?: never; - options?: never; - head?: never; - patch?: never; - trace?: never; - }; } export type webhooks = Record; export interface components { schemas: { - /** AnswerResponse */ - AnswerResponse: { - answer: components["schemas"]["WebRTCSessionDescription"]; - }; /** ArtifactUrls */ ArtifactUrls: { /** Small */ @@ -1492,11 +1406,6 @@ export interface components { /** Details */ details: string; }; - /** CandidatesResponse */ - CandidatesResponse: { - /** Candidates */ - candidates: components["schemas"]["ICECandidateData"][]; - }; /** ClientIdResponse */ ClientIdResponse: { /** Client Id */ @@ -1633,23 +1542,6 @@ export interface components { /** Detail */ detail?: components["schemas"]["ValidationError"][]; }; - /** ICECandidate */ - ICECandidate: { - /** Room Id */ - room_id: string; - candidate: components["schemas"]["ICECandidateData"]; - /** Is Offer */ - is_offer: boolean; - }; - /** ICECandidateData */ - ICECandidateData: { - /** Candidate */ - candidate: string; - /** Sdpmlineindex */ - sdpMLineIndex: number; - /** Sdpmid */ - sdpMid: string; - }; /** KernelImageResponse */ KernelImageResponse: { /** Id */ @@ -1847,10 +1739,6 @@ export interface components { /** Slug */ slug: string; }; - /** OfferResponse */ - OfferResponse: { - offer: components["schemas"]["WebRTCSessionDescription"]; - }; /** * Order * @description Tracks completed user orders through Stripe. @@ -2057,11 +1945,6 @@ export interface components { * @enum {string} */ SortOption: "newest" | "most_viewed" | "most_upvoted"; - /** SuccessResponse */ - SuccessResponse: { - /** Success */ - success: boolean; - }; /** UpdateArtifactRequest */ UpdateArtifactRequest: { /** Name */ @@ -2202,28 +2085,6 @@ export interface components { /** Error Type */ type: string; }; - /** WebRTCAnswer */ - WebRTCAnswer: { - /** Room Id */ - room_id: string; - answer: components["schemas"]["WebRTCSessionDescription"]; - }; - /** WebRTCOffer */ - WebRTCOffer: { - /** Room Id */ - room_id: string; - offer: components["schemas"]["WebRTCSessionDescription"]; - }; - /** WebRTCSessionDescription */ - WebRTCSessionDescription: { - /** - * Type - * @enum {string} - */ - type: "offer" | "answer"; - /** Sdp */ - sdp: string; - }; }; responses: never; parameters: never; @@ -2253,18 +2114,14 @@ export interface operations { }; }; }; - register_user_auth_signup_post: { + logout_user_endpoint_auth_api_logout_delete: { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; - requestBody: { - content: { - "application/json": components["schemas"]["UserSignup"]; - }; - }; + requestBody?: never; responses: { /** @description Successful Response */ 200: { @@ -2272,21 +2129,32 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["UserInfoResponseItem"]; + "application/json": boolean; }; }; - /** @description Validation Error */ - 422: { + }; + }; + github_client_id_endpoint_auth_github_client_id_get: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful Response */ + 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["HTTPValidationError"]; + "application/json": components["schemas"]["ClientIdResponse"]; }; }; }; }; - login_user_auth_login_post: { + github_code_auth_github_code_post: { parameters: { query?: never; header?: never; @@ -2295,7 +2163,7 @@ export interface operations { }; requestBody: { content: { - "application/json": components["schemas"]["LoginRequest"]; + "application/json": components["schemas"]["GithubAuthRequest"]; }; }; responses: { @@ -2305,7 +2173,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["LoginResponse"]; + "application/json": components["schemas"]["GithubAuthResponse"]; }; }; /** @description Validation Error */ @@ -2319,7 +2187,7 @@ export interface operations { }; }; }; - github_client_id_endpoint_auth_github_client_id_get: { + google_client_id_endpoint_auth_google_client_id_get: { parameters: { query?: never; header?: never; @@ -2339,7 +2207,7 @@ export interface operations { }; }; }; - github_code_auth_github_code_post: { + google_login_endpoint_auth_google_login_post: { parameters: { query?: never; header?: never; @@ -2348,7 +2216,7 @@ export interface operations { }; requestBody: { content: { - "application/json": components["schemas"]["GithubAuthRequest"]; + "application/json": components["schemas"]["GoogleLogin"]; }; }; responses: { @@ -2358,7 +2226,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["GithubAuthResponse"]; + "application/json": components["schemas"]["AuthResponse"]; }; }; /** @description Validation Error */ @@ -2372,27 +2240,7 @@ export interface operations { }; }; }; - google_client_id_endpoint_auth_google_client_id_get: { - parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["ClientIdResponse"]; - }; - }; - }; - }; - google_login_endpoint_auth_google_login_post: { + create_signup_token_auth_email_create_post: { parameters: { query?: never; header?: never; @@ -2401,7 +2249,7 @@ export interface operations { }; requestBody: { content: { - "application/json": components["schemas"]["GoogleLogin"]; + "application/json": components["schemas"]["EmailSignUpRequest"]; }; }; responses: { @@ -2411,7 +2259,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["AuthResponse"]; + "application/json": components["schemas"]["EmailSignUpResponse"]; }; }; /** @description Validation Error */ @@ -2425,11 +2273,13 @@ export interface operations { }; }; }; - logout_user_endpoint_auth_logout_delete: { + get_signup_token_auth_email_get__id__get: { parameters: { query?: never; header?: never; - path?: never; + path: { + id: string; + }; cookie?: never; }; requestBody?: never; @@ -2440,21 +2290,26 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": boolean; + "application/json": components["schemas"]["GetTokenResponse"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; }; }; }; }; - artifact_url_artifacts_url__artifact_type___listing_id___name__get: { + delete_signup_token_auth_email_delete__id__delete: { parameters: { - query?: { - size?: "small" | "large"; - }; + query?: never; header?: never; path: { - artifact_type: "image" | ("urdf" | "mjcf") | ("stl" | "obj" | "dae" | "ply") | ("tgz" | "zip"); - listing_id: string; - name: string; + id: string; }; cookie?: never; }; @@ -2466,7 +2321,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": unknown; + "application/json": components["schemas"]["DeleteTokenResponse"]; }; }; /** @description Validation Error */ @@ -2480,16 +2335,18 @@ export interface operations { }; }; }; - get_artifact_info_artifacts_info__artifact_id__get: { + register_user_auth_email_signup_post: { parameters: { query?: never; header?: never; - path: { - artifact_id: string; - }; + path?: never; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["UserSignup"]; + }; + }; responses: { /** @description Successful Response */ 200: { @@ -2497,7 +2354,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["SingleArtifactResponse"]; + "application/json": components["schemas"]["UserInfoResponseItem"]; }; }; /** @description Validation Error */ @@ -2511,16 +2368,18 @@ export interface operations { }; }; }; - list_artifacts_artifacts_list__listing_id__get: { + login_user_auth_email_login_post: { parameters: { query?: never; header?: never; - path: { - listing_id: string; - }; + path?: never; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "application/json": components["schemas"]["LoginRequest"]; + }; + }; responses: { /** @description Successful Response */ 200: { @@ -2528,7 +2387,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListArtifactsResponse"]; + "application/json": components["schemas"]["LoginResponse"]; }; }; /** @description Validation Error */ @@ -2542,20 +2401,20 @@ export interface operations { }; }; }; - upload_artifacts_upload__listing_id__post: { + artifact_url_artifacts_url__artifact_type___listing_id___name__get: { parameters: { - query?: never; + query?: { + size?: "small" | "large"; + }; header?: never; path: { + artifact_type: "image" | ("urdf" | "mjcf") | ("stl" | "obj" | "dae" | "ply") | ("tgz" | "zip"); listing_id: string; + name: string; }; cookie?: never; }; - requestBody: { - content: { - "multipart/form-data": components["schemas"]["Body_upload_artifacts_upload__listing_id__post"]; - }; - }; + requestBody?: never; responses: { /** @description Successful Response */ 200: { @@ -2563,7 +2422,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["UploadArtifactResponse"]; + "application/json": unknown; }; }; /** @description Validation Error */ @@ -2577,20 +2436,16 @@ export interface operations { }; }; }; - edit_artifact_artifacts_edit__artifact_id__put: { + get_artifact_info_artifacts_info__artifact_id__get: { parameters: { - query: { - id: string; - }; + query?: never; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "application/json": components["schemas"]["UpdateArtifactRequest"]; + path: { + artifact_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { /** @description Successful Response */ 200: { @@ -2598,7 +2453,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": boolean; + "application/json": components["schemas"]["SingleArtifactResponse"]; }; }; /** @description Validation Error */ @@ -2612,12 +2467,12 @@ export interface operations { }; }; }; - delete_artifact_artifacts_delete__artifact_id__delete: { + list_artifacts_artifacts_list__listing_id__get: { parameters: { query?: never; header?: never; path: { - artifact_id: string; + listing_id: string; }; cookie?: never; }; @@ -2629,7 +2484,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": boolean; + "application/json": components["schemas"]["ListArtifactsResponse"]; }; }; /** @description Validation Error */ @@ -2643,18 +2498,20 @@ export interface operations { }; }; }; - set_main_image_artifacts_list__listing_id__main_put: { + upload_artifacts_upload__listing_id__post: { parameters: { - query: { - artifact_id: string; - }; + query?: never; header?: never; path: { listing_id: string; }; cookie?: never; }; - requestBody?: never; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["Body_upload_artifacts_upload__listing_id__post"]; + }; + }; responses: { /** @description Successful Response */ 200: { @@ -2662,7 +2519,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": boolean; + "application/json": components["schemas"]["UploadArtifactResponse"]; }; }; /** @description Validation Error */ @@ -2676,16 +2533,18 @@ export interface operations { }; }; }; - create_signup_token_email_signup_create_post: { + edit_artifact_artifacts_edit__artifact_id__put: { parameters: { - query?: never; + query: { + id: string; + }; header?: never; path?: never; cookie?: never; }; requestBody: { content: { - "application/json": components["schemas"]["EmailSignUpRequest"]; + "application/json": components["schemas"]["UpdateArtifactRequest"]; }; }; responses: { @@ -2695,7 +2554,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["EmailSignUpResponse"]; + "application/json": boolean; }; }; /** @description Validation Error */ @@ -2709,12 +2568,12 @@ export interface operations { }; }; }; - get_signup_token_email_signup_get__id__get: { + delete_artifact_artifacts_delete__artifact_id__delete: { parameters: { query?: never; header?: never; path: { - id: string; + artifact_id: string; }; cookie?: never; }; @@ -2726,7 +2585,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["GetTokenResponse"]; + "application/json": boolean; }; }; /** @description Validation Error */ @@ -2740,12 +2599,14 @@ export interface operations { }; }; }; - delete_signup_token_email_signup_delete__id__delete: { + set_main_image_artifacts_list__listing_id__main_put: { parameters: { - query?: never; + query: { + artifact_id: string; + }; header?: never; path: { - id: string; + listing_id: string; }; cookie?: never; }; @@ -2757,7 +2618,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["DeleteTokenResponse"]; + "application/json": boolean; }; }; /** @description Validation Error */ @@ -4542,81 +4403,16 @@ export interface operations { }; }; }; - handle_offer_teleop_offer_post: { + store_ice_candidate_teleop_rtc_store_post: { parameters: { - query?: never; - header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "application/json": components["schemas"]["WebRTCOffer"]; - }; - }; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["SuccessResponse"]; - }; - }; - /** @description Validation Error */ - 422: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HTTPValidationError"]; - }; + query: { + candidate: string; + robot_id: string; }; - }; - }; - handle_answer_teleop_answer_post: { - parameters: { - query?: never; header?: never; path?: never; cookie?: never; }; - requestBody: { - content: { - "application/json": components["schemas"]["WebRTCAnswer"]; - }; - }; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["SuccessResponse"]; - }; - }; - /** @description Validation Error */ - 422: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HTTPValidationError"]; - }; - }; - }; - }; - get_offer_teleop_offer__room_id__get: { - parameters: { - query?: never; - header?: never; - path: { - room_id: string; - }; - cookie?: never; - }; requestBody?: never; responses: { /** @description Successful Response */ @@ -4625,7 +4421,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["OfferResponse"]; + "application/json": unknown; }; }; /** @description Validation Error */ @@ -4639,112 +4435,15 @@ export interface operations { }; }; }; - get_answer_teleop_answer__room_id__get: { + poll_ice_candidates_teleop_rtc_poll_ice_candidates_get: { parameters: { - query?: never; - header?: never; - path: { - room_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["AnswerResponse"]; - }; - }; - /** @description Validation Error */ - 422: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HTTPValidationError"]; - }; + query: { + robot_id: string; }; - }; - }; - handle_ice_candidate_teleop_ice_candidate_post: { - parameters: { - query?: never; header?: never; path?: never; cookie?: never; }; - requestBody: { - content: { - "application/json": components["schemas"]["ICECandidate"]; - }; - }; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["SuccessResponse"]; - }; - }; - /** @description Validation Error */ - 422: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HTTPValidationError"]; - }; - }; - }; - }; - get_ice_candidates_teleop_ice_candidates__room_id__get: { - parameters: { - query?: { - is_offer?: boolean; - }; - header?: never; - path: { - room_id: string; - }; - cookie?: never; - }; - requestBody?: never; - responses: { - /** @description Successful Response */ - 200: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["CandidatesResponse"]; - }; - }; - /** @description Validation Error */ - 422: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HTTPValidationError"]; - }; - }; - }; - }; - clear_room_teleop_clear__room_id__post: { - parameters: { - query?: never; - header?: never; - path: { - room_id: string; - }; - cookie?: never; - }; requestBody?: never; responses: { /** @description Successful Response */ @@ -4753,7 +4452,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["SuccessResponse"]; + "application/json": unknown; }; }; /** @description Validation Error */ diff --git a/store/app/main.py b/store/app/main.py index 10f3c5f7..3cfacd7f 100644 --- a/store/app/main.py +++ b/store/app/main.py @@ -23,7 +23,6 @@ ) from store.app.routers.artifacts import artifacts_router from store.app.routers.auth import router -from store.app.routers.email import email_router from store.app.routers.kernel_images import kernel_images_router from store.app.routers.keys import keys_router from store.app.routers.listings import listings_router @@ -184,7 +183,6 @@ async def validate_auth_token(auth_token: str = Depends(api_key_header)) -> str: app.include_router(router, prefix="/auth", tags=["auth"]) app.include_router(artifacts_router, prefix="/artifacts", tags=["artifacts"]) -app.include_router(email_router, prefix="/email", tags=["email"]) app.include_router(kernel_images_router, prefix="/kernel-images", tags=["kernel-images"]) app.include_router(keys_router, prefix="/keys", tags=["keys"]) app.include_router(listings_router, prefix="/listings", tags=["listings"]) diff --git a/store/app/routers/auth/email.py b/store/app/routers/auth/email.py index bf8a0344..54199255 100644 --- a/store/app/routers/auth/email.py +++ b/store/app/routers/auth/email.py @@ -3,16 +3,70 @@ from typing import Annotated, Self from fastapi import APIRouter, Depends, HTTPException, status -from pydantic import BaseModel, EmailStr +from pydantic import BaseModel +from pydantic.networks import EmailStr from store.app.crud.users import UserCrud from store.app.db import Crud from store.app.model import APIKeySource, User +from store.app.utils.email import send_signup_email from store.app.utils.password import verify_password router = APIRouter() +class EmailSignUpRequest(BaseModel): + email: EmailStr + + +class EmailSignUpResponse(BaseModel): + message: str + + +@router.post("/create", response_model=EmailSignUpResponse) +async def create_signup_token( + data: EmailSignUpRequest, + crud: Annotated[Crud, Depends(Crud.get)], +) -> EmailSignUpResponse: + """Creates a signup token and emails it to the user.""" + try: + signup_token = await crud.create_email_signup_token(data.email) + await send_signup_email(email=data.email, token=signup_token.id) + + return EmailSignUpResponse(message="Sign up email sent! Follow the link sent to you to continue registration.") + except Exception as e: + raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) + + +class GetTokenResponse(BaseModel): + id: str + email: str + + +@router.get("/get/{id}", response_model=GetTokenResponse) +async def get_signup_token( + id: str, + crud: Annotated[Crud, Depends(Crud.get)], +) -> GetTokenResponse: + signup_token = await crud.get_email_signup_token(id) + if not signup_token: + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Token not found.") + return GetTokenResponse(id=signup_token.id, email=signup_token.email) + + +class DeleteTokenResponse(BaseModel): + message: str + + +@router.delete("/delete/{id}", response_model=DeleteTokenResponse) +async def delete_signup_token( + id: str, + crud: Annotated[Crud, Depends(Crud.get)], +) -> DeleteTokenResponse: + await crud.delete_email_signup_token(id) + return DeleteTokenResponse(message="Token deleted successfully.") + + class UserSignup(BaseModel): signup_token_id: str email: str @@ -35,16 +89,6 @@ class UsersInfoResponse(BaseModel): users: list[UserInfoResponseItem] -class LoginRequest(BaseModel): - email: EmailStr - password: str - - -class LoginResponse(BaseModel): - user_id: str - token: str - - @router.post("/signup", response_model=UserInfoResponseItem) async def register_user(data: UserSignup, crud: Annotated[Crud, Depends(Crud.get)]) -> UserInfoResponseItem: signup_token = await crud.get_email_signup_token(data.signup_token_id) @@ -58,6 +102,16 @@ async def register_user(data: UserSignup, crud: Annotated[Crud, Depends(Crud.get return UserInfoResponseItem(id=user.id, email=user.email) +class LoginRequest(BaseModel): + email: EmailStr + password: str + + +class LoginResponse(BaseModel): + user_id: str + token: str + + @router.post("/login", response_model=LoginResponse) async def login_user(data: LoginRequest, user_crud: UserCrud = Depends()) -> LoginResponse: async with user_crud: diff --git a/store/app/routers/email.py b/store/app/routers/email.py deleted file mode 100644 index 2a3b06c9..00000000 --- a/store/app/routers/email.py +++ /dev/null @@ -1,68 +0,0 @@ -"""This module defines the FastAPI routes for managing email related API routes.""" - -from typing import Annotated - -from fastapi import APIRouter, Depends, HTTPException, status -from pydantic.main import BaseModel -from pydantic.networks import EmailStr - -from store.app.db import Crud -from store.app.utils.email import send_signup_email - -signup_router = APIRouter() - - -class EmailSignUpRequest(BaseModel): - email: EmailStr - - -class EmailSignUpResponse(BaseModel): - message: str - - -@signup_router.post("/create", response_model=EmailSignUpResponse) -async def create_signup_token( - data: EmailSignUpRequest, - crud: Annotated[Crud, Depends(Crud.get)], -) -> EmailSignUpResponse: - """Creates a signup token and emails it to the user.""" - try: - signup_token = await crud.create_email_signup_token(data.email) - await send_signup_email(email=data.email, token=signup_token.id) - - return EmailSignUpResponse(message="Sign up email sent! Follow the link sent to you to continue registration.") - except Exception as e: - raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) - - -class GetTokenResponse(BaseModel): - id: str - email: str - - -class DeleteTokenResponse(BaseModel): - message: str - - -@signup_router.get("/get/{id}", response_model=GetTokenResponse) -async def get_signup_token( - id: str, - crud: Annotated[Crud, Depends(Crud.get)], -) -> GetTokenResponse: - signup_token = await crud.get_email_signup_token(id) - if not signup_token: - raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Token not found.") - return GetTokenResponse(id=signup_token.id, email=signup_token.email) - - -@signup_router.delete("/delete/{id}", response_model=DeleteTokenResponse) -async def delete_signup_token( - id: str, - crud: Annotated[Crud, Depends(Crud.get)], -) -> DeleteTokenResponse: - await crud.delete_email_signup_token(id) - return DeleteTokenResponse(message="Token deleted successfully.") - - -email_router = APIRouter() -email_router.include_router(signup_router, prefix="/signup", tags=["signup"])