Files
Lazuli/src/app.d.ts

134 lines
4.1 KiB
TypeScript
Raw Normal View History

2024-01-21 20:28:37 -05:00
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
2024-01-25 19:50:26 -05:00
interface Locals {
2024-02-23 00:53:54 -05:00
user: Omit<User, 'passwordHash'>
2024-01-25 19:50:26 -05:00
}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
2024-01-25 19:50:26 -05:00
2024-02-04 01:01:37 -05:00
// General Interface Desing tips:
// Use possibly undefined `?:` for when a property is optional, meaning it could be there, or it could be not applicable
// Use possibly null `| null` for when the property is expected to be there but could possbily be explicitly empty
2024-02-04 01:01:37 -05:00
// Do not store data from other services in the database, only the data necessary to fetch whatever you need.
// This avoid syncronization issues. E.g. Store userId, and urlOrigin to fetch the user's name and profile picture.
type User = {
2024-01-25 19:50:26 -05:00
id: string
username: string
2024-02-23 00:53:54 -05:00
passwordHash: string
2024-01-25 19:50:26 -05:00
}
2024-01-29 12:29:32 -05:00
type ConnectionInfo = {
id: string
userId: string
} & ({
type: 'jellyfin'
serverUrl: string
2024-04-09 00:10:23 -04:00
serverName?: string
jellyfinUserId: string
2024-04-09 00:10:23 -04:00
username?: string
} | {
type: 'youtube-music'
youtubeUserId: string
username?: string
profilePicture?: string
})
interface Connection {
public id: string
getRecommendations: () => Promise<(Song | Album | Artist | Playlist)[]>
getConnectionInfo: () => Promise<ConnectionInfo>
search: (searchTerm: string, filter?: 'song' | 'album' | 'artist' | 'playlist') => Promise<(Song | Album | Artist | Playlist)[]>
getAudioStream: (id: string, range: string | null) => Promise<Response>
}
2024-02-04 01:01:37 -05:00
// These Schemas should only contain general info data that is necessary for data fetching purposes.
// They are NOT meant to be stores for large amounts of data, i.e. Don't include the data for every single song the Playlist type.
// Big data should be fetched as needed in the app, these exist to ensure that the info necessary to fetch that data is there.
2024-02-03 02:47:23 -05:00
2024-03-27 23:53:59 -04:00
type Song = {
connection: {
id: string
type: 'jellyfin' | 'youtube-music'
}
id: string
2024-03-27 23:53:59 -04:00
name: string
2024-02-04 01:01:37 -05:00
type: 'song'
duration: number // Seconds
2024-04-25 18:31:29 -04:00
thumbnailUrl: string // Base/maxres url of song, any scaling for performance purposes will be handled by remoteImage endpoint
releaseDate: string // ISOString
2024-04-29 10:14:07 -04:00
artists?: { // Should try to order
2024-02-04 01:01:37 -05:00
id: string
name: string
profilePicture?: string
2024-02-04 01:01:37 -05:00
}[]
2024-02-28 03:03:40 -05:00
album?: {
id: string
name: string
thumbnailUrl?: string
2024-02-28 03:03:40 -05:00
}
2024-04-29 10:14:07 -04:00
uploader?: {
2024-04-09 00:10:23 -04:00
id: string
name: string
profilePicture?: string
2024-04-09 00:10:23 -04:00
}
2024-04-29 10:14:07 -04:00
isVideo: boolean
}
2024-02-03 02:47:23 -05:00
2024-03-27 23:53:59 -04:00
type Album = {
connection: {
id: string
type: 'jellyfin' | 'youtube-music'
}
id: string
2024-03-27 23:53:59 -04:00
name: string
2024-04-25 18:31:29 -04:00
type: 'album'
duration?: number // Seconds
thumbnailUrl: string
artists: { // Should try to order
2024-02-04 01:01:37 -05:00
id: string
name: string
profilePicture?: string
}[] | 'Various Artists'
releaseDate?: string // ISOString
length?: number
2024-02-03 02:47:23 -05:00
}
// Need to figure out how to do Artists, maybe just query MusicBrainz?
type Artist = {
connection: {
id: string
type: 'jellyfin' | 'youtube-music'
}
id: string
2024-03-27 23:53:59 -04:00
name: string
type: 'artist'
profilePicture?: string
2024-02-03 02:47:23 -05:00
}
type Playlist = { // Keep Playlist items seperate from the playlist itself. What's really nice is playlist items can just be an ordered array of Songs
connection: {
id: string
type: 'jellyfin' | 'youtube-music'
}
2024-03-27 23:53:59 -04:00
id: string
name: string
type: 'playlist'
duration: number
thumbnailUrl: string
2024-04-09 00:10:23 -04:00
createdBy?: {
id: string
name: string
profilePicture?: string
2024-04-09 00:10:23 -04:00
}
length: number
2024-02-03 02:47:23 -05:00
}
2024-01-21 20:28:37 -05:00
}
export {}