import { Field, InputType, ObjectType } from 'type-graphql'; import { User } from '@/entities/User'; import { VerificationRequest } from '@/types/VerificationRequest'; @InputType() class UserProfileInput { @Field(() => String, { nullable: true, }) firstName?: string; @Field(() => String, { nullable: true, }) lastName?: string; } @InputType() export class SignUpAnonymouslyInput { @Field(() => UserProfileInput, { nullable: true, }) profile?: UserProfileInput; } @ObjectType() export class SignUpAnonymouslyPayload { @Field(() => User) user!: User; @Field(() => String) accessToken?: string; } export const SIGN_UP_ANONYMOUSLY_DEFAULTS = {}; @InputType() export class SignInInput { @Field(() => String, { description: 'Accepts either username or email', }) username!: string; @Field(() => String) password!: string; } @ObjectType() export class SignInResponse { @Field(() => User) user!: User; @Field(() => String) accessToken?: string; } export const SIGN_UP_DEFAULTS = {}; @InputType() export class SignUpInput { @Field(() => String, { nullable: false, }) username!: string; @Field(() => String) password!: string; @Field(() => String) email!: string; } @ObjectType() export class SignUpResponse { @Field(() => User) user!: User; @Field(() => String) accessToken!: string; @Field(() => VerificationRequest, { nullable: true, }) verificationRequested?: VerificationRequest; } export const CHANGE_PASSWORD_DEFAULTS = {}; @InputType() export class ChangePasswordInput { @Field(() => String, { description: 'The old password to ensure is correct.', }) oldPassword!: string; @Field(() => String, { description: 'The new password to store.', }) newPassword!: string; } @ObjectType() export class ChangePasswordPayload { @Field(() => Boolean) success?: boolean; } export const REQUEST_RESET_PASSWORD_DEFAULTS = {}; @InputType() export class RequestResetPasswordInput { @Field(() => String, { description: 'Accepts either username or email', }) username!: string; } @ObjectType() export class RequestResetPasswordPayload { @Field(() => Boolean) success?: boolean; } export const VERIFY_ONE_TIME_PASSWORD_DEFAULTS = {}; @InputType() export class VerifyOneTimePasswordInput { @Field(() => String, { nullable: false, }) otpAttempt!: string; } @ObjectType() export class VerifyOneTimePasswordPayload { @Field(() => Boolean, { description: 'Indicates whether or not the one time password attempt was successful.', }) success!: boolean; } export const REQUEST_ONE_TIME_PASSWORD_DEFAULTS = {}; @InputType() export class RequestOneTimePasswordInput {} @ObjectType() export class RequestOneTimePasswordPayload { @Field(() => Boolean, { description: 'Indicates whether or not the one time password was successfully requested.', }) success!: boolean; } export const CHANGE_PASSWORD_WITH_RESET_PASSWORD_KEY_DEFAULTS = {}; @InputType() export class ChangePasswordWithResetPasswordKeyInput { @Field(() => String, { description: 'The key provided by the user from the reset password link.', }) resetPasswordKey!: string; @Field(() => String, { description: 'The new password to store.', }) newPassword!: string; @Field(() => String, { description: 'accepts either username or email', }) username!: string; } @ObjectType() export class ChangePasswordWithResetPasswordKeyPayload { @Field(() => Boolean) success?: boolean; } @InputType() export class EmailAvailableInput { @Field(() => String, { description: 'The email to check.', }) email!: string; } @ObjectType() export class EmailAvailablePayload { @Field(() => Boolean) available!: boolean; } @ObjectType() export class LogoutResponse { @Field(() => Boolean) success!: boolean; }