ls-deno/types.ts
2022-11-10 16:39:48 -06:00

84 lines
1.7 KiB
TypeScript

export interface Identifiable {
id: string;
}
export interface Created {
createdAt: Date;
}
export interface Updated {
updatedAt: Date;
}
export type Timestamped = Created & Updated;
export interface Team extends Identifiable, Timestamped {
displayName: string;
}
export interface User extends Identifiable, Timestamped {
username: string;
passwordDigest: string;
displayName?: string;
}
export type PublicUser = Pick<
User,
| "displayName"
| "username"
| keyof Identifiable
>;
export interface Note extends Identifiable, Timestamped {
content: string;
userId: User["id"] | null;
userUsername?: User["username"];
userDisplayName?: User["displayName"];
}
type IdentifierFor<T extends Identifiable> = T["id"];
export interface Token extends Created {
bytes?: Uint8Array;
digest: Uint8Array;
userId: IdentifierFor<User>;
data: Record<string, unknown> | null;
}
/** 32 bytes base64-encoded */
export type TokenDigest = string;
export interface ContextState extends Record<string, unknown> {
user?: PublicUser;
something?: string;
}
export type TeamUserStatus =
| "invited"
| "accepted"
| "manager"
| "owner"
| "removed"
| "left";
export interface TeamUser {
userId: IdentifierFor<User>;
teamId: IdentifierFor<Team>;
status: TeamUserStatus;
}
export interface Playlist extends Identifiable, Timestamped {
displayName: string;
teamId: IdentifierFor<Team>;
}
export interface Display extends Identifiable, Timestamped {
displayName: string;
teamId: IdentifierFor<Team>;
playlistId: IdentifierFor<Playlist>;
isFrozen: boolean;
isBlanked: boolean;
currentSongIndex: number;
currentVerseIndex: number;
}
export type Ungenerated<T> = Omit<T, keyof Identifiable | keyof Timestamped>;