you know what let's just change frontend framework again

This commit is contained in:
sam 2024-11-24 15:55:29 +01:00
parent c8cd483d20
commit 0d47f1fb01
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
115 changed files with 4407 additions and 10824 deletions

View file

@ -0,0 +1,23 @@
import type { User } from "./user";
export type AuthResponse = {
user: User;
token: string;
expires_at: string;
};
export type CallbackResponse = {
has_account: boolean;
ticket?: string;
remote_username?: string;
user?: User;
token?: string;
expires_at?: string;
};
export type AuthUrls = {
email_enabled: boolean;
discord?: string;
google?: string;
tumblr?: string;
};

View file

@ -0,0 +1,4 @@
export * from "./meta";
export * from "./user";
export * from "./member";
export * from "./auth";

View file

@ -0,0 +1,9 @@
import type { Field, PartialMember, PartialUser, PrideFlag } from "./user";
export type Member = PartialMember & {
fields: Field[];
flags: PrideFlag[];
links: string[];
user: PartialUser;
};

View file

@ -0,0 +1,19 @@
export type Meta = {
repository: string;
version: string;
hash: string;
users: {
total: number;
active_month: number;
active_week: number;
active_day: number;
};
members: number;
limits: Limits;
};
export type Limits = {
member_count: number;
bio_length: number;
custom_preferences: number;
};

View file

@ -0,0 +1,139 @@
export type PartialUser = {
id: string;
username: string;
display_name: string | null;
avatar_url: string | null;
custom_preferences: Record<string, CustomPreference>;
};
export type User = PartialUser & {
bio: string | null;
member_title: string | null;
links: string[];
names: FieldEntry[];
pronouns: Pronoun[];
fields: Field[];
flags: PrideFlag[];
role: "USER" | "MODERATOR" | "ADMIN";
};
export type MeUser = UserWithMembers & {
auth_methods: AuthMethod[];
member_list_hidden: boolean;
last_active: string;
last_sid_reroll: string;
};
export type UserWithMembers = User & { members: PartialMember[] };
export type UserWithHiddenFields = User & {
auth_methods?: unknown[];
member_list_hidden: boolean;
last_active: string;
};
export type UserSettings = {
dark_mode: boolean | null;
};
export type PartialMember = {
id: string;
name: string;
display_name: string;
bio: string | null;
avatar_url: string | null;
names: FieldEntry[];
pronouns: Pronoun[];
unlisted: boolean | null;
};
export type FieldEntry = {
value: string;
status: string;
};
export type Pronoun = FieldEntry & { display_text: string | null };
export type Field = {
name: string;
entries: FieldEntry[];
};
export type PrideFlag = {
id: string;
image_url: string;
name: string;
description: string | null;
};
export type AuthMethod = {
id: string;
type: "DISCORD" | "GOOGLE" | "TUMBLR" | "FEDIVERSE" | "EMAIL";
remote_id: string;
remote_username?: string;
};
export type CustomPreference = {
icon: string;
tooltip: string;
muted: boolean;
favourite: boolean;
size: PreferenceSize;
};
export enum PreferenceSize {
Large = "LARGE",
Normal = "NORMAL",
Small = "SMALL",
}
export function mergePreferences(
prefs: Record<string, CustomPreference>,
): Record<string, CustomPreference> {
return Object.assign({}, defaultPreferences, prefs);
}
export const defaultPreferences = Object.freeze({
favourite: {
icon: "heart-fill",
tooltip: "Favourite",
size: PreferenceSize.Large,
muted: false,
favourite: true,
},
okay: {
icon: "hand-thumbs-up",
tooltip: "Okay",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
jokingly: {
icon: "emoji-laughing",
tooltip: "Jokingly",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
friends_only: {
icon: "people",
tooltip: "Friends only",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
avoid: {
icon: "hand-thumbs-down",
tooltip: "Avoid",
size: PreferenceSize.Small,
muted: true,
favourite: false,
},
missing: {
icon: "question-lg",
tooltip: "Unknown (missing)",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
});