Files
Lazuli/src/app.d.ts

114 lines
3.2 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 = {
2024-04-03 23:28:38 -04:00
connection: string
2024-03-27 23:53:59 -04:00
id: string
name: string
2024-02-04 01:01:37 -05:00
type: 'song'
2024-03-06 21:13:12 -05:00
duration?: number
2024-03-27 23:53:59 -04:00
thumbnail?: string
2024-02-28 03:03:40 -05:00
artists?: {
2024-02-04 01:01:37 -05:00
id: string
name: string
}[]
2024-02-28 03:03:40 -05:00
album?: {
id: string
name: string
}
2024-04-09 00:10:23 -04:00
createdBy?: {
id: string
name: string
}
2024-02-28 03:03:40 -05:00
releaseDate?: string
2024-02-03 02:47:23 -05:00
}
2024-03-27 23:53:59 -04:00
type Album = {
2024-04-03 23:28:38 -04:00
connection: string
2024-03-27 23:53:59 -04:00
id: string
name: string
2024-02-04 01:01:37 -05:00
type: 'album'
2024-03-06 21:13:12 -05:00
duration?: number
2024-03-27 23:53:59 -04:00
thumbnail?: string
2024-02-28 03:03:40 -05:00
artists?: {
// Album Artists
2024-02-04 01:01:37 -05:00
id: string
name: string
}[]
2024-02-28 03:03:40 -05:00
releaseDate?: string
2024-02-03 02:47:23 -05:00
}
// Need to figure out how to do Artists, maybe just query MusicBrainz?
type Artist = {
2024-04-03 23:28:38 -04:00
connection: string
2024-03-27 23:53:59 -04:00
id: string
name: string
type: 'artist'
2024-03-27 23:53:59 -04:00
thumbnail?: string
2024-02-03 02:47:23 -05:00
}
type Playlist = {
2024-04-03 23:28:38 -04:00
connection: string
2024-03-27 23:53:59 -04:00
id: string
name: string
type: 'playlist'
2024-04-09 00:10:23 -04:00
createdBy?: {
id: string
name: string
}
2024-03-27 23:53:59 -04:00
thumbnail?: string
2024-02-03 02:47:23 -05:00
}
2024-01-21 20:28:37 -05:00
}
export {}