v1 feature: added playlists
This commit is contained in:
65
src/model.ts
65
src/model.ts
@@ -95,6 +95,71 @@ export interface AuthResponse {
|
||||
user: User;
|
||||
}
|
||||
|
||||
/**
|
||||
* Playlists
|
||||
*/
|
||||
|
||||
export interface Playlist {
|
||||
id: string;
|
||||
userId: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
isPublic: boolean;
|
||||
createdAt: Date;
|
||||
imageMime?: string;
|
||||
dumpCount?: number;
|
||||
}
|
||||
|
||||
export interface PlaylistWithDumps extends Playlist {
|
||||
dumps: Dump[];
|
||||
}
|
||||
|
||||
export interface PlaylistMembership {
|
||||
playlist: Playlist;
|
||||
hasDump: boolean;
|
||||
}
|
||||
|
||||
export type RawPlaylist = WithStringDate<Playlist>;
|
||||
export type RawPlaylistWithDumps =
|
||||
& Omit<PlaylistWithDumps, "createdAt" | "dumps">
|
||||
& {
|
||||
createdAt: string;
|
||||
dumps: RawDump[];
|
||||
};
|
||||
export type RawPlaylistMembership = { playlist: RawPlaylist; hasDump: boolean };
|
||||
|
||||
export function deserializePlaylist(raw: RawPlaylist): Playlist {
|
||||
return { ...raw, createdAt: new Date(raw.createdAt) };
|
||||
}
|
||||
|
||||
export function deserializePlaylistWithDumps(
|
||||
raw: RawPlaylistWithDumps,
|
||||
): PlaylistWithDumps {
|
||||
return {
|
||||
...raw,
|
||||
createdAt: new Date(raw.createdAt),
|
||||
dumps: raw.dumps.map(deserializeDump),
|
||||
};
|
||||
}
|
||||
|
||||
export function deserializePlaylistMembership(
|
||||
raw: RawPlaylistMembership,
|
||||
): PlaylistMembership {
|
||||
return { playlist: deserializePlaylist(raw.playlist), hasDump: raw.hasDump };
|
||||
}
|
||||
|
||||
export interface CreatePlaylistRequest {
|
||||
title: string;
|
||||
description?: string;
|
||||
isPublic: boolean;
|
||||
}
|
||||
|
||||
export interface UpdatePlaylistRequest {
|
||||
title?: string;
|
||||
description?: string;
|
||||
isPublic?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* API
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user