diff --git a/frontend/app/auth/google/layout.tsx b/frontend/app/(unauthenticated)/auth/google/layout.tsx similarity index 100% rename from frontend/app/auth/google/layout.tsx rename to frontend/app/(unauthenticated)/auth/google/layout.tsx diff --git a/frontend/app/auth/google/page.tsx b/frontend/app/(unauthenticated)/auth/google/page.tsx similarity index 100% rename from frontend/app/auth/google/page.tsx rename to frontend/app/(unauthenticated)/auth/google/page.tsx diff --git a/frontend/app/login/page.tsx b/frontend/app/(unauthenticated)/login/page.tsx similarity index 96% rename from frontend/app/login/page.tsx rename to frontend/app/(unauthenticated)/login/page.tsx index 6c748be1..d9c07d17 100644 --- a/frontend/app/login/page.tsx +++ b/frontend/app/(unauthenticated)/login/page.tsx @@ -39,7 +39,6 @@ type LoginForm = z.infer; function LoginPage() { const router = useRouter(); - const isLoggedIn = useUserStore((state) => state.isLoggedIn); const setLoggedIn = useUserStore((state) => state.setLoggedIn); const [isError, setIsError] = useState(false); @@ -63,10 +62,6 @@ function LoginPage() { } }; - if (isLoggedIn) { - router.push("/"); - } - return ( @@ -145,6 +140,11 @@ function LoginPage() { Create an account +
+ + Forgot your password? + +
); } diff --git a/frontend/app/register/page.tsx b/frontend/app/(unauthenticated)/register/page.tsx similarity index 96% rename from frontend/app/register/page.tsx rename to frontend/app/(unauthenticated)/register/page.tsx index 9b6c3b84..4b026381 100644 --- a/frontend/app/register/page.tsx +++ b/frontend/app/(unauthenticated)/register/page.tsx @@ -16,7 +16,6 @@ import { Alert, AlertDescription } from "@/components/ui/alert"; import { Box } from "@/components/ui/box"; import { Button } from "@/components/ui/button"; import { Form } from "@/components/ui/form"; -import { useUserStore } from "@/store/user/user-store-provider"; const registerFormSchema = z.object({ email: z.string().email("Invalid email address"), @@ -32,7 +31,6 @@ type RegisterForm = z.infer; function RegisterPage() { const router = useRouter(); - const isLoggedIn = useUserStore((state) => state.isLoggedIn); const [isError, setIsError] = useState(false); const form = useForm({ resolver: zodResolver(registerFormSchema), @@ -53,10 +51,6 @@ function RegisterPage() { } }; - if (isLoggedIn) { - router.push("/"); - } - return ( diff --git a/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-form.tsx b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-form.tsx new file mode 100644 index 00000000..9c91e822 --- /dev/null +++ b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-form.tsx @@ -0,0 +1,154 @@ +"use client"; + +import { useState } from "react"; +import { SubmitHandler, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { CircleAlert } from "lucide-react"; +import { z } from "zod"; + +import { completePasswordResetAuthPasswordResetPut } from "@/client"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Box } from "@/components/ui/box"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; + +const resetPasswordCompleteFormSchema = z + .object({ + password: z + .string() + .min(6, "Password should be at least 6 characters long"), + confirmPassword: z.string(), + }) + .refine(({ password, confirmPassword }) => password === confirmPassword, { + message: "Passwords must match", + path: ["confirmPassword"], + }); + +const resetPasswordFormDefault = { + password: "", + confirmPassword: "", +}; + +type ResetPasswordRequestForm = z.infer; + +export default function ResetPasswordCompleteForm({ + code, + onComplete, +}: { + code: string; + onComplete: () => void; +}) { + const [isError, setIsError] = useState(false); + + const form = useForm({ + resolver: zodResolver(resetPasswordCompleteFormSchema), + defaultValues: resetPasswordFormDefault, + }); + + const onSubmit: SubmitHandler = async (data) => { + const response = await completePasswordResetAuthPasswordResetPut({ + body: { + password: data.password, + confirm_password: data.confirmPassword, + }, + withCredentials: true, + query: { + code: code, + }, + }); + + if (response.error) { + setIsError(true); + } else { + setIsError(false); + onComplete(); + } + }; + + return ( + <> + + + Reset your password + Enter your new password! + + + + + {isError && ( + + + + Your password needs to match. + + + )} +
+ +
+ + ( + + + New Password + + + + + + + )} + /> + +
+
+ + ( + + + Confirm Password + + + + + + + )} + /> + +
+ +
+ +
+
+
+ + ); +} diff --git a/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-sent.tsx b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-sent.tsx new file mode 100644 index 00000000..7ca1682b --- /dev/null +++ b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-complete-sent.tsx @@ -0,0 +1,32 @@ +import Link from "next/link"; +import { CheckCircleIcon } from "lucide-react"; + +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; + +export default function ResetPasswordCompleteSent() { + return ( + + + Check your email + + All done! Login with your new password. + + + + +
+ + + +
+
+
+ ); +} diff --git a/frontend/app/(unauthenticated)/reset-password/_components/reset-password-create-request-form.tsx b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-create-request-form.tsx new file mode 100644 index 00000000..3e2b5842 --- /dev/null +++ b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-create-request-form.tsx @@ -0,0 +1,114 @@ +"use client"; + +import { useState } from "react"; +import { SubmitHandler, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { CircleAlert } from "lucide-react"; +import { z } from "zod"; + +import { requestPasswordResetAuthPasswordResetPost } from "@/client"; +import TextField from "@/components/form/fields/text-field"; +import Link from "@/components/navigation/link"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Box } from "@/components/ui/box"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Form } from "@/components/ui/form"; + +import ResetPasswordRequestSent from "./reset-password-request-sent"; + +const resetPasswordRequestFormSchema = z.object({ + email: z.string().email("Invalid email address"), +}); + +const resetPasswordFormDefault = { + email: "", + password: "", +}; + +type ResetPasswordRequestForm = z.infer; + +export default function ResetPasswordCreateRequestForm() { + const [isError, setIsError] = useState(false); + const [sent, setSent] = useState(false); + + const form = useForm({ + resolver: zodResolver(resetPasswordRequestFormSchema), + defaultValues: resetPasswordFormDefault, + }); + + const onSubmit: SubmitHandler = async (data) => { + const response = await requestPasswordResetAuthPasswordResetPost({ + body: { email: data.email }, + withCredentials: true, + }); + + if (response.error) { + setIsError(true); + } else { + setIsError(false); + setSent(true); + } + }; + + return sent ? ( + setSent(false)} + /> + ) : ( + <> + + + Reset your password + + Don't worry, enter the email associated with your Jippy account + and we will send you a link to reset your password. + + + + + + {isError && ( + + + + Your email or password is incorrect. Please try again, or{" "} + + reset your password + + . + + + )} +
+ +
+ +
+ +
+ +
+
+
+
+

Not registered yet?

+ + Create an account + +
+ + ); +} diff --git a/frontend/app/(unauthenticated)/reset-password/_components/reset-password-request-sent.tsx b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-request-sent.tsx new file mode 100644 index 00000000..31656f52 --- /dev/null +++ b/frontend/app/(unauthenticated)/reset-password/_components/reset-password-request-sent.tsx @@ -0,0 +1,74 @@ +"use client"; + +import { useState } from "react"; + +import { requestPasswordResetAuthPasswordResetPost } from "@/client"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; + +export default function ResetPasswordRequestSent({ + email, + reset, +}: { + email: string; + reset: () => void; +}) { + const [resent, setResent] = useState(false); + const resend = async () => { + await requestPasswordResetAuthPasswordResetPost({ + body: { email }, + withCredentials: true, + }); + setResent(true); + }; + return ( + + + Check your email + + {resent ? ( + +

+ We've resent password reset instructions to{" "} + {email} if it is an email on + file. +

+

+ Please check again. If you still haven't received an email,{" "} + reset()} + > + try a different email + + . +

+
+ ) : ( + +

+ Thanks! If {email} matches an + email we have on file, then we've sent you an email containing + further instructions for resetting your password. +

+

+ If you haven't received an email in 5 minutes, check your spam,{" "} + resend()} + > + resend + {" "} + or{" "} + reset()} + > + try a different email + + . +

+
+ )} +
+ ); +} diff --git a/frontend/app/(unauthenticated)/reset-password/page.tsx b/frontend/app/(unauthenticated)/reset-password/page.tsx new file mode 100644 index 00000000..be8f62d3 --- /dev/null +++ b/frontend/app/(unauthenticated)/reset-password/page.tsx @@ -0,0 +1,43 @@ +"use client"; + +import { useState } from "react"; +import { useSearchParams } from "next/navigation"; + +import { Box } from "@/components/ui/box"; + +import ResetPasswordCompleteForm from "./_components/reset-password-complete-form"; +import ResetPasswordCompleteSent from "./_components/reset-password-complete-sent"; +import ResetPasswordCreateRequestForm from "./_components/reset-password-create-request-form"; + +enum ResetPasswordState { + CreatingRequest, + PendingReset, + End, +} + +function ResetPasswordPage() { + const params = useSearchParams(); + + const code = params.get("code"); + + const [pageState, setPageState] = useState( + code ? ResetPasswordState.PendingReset : ResetPasswordState.CreatingRequest, + ); + + return ( + + {pageState === ResetPasswordState.CreatingRequest && ( + + )} + {pageState === ResetPasswordState.PendingReset && ( + setPageState(ResetPasswordState.End)} + /> + )} + {pageState === ResetPasswordState.End && } + + ); +} + +export default ResetPasswordPage; diff --git a/frontend/app/(unauthenticated)/template.tsx b/frontend/app/(unauthenticated)/template.tsx new file mode 100644 index 00000000..fcf023c1 --- /dev/null +++ b/frontend/app/(unauthenticated)/template.tsx @@ -0,0 +1,16 @@ +"use client"; +import { Suspense } from "react"; +import { useRouter } from "next/navigation"; + +import { useUserStore } from "@/store/user/user-store-provider"; + +export default function RedirectIfAuthenticated({ + children, +}: Readonly<{ children: React.ReactNode }>) { + const router = useRouter(); + const isLoggedIn = useUserStore((state) => state.isLoggedIn); + if (isLoggedIn) { + router.push("/"); + } + return {children}; +} diff --git a/frontend/client/client.ts b/frontend/client/client.ts index 6d6722dd..7d794d27 100644 --- a/frontend/client/client.ts +++ b/frontend/client/client.ts @@ -1,4 +1,4 @@ -export { createClient } from "./core/"; +export { createClient } from './core/'; export type { Client, Config, @@ -6,10 +6,10 @@ export type { RequestOptions, RequestOptionsBase, RequestResult, -} from "./core/types"; +} from './core/types'; export { createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, -} from "./core/utils"; +} from './core/utils'; diff --git a/frontend/client/core/index.ts b/frontend/client/core/index.ts index 76dca954..afe16e6a 100644 --- a/frontend/client/core/index.ts +++ b/frontend/client/core/index.ts @@ -1,9 +1,8 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import type { AxiosError } from "axios"; -import axios from "axios"; +import type { AxiosError } from 'axios'; +import axios from 'axios'; -import type { Client, Config, RequestOptions } from "./types"; -import { createConfig, getUrl, mergeConfigs, mergeHeaders } from "./utils"; +import type { Client, Config, RequestOptions } from './types'; +import { createConfig, getUrl, mergeConfigs, mergeHeaders } from './utils'; export const createClient = (config: Config): Client => { let _config = mergeConfigs(createConfig(), config); @@ -24,7 +23,7 @@ export const createClient = (config: Config): Client => { }; // @ts-expect-error - const request: Client["request"] = async (options) => { + const request: Client['request'] = async (options) => { const opts: RequestOptions = { ..._config, ...options, @@ -52,7 +51,7 @@ export const createClient = (config: Config): Client => { let { data } = response; - if (opts.responseType === "json" && opts.responseTransformer) { + if (opts.responseType === 'json' && opts.responseTransformer) { data = await opts.responseTransformer(data); } @@ -72,15 +71,15 @@ export const createClient = (config: Config): Client => { }; return { - delete: (options) => request({ ...options, method: "delete" }), - get: (options) => request({ ...options, method: "get" }), + delete: (options) => request({ ...options, method: 'delete' }), + get: (options) => request({ ...options, method: 'get' }), getConfig, - head: (options) => request({ ...options, method: "head" }), + head: (options) => request({ ...options, method: 'head' }), instance, - options: (options) => request({ ...options, method: "options" }), - patch: (options) => request({ ...options, method: "patch" }), - post: (options) => request({ ...options, method: "post" }), - put: (options) => request({ ...options, method: "put" }), + options: (options) => request({ ...options, method: 'options' }), + patch: (options) => request({ ...options, method: 'patch' }), + post: (options) => request({ ...options, method: 'post' }), + put: (options) => request({ ...options, method: 'put' }), request, setConfig, } as Client; diff --git a/frontend/client/core/types.ts b/frontend/client/core/types.ts index 18a974f1..98db41f5 100644 --- a/frontend/client/core/types.ts +++ b/frontend/client/core/types.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import type { AxiosError, AxiosInstance, @@ -6,14 +5,14 @@ import type { AxiosResponse, AxiosStatic, CreateAxiosDefaults, -} from "axios"; +} from 'axios'; -import type { BodySerializer } from "./utils"; +import type { BodySerializer } from './utils'; type OmitKeys = Pick>; export interface Config - extends Omit { + extends Omit { /** * Axios implementation. You can use this option to provide a custom * Axios instance. @@ -38,7 +37,7 @@ export interface Config * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: - | CreateAxiosDefaults["headers"] + | CreateAxiosDefaults['headers'] | Record< string, | string @@ -55,15 +54,15 @@ export interface Config * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: - | "connect" - | "delete" - | "get" - | "head" - | "options" - | "patch" - | "post" - | "put" - | "trace"; + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; /** * A function for transforming response data before it's returned to the * caller function. This is an ideal place to post-process server data, @@ -100,7 +99,7 @@ type MethodFn = < TError = unknown, ThrowOnError extends boolean = false, >( - options: Omit, "method">, + options: Omit, 'method'>, ) => RequestResult; type RequestFn = < @@ -108,8 +107,8 @@ type RequestFn = < TError = unknown, ThrowOnError extends boolean = false, >( - options: Omit, "method"> & - Pick>, "method">, + options: Omit, 'method'> & + Pick>, 'method'>, ) => RequestResult; export interface Client { @@ -128,12 +127,12 @@ export interface Client { export type RequestOptions = RequestOptionsBase & Config & { - headers: AxiosRequestConfig["headers"]; + headers: AxiosRequestConfig['headers']; }; type OptionsBase = Omit< RequestOptionsBase, - "url" + 'url' > & { /** * You can provide a client instance returned by `createClient()` instead of @@ -148,12 +147,12 @@ export type Options< ThrowOnError extends boolean = boolean, > = T extends { body?: any } ? T extends { headers?: any } - ? OmitKeys, "body" | "headers"> & T - : OmitKeys, "body"> & + ? OmitKeys, 'body' | 'headers'> & T + : OmitKeys, 'body'> & T & - Pick, "headers"> + Pick, 'headers'> : T extends { headers?: any } - ? OmitKeys, "headers"> & + ? OmitKeys, 'headers'> & T & - Pick, "body"> + Pick, 'body'> : OptionsBase & T; diff --git a/frontend/client/core/utils.ts b/frontend/client/core/utils.ts index f7103fc4..2d3e8a8e 100644 --- a/frontend/client/core/utils.ts +++ b/frontend/client/core/utils.ts @@ -1,6 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import type { Config } from "./types"; +import type { Config } from './types'; interface PathSerializer { path: Record; @@ -9,10 +7,10 @@ interface PathSerializer { const PATH_PARAM_RE = /\{[^{}]+\}/g; -type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited"; -type MatrixStyle = "label" | "matrix" | "simple"; +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; type ArraySeparatorStyle = ArrayStyle | MatrixStyle; -type ObjectStyle = "form" | "deepObject"; +type ObjectStyle = 'form' | 'deepObject'; type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; export type BodySerializer = (body: any) => any; @@ -42,12 +40,12 @@ const serializePrimitiveParam = ({ value, }: SerializePrimitiveParam) => { if (value === undefined || value === null) { - return ""; + return ''; } - if (typeof value === "object") { + if (typeof value === 'object') { throw new Error( - "Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.", + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', ); } @@ -56,40 +54,40 @@ const serializePrimitiveParam = ({ const separatorArrayExplode = (style: ArraySeparatorStyle) => { switch (style) { - case "label": - return "."; - case "matrix": - return ";"; - case "simple": - return ","; + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; default: - return "&"; + return '&'; } }; const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { switch (style) { - case "form": - return ","; - case "pipeDelimited": - return "|"; - case "spaceDelimited": - return "%20"; + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; default: - return ","; + return ','; } }; const separatorObjectExplode = (style: ObjectSeparatorStyle) => { switch (style) { - case "label": - return "."; - case "matrix": - return ";"; - case "simple": - return ","; + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; default: - return "&"; + return '&'; } }; @@ -107,11 +105,11 @@ const serializeArrayParam = ({ allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) ).join(separatorArrayNoExplode(style)); switch (style) { - case "label": + case 'label': return `.${joinedValues}`; - case "matrix": + case 'matrix': return `;${name}=${joinedValues}`; - case "simple": + case 'simple': return joinedValues; default: return `${name}=${joinedValues}`; @@ -121,7 +119,7 @@ const serializeArrayParam = ({ const separator = separatorArrayExplode(style); const joinedValues = value .map((v) => { - if (style === "label" || style === "simple") { + if (style === 'label' || style === 'simple') { return allowReserved ? v : encodeURIComponent(v as string); } @@ -132,7 +130,7 @@ const serializeArrayParam = ({ }); }) .join(separator); - return style === "label" || style === "matrix" + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; }; @@ -146,7 +144,7 @@ const serializeObjectParam = ({ }: SerializeOptions & { value: Record; }) => { - if (style !== "deepObject" && !explode) { + if (style !== 'deepObject' && !explode) { let values: string[] = []; Object.entries(value).forEach(([key, v]) => { values = [ @@ -155,13 +153,13 @@ const serializeObjectParam = ({ allowReserved ? (v as string) : encodeURIComponent(v as string), ]; }); - const joinedValues = values.join(","); + const joinedValues = values.join(','); switch (style) { - case "form": + case 'form': return `${name}=${joinedValues}`; - case "label": + case 'label': return `.${joinedValues}`; - case "matrix": + case 'matrix': return `;${name}=${joinedValues}`; default: return joinedValues; @@ -173,12 +171,12 @@ const serializeObjectParam = ({ .map(([key, v]) => serializePrimitiveParam({ allowReserved, - name: style === "deepObject" ? `${name}[${key}]` : key, + name: style === 'deepObject' ? `${name}[${key}]` : key, value: v as string, }), ) .join(separator); - return style === "label" || style === "matrix" + return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues; }; @@ -190,19 +188,19 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { for (const match of matches) { let explode = false; let name = match.substring(1, match.length - 1); - let style: ArraySeparatorStyle = "simple"; + let style: ArraySeparatorStyle = 'simple'; - if (name.endsWith("*")) { + if (name.endsWith('*')) { explode = true; name = name.substring(0, name.length - 1); } - if (name.startsWith(".")) { + if (name.startsWith('.')) { name = name.substring(1); - style = "label"; - } else if (name.startsWith(";")) { + style = 'label'; + } else if (name.startsWith(';')) { name = name.substring(1); - style = "matrix"; + style = 'matrix'; } const value = path[name]; @@ -219,7 +217,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { continue; } - if (typeof value === "object") { + if (typeof value === 'object') { url = url.replace( match, serializeObjectParam({ @@ -232,7 +230,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { continue; } - if (style === "matrix") { + if (style === 'matrix') { url = url.replace( match, `;${serializePrimitiveParam({ @@ -244,7 +242,7 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { } const replaceValue = encodeURIComponent( - style === "label" ? `.${value as string}` : (value as string), + style === 'label' ? `.${value as string}` : (value as string), ); url = url.replace(match, replaceValue); } @@ -265,7 +263,7 @@ const serializeFormDataPair = ( key: string, value: unknown, ) => { - if (typeof value === "string" || value instanceof Blob) { + if (typeof value === 'string' || value instanceof Blob) { formData.append(key, value); } else { formData.append(key, JSON.stringify(value)); @@ -279,11 +277,11 @@ export const mergeConfigs = (a: Config, b: Config): Config => { }; export const mergeHeaders = ( - ...headers: Array["headers"] | undefined> -): Required["headers"] => { - const mergedHeaders: Required["headers"] = {}; + ...headers: Array['headers'] | undefined> +): Required['headers'] => { + const mergedHeaders: Required['headers'] = {}; for (const header of headers) { - if (!header || typeof header !== "object") { + if (!header || typeof header !== 'object') { continue; } @@ -303,7 +301,7 @@ export const mergeHeaders = ( // content value in OpenAPI specification is 'application/json' // @ts-expect-error mergedHeaders[key] = - typeof value === "object" ? JSON.stringify(value) : (value as string); + typeof value === 'object' ? JSON.stringify(value) : (value as string); } } } @@ -340,7 +338,7 @@ const serializeUrlSearchParamsPair = ( key: string, value: unknown, ) => { - if (typeof value === "string") { + if (typeof value === 'string') { data.append(key, value); } else { data.append(key, JSON.stringify(value)); @@ -369,6 +367,6 @@ export const urlSearchParamsBodySerializer = { }; export const createConfig = (override: Config = {}): Config => ({ - baseURL: "", + baseURL: '', ...override, }); diff --git a/frontend/client/index.ts b/frontend/client/index.ts index 1cb041de..0a2b84ba 100644 --- a/frontend/client/index.ts +++ b/frontend/client/index.ts @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from "./schemas.gen"; -export * from "./services.gen"; -export * from "./types.gen"; +export * from './schemas.gen'; +export * from './services.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/frontend/client/schemas.gen.ts b/frontend/client/schemas.gen.ts index a4999a29..3628044a 100644 --- a/frontend/client/schemas.gen.ts +++ b/frontend/client/schemas.gen.ts @@ -1,440 +1,623 @@ // This file is auto-generated by @hey-api/openapi-ts export const AnalysisDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - category: { - $ref: "#/components/schemas/CategoryDTO", - }, - content: { - type: "string", - title: "Content", - }, - }, - type: "object", - required: ["id", "category", "content"], - title: "AnalysisDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + category: { + '$ref': '#/components/schemas/CategoryDTO' + }, + content: { + type: 'string', + title: 'Content' + } + }, + type: 'object', + required: ['id', 'category', 'content'], + title: 'AnalysisDTO' } as const; export const AnswerDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - points: { - items: { - $ref: "#/components/schemas/PointMiniDTO", - }, - type: "array", - title: "Points", - }, - }, - type: "object", - required: ["id", "points"], - title: "AnswerDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + points: { + items: { + '$ref': '#/components/schemas/PointMiniDTO' + }, + type: 'array', + title: 'Points' + } + }, + type: 'object', + required: ['id', 'points'], + title: 'AnswerDTO' +} as const; + +export const ArticleDTOSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + summary: { + type: 'string', + title: 'Summary' + }, + body: { + type: 'string', + title: 'Body' + }, + url: { + type: 'string', + title: 'Url' + }, + source: { + '$ref': '#/components/schemas/ArticleSource' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + image_url: { + type: 'string', + title: 'Image Url' + } + }, + type: 'object', + required: ['id', 'title', 'summary', 'body', 'url', 'source', 'date', 'image_url'], + title: 'ArticleDTO' +} as const; + +export const ArticleSourceSchema = { + type: 'string', + enum: ['CNA', 'GUARDIAN'], + title: 'ArticleSource' } as const; export const Body_log_in_auth_login_postSchema = { - properties: { - grant_type: { - anyOf: [ - { - type: "string", - pattern: "password", - }, - { - type: "null", - }, - ], - title: "Grant Type", - }, - username: { - type: "string", - title: "Username", - }, - password: { - type: "string", - title: "Password", - }, - scope: { - type: "string", - title: "Scope", - default: "", - }, - client_id: { - anyOf: [ - { - type: "string", + properties: { + grant_type: { + anyOf: [ + { + type: 'string', + pattern: 'password' + }, + { + type: 'null' + } + ], + title: 'Grant Type' }, - { - type: "null", + username: { + type: 'string', + title: 'Username' }, - ], - title: "Client Id", - }, - client_secret: { - anyOf: [ - { - type: "string", + password: { + type: 'string', + title: 'Password' }, - { - type: "null", + scope: { + type: 'string', + title: 'Scope', + default: '' }, - ], - title: "Client Secret", - }, - }, - type: "object", - required: ["username", "password"], - title: "Body_log_in_auth_login_post", + client_id: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Client Id' + }, + client_secret: { + anyOf: [ + { + type: 'string' + }, + { + type: 'null' + } + ], + title: 'Client Secret' + } + }, + type: 'object', + required: ['username', 'password'], + title: 'Body_log_in_auth_login_post' } as const; export const CategoryDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - name: { - type: "string", - title: "Name", - }, - }, - type: "object", - required: ["id", "name"], - title: "CategoryDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + name: { + type: 'string', + title: 'Name' + } + }, + type: 'object', + required: ['id', 'name'], + title: 'CategoryDTO' } as const; export const CreateUserQuestionSchema = { - properties: { - question: { - type: "string", - title: "Question", - }, - }, - type: "object", - required: ["question"], - title: "CreateUserQuestion", + properties: { + question: { + type: 'string', + title: 'Question' + } + }, + type: 'object', + required: ['question'], + title: 'CreateUserQuestion' } as const; export const EventDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - description: { - type: "string", - title: "Description", - }, - is_singapore: { - type: "boolean", - title: "Is Singapore", - }, - date: { - type: "string", - format: "date-time", - title: "Date", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - analysises: { - items: { - $ref: "#/components/schemas/AnalysisDTO", - }, - type: "array", - title: "Analysises", - }, - gp_questions: { - items: { - $ref: "#/components/schemas/GPQuestionDTO", - }, - type: "array", - title: "Gp Questions", - }, - }, - type: "object", - required: [ - "id", - "title", - "description", - "is_singapore", - "date", - "categories", - "analysises", - "gp_questions", - ], - title: "EventDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + description: { + type: 'string', + title: 'Description' + }, + is_singapore: { + type: 'boolean', + title: 'Is Singapore' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + }, + original_article: { + '$ref': '#/components/schemas/ArticleDTO' + }, + reads: { + items: { + '$ref': '#/components/schemas/ReadDTO' + }, + type: 'array', + title: 'Reads' + }, + analysises: { + items: { + '$ref': '#/components/schemas/AnalysisDTO' + }, + type: 'array', + title: 'Analysises' + }, + gp_questions: { + items: { + '$ref': '#/components/schemas/GPQuestionDTO' + }, + type: 'array', + title: 'Gp Questions' + } + }, + type: 'object', + required: ['id', 'title', 'description', 'is_singapore', 'date', 'categories', 'original_article', 'reads', 'analysises', 'gp_questions'], + title: 'EventDTO' } as const; export const EventIndexResponseSchema = { - properties: { - total_count: { - type: "integer", - title: "Total Count", - }, - count: { - type: "integer", - title: "Count", - }, - data: { - items: { - $ref: "#/components/schemas/MiniEventDTO", - }, - type: "array", - title: "Data", - }, - }, - type: "object", - required: ["total_count", "count", "data"], - title: "EventIndexResponse", + properties: { + total_count: { + type: 'integer', + title: 'Total Count' + }, + count: { + type: 'integer', + title: 'Count' + }, + data: { + items: { + '$ref': '#/components/schemas/MiniEventDTO' + }, + type: 'array', + title: 'Data' + } + }, + type: 'object', + required: ['total_count', 'count', 'data'], + title: 'EventIndexResponse' } as const; export const GPQuestionDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - question: { - type: "string", - title: "Question", - }, - is_llm_generated: { - type: "boolean", - title: "Is Llm Generated", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - }, - type: "object", - required: ["id", "question", "is_llm_generated", "categories"], - title: "GPQuestionDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + question: { + type: 'string', + title: 'Question' + }, + is_llm_generated: { + type: 'boolean', + title: 'Is Llm Generated' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + } + }, + type: 'object', + required: ['id', 'question', 'is_llm_generated', 'categories'], + title: 'GPQuestionDTO' } as const; export const HTTPValidationErrorSchema = { - properties: { - detail: { - items: { - $ref: "#/components/schemas/ValidationError", - }, - type: "array", - title: "Detail", - }, - }, - type: "object", - title: "HTTPValidationError", + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' } as const; export const MiniEventDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - description: { - type: "string", - title: "Description", - }, - is_singapore: { - type: "boolean", - title: "Is Singapore", - }, - date: { - type: "string", - format: "date-time", - title: "Date", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + description: { + type: 'string', + title: 'Description' + }, + is_singapore: { + type: 'boolean', + title: 'Is Singapore' + }, + date: { + type: 'string', + format: 'date-time', + title: 'Date' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + }, + original_article: { + '$ref': '#/components/schemas/ArticleDTO' + }, + reads: { + items: { + '$ref': '#/components/schemas/ReadDTO' + }, + type: 'array', + title: 'Reads' + } + }, + type: 'object', + required: ['id', 'title', 'description', 'is_singapore', 'date', 'categories', 'original_article', 'reads'], + title: 'MiniEventDTO' +} as const; + +export const NoteCreateSchema = { + properties: { + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + }, + parent_id: { + type: 'integer', + title: 'Parent Id' + }, + parent_type: { + '$ref': '#/components/schemas/NoteType' + } }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", + type: 'object', + required: ['content', 'start_index', 'end_index', 'parent_id', 'parent_type'], + title: 'NoteCreate' +} as const; + +export const NoteDTOSchema = { + properties: { + id: { + type: 'integer', + title: 'Id' + }, + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + }, + parent_id: { + type: 'integer', + title: 'Parent Id' + }, + parent_type: { + '$ref': '#/components/schemas/NoteType' + } }, - }, - type: "object", - required: [ - "id", - "title", - "description", - "is_singapore", - "date", - "categories", - ], - title: "MiniEventDTO", + type: 'object', + required: ['id', 'content', 'start_index', 'end_index', 'parent_id', 'parent_type'], + title: 'NoteDTO' +} as const; + +export const NoteTypeSchema = { + type: 'string', + enum: ['event', 'article', 'point'], + title: 'NoteType' +} as const; + +export const NoteUpdateSchema = { + properties: { + content: { + type: 'string', + title: 'Content' + }, + start_index: { + type: 'integer', + title: 'Start Index' + }, + end_index: { + type: 'integer', + title: 'End Index' + } + }, + type: 'object', + required: ['content', 'start_index', 'end_index'], + title: 'NoteUpdate' +} as const; + +export const PasswordResetCompleteDataSchema = { + properties: { + password: { + type: 'string', + minLength: 6, + title: 'Password' + }, + confirm_password: { + type: 'string', + minLength: 6, + title: 'Confirm Password' + } + }, + type: 'object', + required: ['password', 'confirm_password'], + title: 'PasswordResetCompleteData' +} as const; + +export const PasswordResetRequestDataSchema = { + properties: { + email: { + type: 'string', + format: 'email', + title: 'Email' + } + }, + type: 'object', + required: ['email'], + title: 'PasswordResetRequestData' } as const; export const PointMiniDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - title: { - type: "string", - title: "Title", - }, - body: { - type: "string", - title: "Body", - }, - events: { - items: { - $ref: "#/components/schemas/EventDTO", - }, - type: "array", - title: "Events", - }, - }, - type: "object", - required: ["id", "title", "body", "events"], - title: "PointMiniDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + title: { + type: 'string', + title: 'Title' + }, + body: { + type: 'string', + title: 'Body' + }, + events: { + items: { + '$ref': '#/components/schemas/EventDTO' + }, + type: 'array', + title: 'Events' + } + }, + type: 'object', + required: ['id', 'title', 'body', 'events'], + title: 'PointMiniDTO' } as const; export const ProfileUpdateSchema = { - properties: { - category_ids: { - items: { - type: "integer", - }, - type: "array", - title: "Category Ids", - }, - }, - type: "object", - required: ["category_ids"], - title: "ProfileUpdate", + properties: { + category_ids: { + items: { + type: 'integer' + }, + type: 'array', + title: 'Category Ids' + } + }, + type: 'object', + required: ['category_ids'], + title: 'ProfileUpdate' +} as const; + +export const ReadDTOSchema = { + properties: { + first_read: { + type: 'string', + format: 'date-time', + title: 'First Read' + }, + last_read: { + type: 'string', + format: 'date-time', + title: 'Last Read' + } + }, + type: 'object', + required: ['first_read', 'last_read'], + title: 'ReadDTO' } as const; export const SignUpDataSchema = { - properties: { - email: { - type: "string", - format: "email", - title: "Email", - }, - password: { - type: "string", - minLength: 6, - title: "Password", - }, - }, - type: "object", - required: ["email", "password"], - title: "SignUpData", + properties: { + email: { + type: 'string', + format: 'email', + title: 'Email' + }, + password: { + type: 'string', + minLength: 6, + title: 'Password' + } + }, + type: 'object', + required: ['email', 'password'], + title: 'SignUpData' } as const; export const TokenSchema = { - properties: { - access_token: { - type: "string", - title: "Access Token", - }, - token_type: { - type: "string", - title: "Token Type", - }, - user: { - $ref: "#/components/schemas/UserPublic", + properties: { + access_token: { + type: 'string', + title: 'Access Token' + }, + token_type: { + type: 'string', + title: 'Token Type' + }, + user: { + '$ref': '#/components/schemas/UserPublic' + } }, - }, - type: "object", - required: ["access_token", "token_type", "user"], - title: "Token", + type: 'object', + required: ['access_token', 'token_type', 'user'], + title: 'Token' } as const; export const UserPublicSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - email: { - type: "string", - format: "email", - title: "Email", - }, - categories: { - items: { - $ref: "#/components/schemas/CategoryDTO", - }, - type: "array", - title: "Categories", - }, - }, - type: "object", - required: ["id", "email", "categories"], - title: "UserPublic", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + email: { + type: 'string', + format: 'email', + title: 'Email' + }, + categories: { + items: { + '$ref': '#/components/schemas/CategoryDTO' + }, + type: 'array', + title: 'Categories' + } + }, + type: 'object', + required: ['id', 'email', 'categories'], + title: 'UserPublic' } as const; export const UserQuestionMiniDTOSchema = { - properties: { - id: { - type: "integer", - title: "Id", - }, - question: { - type: "string", - title: "Question", - }, - answer: { - $ref: "#/components/schemas/AnswerDTO", + properties: { + id: { + type: 'integer', + title: 'Id' + }, + question: { + type: 'string', + title: 'Question' + }, + answer: { + '$ref': '#/components/schemas/AnswerDTO' + } }, - }, - type: "object", - required: ["id", "question", "answer"], - title: "UserQuestionMiniDTO", + type: 'object', + required: ['id', 'question', 'answer'], + title: 'UserQuestionMiniDTO' } as const; export const ValidationErrorSchema = { - properties: { - loc: { - items: { - anyOf: [ - { - type: "string", - }, - { - type: "integer", - }, - ], - }, - type: "array", - title: "Location", - }, - msg: { - type: "string", - title: "Message", - }, - type: { - type: "string", - title: "Error Type", - }, - }, - type: "object", - required: ["loc", "msg", "type"], - title: "ValidationError", -} as const; + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { + type: 'string', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } + }, + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' +} as const; \ No newline at end of file diff --git a/frontend/client/services.gen.ts b/frontend/client/services.gen.ts index 39abc72b..9096bfb5 100644 --- a/frontend/client/services.gen.ts +++ b/frontend/client/services.gen.ts @@ -1,271 +1,195 @@ // This file is auto-generated by @hey-api/openapi-ts -import { - createClient, - createConfig, - type Options, - urlSearchParamsBodySerializer, -} from "./client"; -import type { - AuthGoogleAuthGoogleGetData, - AuthGoogleAuthGoogleGetError, - AuthGoogleAuthGoogleGetResponse, - CreateUserQuestionUserQuestionsPostData, - CreateUserQuestionUserQuestionsPostError, - CreateUserQuestionUserQuestionsPostResponse, - GetCategoriesCategoriesGetError, - GetCategoriesCategoriesGetResponse, - GetEventEventsIdGetData, - GetEventEventsIdGetError, - GetEventEventsIdGetResponse, - GetEventsEventsGetData, - GetEventsEventsGetError, - GetEventsEventsGetResponse, - GetUserAuthSessionGetData, - GetUserAuthSessionGetError, - GetUserAuthSessionGetResponse, - GetUserQuestionsUserQuestionsGetData, - GetUserQuestionsUserQuestionsGetError, - GetUserQuestionsUserQuestionsGetResponse, - GetUserQuestionUserQuestionsIdGetData, - GetUserQuestionUserQuestionsIdGetError, - GetUserQuestionUserQuestionsIdGetResponse, - LogInAuthLoginPostData, - LogInAuthLoginPostError, - LogInAuthLoginPostResponse, - LoginGoogleAuthLoginGoogleGetError, - LoginGoogleAuthLoginGoogleGetResponse, - LogoutAuthLogoutGetError, - LogoutAuthLogoutGetResponse, - SignUpAuthSignupPostData, - SignUpAuthSignupPostError, - SignUpAuthSignupPostResponse, - UpdateProfileProfilePutData, - UpdateProfileProfilePutError, - UpdateProfileProfilePutResponse, -} from "./types.gen"; +import { createClient, createConfig, type Options, urlSearchParamsBodySerializer } from './client'; +import type { SignUpAuthSignupPostData, SignUpAuthSignupPostError, SignUpAuthSignupPostResponse, LogInAuthLoginPostData, LogInAuthLoginPostError, LogInAuthLoginPostResponse, LoginGoogleAuthLoginGoogleGetError, LoginGoogleAuthLoginGoogleGetResponse, AuthGoogleAuthGoogleGetData, AuthGoogleAuthGoogleGetError, AuthGoogleAuthGoogleGetResponse, GetUserAuthSessionGetData, GetUserAuthSessionGetError, GetUserAuthSessionGetResponse, LogoutAuthLogoutGetError, LogoutAuthLogoutGetResponse, RequestPasswordResetAuthPasswordResetPostData, RequestPasswordResetAuthPasswordResetPostError, RequestPasswordResetAuthPasswordResetPostResponse, CompletePasswordResetAuthPasswordResetPutData, CompletePasswordResetAuthPasswordResetPutError, CompletePasswordResetAuthPasswordResetPutResponse, ChangePasswordAuthChangePasswordPutData, ChangePasswordAuthChangePasswordPutError, ChangePasswordAuthChangePasswordPutResponse, GetCategoriesCategoriesGetError, GetCategoriesCategoriesGetResponse, UpdateProfileProfilePutData, UpdateProfileProfilePutError, UpdateProfileProfilePutResponse, GetEventsEventsGetData, GetEventsEventsGetError, GetEventsEventsGetResponse, GetEventEventsIdGetData, GetEventEventsIdGetError, GetEventEventsIdGetResponse, GetEventNotesEventsIdNotesGetData, GetEventNotesEventsIdNotesGetError, GetEventNotesEventsIdNotesGetResponse, ReadEventEventsIdReadPostData, ReadEventEventsIdReadPostError, ReadEventEventsIdReadPostResponse, GetUserQuestionsUserQuestionsGetData, GetUserQuestionsUserQuestionsGetError, GetUserQuestionsUserQuestionsGetResponse, CreateUserQuestionUserQuestionsPostData, CreateUserQuestionUserQuestionsPostError, CreateUserQuestionUserQuestionsPostResponse, GetUserQuestionUserQuestionsIdGetData, GetUserQuestionUserQuestionsIdGetError, GetUserQuestionUserQuestionsIdGetResponse, GetAllNotesNotesGetData, GetAllNotesNotesGetError, GetAllNotesNotesGetResponse, CreateNoteNotesPostData, CreateNoteNotesPostError, CreateNoteNotesPostResponse, UpdateNoteNotesIdPutData, UpdateNoteNotesIdPutError, UpdateNoteNotesIdPutResponse, DeleteNoteNotesIdDeleteData, DeleteNoteNotesIdDeleteError, DeleteNoteNotesIdDeleteResponse, GetPointNotesPointsIdNotesGetData, GetPointNotesPointsIdNotesGetError, GetPointNotesPointsIdNotesGetResponse } from './types.gen'; export const client = createClient(createConfig()); /** * Sign Up */ -export const signUpAuthSignupPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - SignUpAuthSignupPostResponse, - SignUpAuthSignupPostError, - ThrowOnError - >({ +export const signUpAuthSignupPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/auth/signup", - }); -}; + url: '/auth/signup' +}); }; /** * Log In */ -export const logInAuthLoginPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - LogInAuthLoginPostResponse, - LogInAuthLoginPostError, - ThrowOnError - >({ +export const logInAuthLoginPost = (options: Options) => { return (options?.client ?? client).post({ ...options, ...urlSearchParamsBodySerializer, headers: { - "Content-Type": "application/x-www-form-urlencoded", - ...options?.headers, + 'Content-Type': 'application/x-www-form-urlencoded', + ...options?.headers }, - url: "/auth/login", - }); -}; + url: '/auth/login' +}); }; /** * Login Google */ -export const loginGoogleAuthLoginGoogleGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - LoginGoogleAuthLoginGoogleGetResponse, - LoginGoogleAuthLoginGoogleGetError, - ThrowOnError - >({ +export const loginGoogleAuthLoginGoogleGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/login/google", - }); -}; + url: '/auth/login/google' +}); }; /** * Auth Google */ -export const authGoogleAuthGoogleGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - AuthGoogleAuthGoogleGetResponse, - AuthGoogleAuthGoogleGetError, - ThrowOnError - >({ +export const authGoogleAuthGoogleGet = (options: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/google", - }); -}; + url: '/auth/google' +}); }; /** * Get User */ -export const getUserAuthSessionGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - GetUserAuthSessionGetResponse, - GetUserAuthSessionGetError, - ThrowOnError - >({ +export const getUserAuthSessionGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/session", - }); -}; + url: '/auth/session' +}); }; /** * Logout */ -export const logoutAuthLogoutGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - LogoutAuthLogoutGetResponse, - LogoutAuthLogoutGetError, - ThrowOnError - >({ +export const logoutAuthLogoutGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/auth/logout", - }); -}; + url: '/auth/logout' +}); }; + +/** + * Request Password Reset + */ +export const requestPasswordResetAuthPasswordResetPost = (options: Options) => { return (options?.client ?? client).post({ + ...options, + url: '/auth/password-reset' +}); }; + +/** + * Complete Password Reset + */ +export const completePasswordResetAuthPasswordResetPut = (options: Options) => { return (options?.client ?? client).put({ + ...options, + url: '/auth/password-reset' +}); }; + +/** + * Change Password + */ +export const changePasswordAuthChangePasswordPut = (options: Options) => { return (options?.client ?? client).put({ + ...options, + url: '/auth/change-password' +}); }; /** * Get Categories */ -export const getCategoriesCategoriesGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - GetCategoriesCategoriesGetResponse, - GetCategoriesCategoriesGetError, - ThrowOnError - >({ +export const getCategoriesCategoriesGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/categories/", - }); -}; + url: '/categories/' +}); }; /** * Update Profile */ -export const updateProfileProfilePut = ( - options: Options, -) => { - return (options?.client ?? client).put< - UpdateProfileProfilePutResponse, - UpdateProfileProfilePutError, - ThrowOnError - >({ +export const updateProfileProfilePut = (options: Options) => { return (options?.client ?? client).put({ ...options, - url: "/profile/", - }); -}; + url: '/profile/' +}); }; /** * Get Events */ -export const getEventsEventsGet = ( - options?: Options, -) => { - return (options?.client ?? client).get< - GetEventsEventsGetResponse, - GetEventsEventsGetError, - ThrowOnError - >({ +export const getEventsEventsGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/events/", - }); -}; + url: '/events/' +}); }; /** * Get Event */ -export const getEventEventsIdGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - GetEventEventsIdGetResponse, - GetEventEventsIdGetError, - ThrowOnError - >({ +export const getEventEventsIdGet = (options: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/events/:id' +}); }; + +/** + * Get Event Notes + */ +export const getEventNotesEventsIdNotesGet = (options: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/events/:id/notes' +}); }; + +/** + * Read Event + */ +export const readEventEventsIdReadPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/events/:id", - }); -}; + url: '/events/:id/read' +}); }; /** * Get User Questions */ -export const getUserQuestionsUserQuestionsGet = < - ThrowOnError extends boolean = false, ->( - options?: Options, -) => { - return (options?.client ?? client).get< - GetUserQuestionsUserQuestionsGetResponse, - GetUserQuestionsUserQuestionsGetError, - ThrowOnError - >({ +export const getUserQuestionsUserQuestionsGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/user-questions/", - }); -}; + url: '/user-questions/' +}); }; /** * Create User Question */ -export const createUserQuestionUserQuestionsPost = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).post< - CreateUserQuestionUserQuestionsPostResponse, - CreateUserQuestionUserQuestionsPostError, - ThrowOnError - >({ +export const createUserQuestionUserQuestionsPost = (options: Options) => { return (options?.client ?? client).post({ ...options, - url: "/user-questions/", - }); -}; + url: '/user-questions/' +}); }; /** * Get User Question */ -export const getUserQuestionUserQuestionsIdGet = < - ThrowOnError extends boolean = false, ->( - options: Options, -) => { - return (options?.client ?? client).get< - GetUserQuestionUserQuestionsIdGetResponse, - GetUserQuestionUserQuestionsIdGetError, - ThrowOnError - >({ +export const getUserQuestionUserQuestionsIdGet = (options: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/user-questions/:id' +}); }; + +/** + * Get All Notes + */ +export const getAllNotesNotesGet = (options?: Options) => { return (options?.client ?? client).get({ + ...options, + url: '/notes/' +}); }; + +/** + * Create Note + */ +export const createNoteNotesPost = (options: Options) => { return (options?.client ?? client).post({ + ...options, + url: '/notes/' +}); }; + +/** + * Update Note + */ +export const updateNoteNotesIdPut = (options: Options) => { return (options?.client ?? client).put({ + ...options, + url: '/notes/:id' +}); }; + +/** + * Delete Note + */ +export const deleteNoteNotesIdDelete = (options: Options) => { return (options?.client ?? client).delete({ + ...options, + url: '/notes/:id' +}); }; + +/** + * Get Point Notes + */ +export const getPointNotesPointsIdNotesGet = (options?: Options) => { return (options?.client ?? client).get({ ...options, - url: "/user-questions/:id", - }); -}; + url: '/points/:id/notes' +}); }; \ No newline at end of file diff --git a/frontend/client/types.gen.ts b/frontend/client/types.gen.ts index 85a6f1a4..32ef05b3 100644 --- a/frontend/client/types.gen.ts +++ b/frontend/client/types.gen.ts @@ -1,208 +1,351 @@ // This file is auto-generated by @hey-api/openapi-ts export type AnalysisDTO = { - id: number; - category: CategoryDTO; - content: string; + id: number; + category: CategoryDTO; + content: string; }; export type AnswerDTO = { - id: number; - points: Array; + id: number; + points: Array; +}; + +export type ArticleDTO = { + id: number; + title: string; + summary: string; + body: string; + url: string; + source: ArticleSource; + date: string; + image_url: string; }; +export type ArticleSource = 'CNA' | 'GUARDIAN'; + export type Body_log_in_auth_login_post = { - grant_type?: string | null; - username: string; - password: string; - scope?: string; - client_id?: string | null; - client_secret?: string | null; + grant_type?: (string | null); + username: string; + password: string; + scope?: string; + client_id?: (string | null); + client_secret?: (string | null); }; export type CategoryDTO = { - id: number; - name: string; + id: number; + name: string; }; export type CreateUserQuestion = { - question: string; + question: string; }; export type EventDTO = { - id: number; - title: string; - description: string; - is_singapore: boolean; - date: string; - categories: Array; - analysises: Array; - gp_questions: Array; + id: number; + title: string; + description: string; + is_singapore: boolean; + date: string; + categories: Array; + original_article: ArticleDTO; + reads: Array; + analysises: Array; + gp_questions: Array; }; export type EventIndexResponse = { - total_count: number; - count: number; - data: Array; + total_count: number; + count: number; + data: Array; }; export type GPQuestionDTO = { - id: number; - question: string; - is_llm_generated: boolean; - categories: Array; + id: number; + question: string; + is_llm_generated: boolean; + categories: Array; }; export type HTTPValidationError = { - detail?: Array; + detail?: Array; }; export type MiniEventDTO = { - id: number; - title: string; - description: string; - is_singapore: boolean; - date: string; - categories: Array; + id: number; + title: string; + description: string; + is_singapore: boolean; + date: string; + categories: Array; + original_article: ArticleDTO; + reads: Array; +}; + +export type NoteCreate = { + content: string; + start_index: number; + end_index: number; + parent_id: number; + parent_type: NoteType; +}; + +export type NoteDTO = { + id: number; + content: string; + start_index: number; + end_index: number; + parent_id: number; + parent_type: NoteType; +}; + +export type NoteType = 'event' | 'article' | 'point'; + +export type NoteUpdate = { + content: string; + start_index: number; + end_index: number; +}; + +export type PasswordResetCompleteData = { + password: string; + confirm_password: string; +}; + +export type PasswordResetRequestData = { + email: string; }; export type PointMiniDTO = { - id: number; - title: string; - body: string; - events: Array; + id: number; + title: string; + body: string; + events: Array; }; export type ProfileUpdate = { - category_ids: Array; + category_ids: Array<(number)>; +}; + +export type ReadDTO = { + first_read: string; + last_read: string; }; export type SignUpData = { - email: string; - password: string; + email: string; + password: string; }; export type Token = { - access_token: string; - token_type: string; - user: UserPublic; + access_token: string; + token_type: string; + user: UserPublic; }; export type UserPublic = { - id: number; - email: string; - categories: Array; + id: number; + email: string; + categories: Array; }; export type UserQuestionMiniDTO = { - id: number; - question: string; - answer: AnswerDTO; + id: number; + question: string; + answer: AnswerDTO; }; export type ValidationError = { - loc: Array; - msg: string; - type: string; + loc: Array<(string | number)>; + msg: string; + type: string; }; export type SignUpAuthSignupPostData = { - body: SignUpData; + body: SignUpData; }; -export type SignUpAuthSignupPostResponse = unknown; +export type SignUpAuthSignupPostResponse = (unknown); -export type SignUpAuthSignupPostError = HTTPValidationError; +export type SignUpAuthSignupPostError = (HTTPValidationError); export type LogInAuthLoginPostData = { - body: Body_log_in_auth_login_post; + body: Body_log_in_auth_login_post; }; -export type LogInAuthLoginPostResponse = Token; +export type LogInAuthLoginPostResponse = (Token); -export type LogInAuthLoginPostError = HTTPValidationError; +export type LogInAuthLoginPostError = (HTTPValidationError); -export type LoginGoogleAuthLoginGoogleGetResponse = unknown; +export type LoginGoogleAuthLoginGoogleGetResponse = (unknown); export type LoginGoogleAuthLoginGoogleGetError = unknown; export type AuthGoogleAuthGoogleGetData = { - query: { - code: string; - }; + query: { + code: string; + }; }; -export type AuthGoogleAuthGoogleGetResponse = unknown; +export type AuthGoogleAuthGoogleGetResponse = (unknown); -export type AuthGoogleAuthGoogleGetError = HTTPValidationError; +export type AuthGoogleAuthGoogleGetError = (HTTPValidationError); export type GetUserAuthSessionGetData = unknown; -export type GetUserAuthSessionGetResponse = UserPublic; +export type GetUserAuthSessionGetResponse = (UserPublic); -export type GetUserAuthSessionGetError = HTTPValidationError; +export type GetUserAuthSessionGetError = (HTTPValidationError); -export type LogoutAuthLogoutGetResponse = unknown; +export type LogoutAuthLogoutGetResponse = (unknown); export type LogoutAuthLogoutGetError = unknown; -export type GetCategoriesCategoriesGetResponse = Array; +export type RequestPasswordResetAuthPasswordResetPostData = { + body: PasswordResetRequestData; +}; + +export type RequestPasswordResetAuthPasswordResetPostResponse = (unknown); + +export type RequestPasswordResetAuthPasswordResetPostError = (HTTPValidationError); + +export type CompletePasswordResetAuthPasswordResetPutData = { + body: PasswordResetCompleteData; + query: { + code: string; + }; +}; + +export type CompletePasswordResetAuthPasswordResetPutResponse = (unknown); + +export type CompletePasswordResetAuthPasswordResetPutError = (HTTPValidationError); + +export type ChangePasswordAuthChangePasswordPutData = { + body: PasswordResetCompleteData; +}; + +export type ChangePasswordAuthChangePasswordPutResponse = (unknown); + +export type ChangePasswordAuthChangePasswordPutError = (HTTPValidationError); + +export type GetCategoriesCategoriesGetResponse = (Array); export type GetCategoriesCategoriesGetError = unknown; export type UpdateProfileProfilePutData = { - body: ProfileUpdate; + body: ProfileUpdate; }; -export type UpdateProfileProfilePutResponse = UserPublic; +export type UpdateProfileProfilePutResponse = (UserPublic); -export type UpdateProfileProfilePutError = HTTPValidationError; +export type UpdateProfileProfilePutError = (HTTPValidationError); export type GetEventsEventsGetData = { - query?: { - category_ids?: Array | null; - end_date?: string | null; - limit?: number | null; - offset?: number | null; - start_date?: string | null; - }; + query?: { + category_ids?: (Array<(number)> | null); + end_date?: (string | null); + limit?: (number | null); + offset?: (number | null); + start_date?: (string | null); + }; }; -export type GetEventsEventsGetResponse = EventIndexResponse; +export type GetEventsEventsGetResponse = (EventIndexResponse); -export type GetEventsEventsGetError = HTTPValidationError; +export type GetEventsEventsGetError = (HTTPValidationError); export type GetEventEventsIdGetData = { - query: { - id: number; - }; + query: { + id: number; + }; }; -export type GetEventEventsIdGetResponse = EventDTO; +export type GetEventEventsIdGetResponse = (EventDTO); + +export type GetEventEventsIdGetError = (HTTPValidationError); + +export type GetEventNotesEventsIdNotesGetData = { + query: { + id: number; + }; +}; -export type GetEventEventsIdGetError = HTTPValidationError; +export type GetEventNotesEventsIdNotesGetResponse = (Array); + +export type GetEventNotesEventsIdNotesGetError = (HTTPValidationError); + +export type ReadEventEventsIdReadPostData = { + query: { + id: number; + }; +}; + +export type ReadEventEventsIdReadPostResponse = (unknown); + +export type ReadEventEventsIdReadPostError = (HTTPValidationError); export type GetUserQuestionsUserQuestionsGetData = unknown; -export type GetUserQuestionsUserQuestionsGetResponse = - Array; +export type GetUserQuestionsUserQuestionsGetResponse = (Array); -export type GetUserQuestionsUserQuestionsGetError = HTTPValidationError; +export type GetUserQuestionsUserQuestionsGetError = (HTTPValidationError); export type CreateUserQuestionUserQuestionsPostData = { - body: CreateUserQuestion; + body: CreateUserQuestion; }; -export type CreateUserQuestionUserQuestionsPostResponse = UserQuestionMiniDTO; +export type CreateUserQuestionUserQuestionsPostResponse = (UserQuestionMiniDTO); -export type CreateUserQuestionUserQuestionsPostError = HTTPValidationError; +export type CreateUserQuestionUserQuestionsPostError = (HTTPValidationError); export type GetUserQuestionUserQuestionsIdGetData = { - query: { - id: number; - }; + query: { + id: number; + }; }; -export type GetUserQuestionUserQuestionsIdGetResponse = unknown; +export type GetUserQuestionUserQuestionsIdGetResponse = (unknown); + +export type GetUserQuestionUserQuestionsIdGetError = (HTTPValidationError); + +export type GetAllNotesNotesGetData = unknown; + +export type GetAllNotesNotesGetResponse = (Array); + +export type GetAllNotesNotesGetError = (HTTPValidationError); + +export type CreateNoteNotesPostData = { + body: NoteCreate; +}; + +export type CreateNoteNotesPostResponse = (NoteDTO); + +export type CreateNoteNotesPostError = (HTTPValidationError); + +export type UpdateNoteNotesIdPutData = { + body: NoteUpdate; + query: { + id: number; + }; +}; + +export type UpdateNoteNotesIdPutResponse = (NoteDTO); + +export type UpdateNoteNotesIdPutError = (HTTPValidationError); + +export type DeleteNoteNotesIdDeleteData = { + query: { + id: number; + }; +}; + +export type DeleteNoteNotesIdDeleteResponse = (unknown); + +export type DeleteNoteNotesIdDeleteError = (HTTPValidationError); + +export type GetPointNotesPointsIdNotesGetData = unknown; + +export type GetPointNotesPointsIdNotesGetResponse = (unknown); -export type GetUserQuestionUserQuestionsIdGetError = HTTPValidationError; +export type GetPointNotesPointsIdNotesGetError = (HTTPValidationError); \ No newline at end of file