Files
website/shared/api-types.ts
limes a9e578d8f4
Some checks failed
Build and Publish Docker Image / Build and Publish (amd64) (push) Has been cancelled
Build and Publish Docker Image / Build and Publish (arm64) (push) Has been cancelled
feat: account pages
2026-08-15 06:09:14 +02:00

129 lines
2.6 KiB
TypeScript

import { z } from 'zod';
export type GetApiAuthMe = {
pid: number;
username: string;
accessLevel: number;
birthday: string;
gender: string;
country: string;
timezone: string;
emailAddress: string;
serverAccessLevel: 'dev' | 'test' | 'prod';
discordId: string | null;
stripeTier: {
subscriptionId: string;
priceId: string;
tierName: string;
tierLevel: string | number;
} | null;
mii: {
imageUrl: string;
name: string;
data: string;
} | null;
};
export type GetApiAuthMeConections = {
pid: number;
discord: {
id: string;
username: string;
discriminator: string;
avatar: string | null;
avatarUrl: string | null;
} | null;
};
export type ProgressItem = {
title: string;
githubUrl?: string;
completion: number;
tasks: Array<{
status: 'completed' | 'inprogress' | 'notstarted';
title: string;
}>;
};
export type GetProgress = {
donations: {
currentCents: number;
goalCents: number;
};
completion: number;
items: ProgressItem[];
};
export type ApiAuthLogin = {
accessToken: string;
refreshToken: string;
};
export type ApiAccountDiscordLink = {
url: string;
};
export type ApiAccountCheckoutLink = {
url: string;
};
export type TierItem = {
priceId: string;
tierLevel: number;
priceCents: number;
thumbnailUrl: string | null;
name: string;
description: string | null;
perks: {
discordRead: boolean;
beta: boolean;
};
};
export type ApiAccountTiers = {
tiers: TierItem[];
};
export const LoginSchema = z.object({
username: z.string(),
password: z.string()
});
export type ApiAuthLoginRequest = z.infer<typeof LoginSchema>;
export const RegisterSchema = z.object({
email: z.email(),
username: z.string(),
miiName: z.string(),
password: z.string(),
captchaResponse: z.string().optional()
});
export type ApiAuthRegisterRequest = z.infer<typeof RegisterSchema>;
export const AccountUpdateSchema = z.object({
mii: z.object({
name: z.string(),
primary: z.enum(['Y', 'N']),
data: z.string()
}).optional(),
environment: z.enum(['prod', 'test', 'dev']).optional()
});
export type ApiAccountUpdateRequest = z.infer<typeof AccountUpdateSchema>;
export const ResetPasswordSchema = z.object({
password: z.string(),
passwordConfirm: z.string(),
resetToken: z.string()
});
export type ApiAuthResetPasswordRequest = z.infer<typeof ResetPasswordSchema>;
export const ForgotPasswordSchema = z.object({
emailOrPassword: z.string(),
captchaResponse: z.string().optional()
});
export type ApiAuthForgotPasswordRequest = z.infer<typeof ForgotPasswordSchema>;
export const CheckoutSchema = z.object({
priceId: z.string()
});
export type ApiAccountCheckoutRequest = z.infer<typeof CheckoutSchema>;