2024-01-21 20:28:37 -05:00
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
2024-01-21 23:51:15 -05:00
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
}
2024-01-21 23:51:15 -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
2024-02-12 00:39:15 -05:00
// 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
2024-02-12 16:00:55 -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.
2024-03-24 16:03:31 -04:00
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
2024-02-12 16:00:55 -05:00
type serviceType = 'jellyfin' | 'youtube-music'
2024-03-24 16:03:31 -04:00
type ConnectionInfo = {
id : string
userId : string
} & (
| {
type : 'jellyfin'
serviceInfo : Jellyfin.SerivceInfo
tokens : Jellyfin.Tokens
}
| {
type : 'youtube-music'
serviceInfo : YouTubeMusic.SerivceInfo
tokens : YouTubeMusic.Tokens
}
)
interface Connection {
getRecommendations : ( ) = > Promise < MediaItem [ ] >
getConnectionInfo : ( ) = > Promise < ConnectionInfo >
2024-03-25 12:29:22 -04:00
search : ( searchTerm : string ) = > Promise < MediaItem [ ] >
2024-03-24 16:03:31 -04:00
}
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
interface MediaItem {
2024-02-04 01:01:37 -05:00
type : 'song' | 'album' | 'playlist' | 'artist'
2024-02-03 02:47:23 -05:00
id : string
name : string
thumbnail? : string
}
interface Song extends MediaItem {
2024-03-24 16:03:31 -04:00
connection : {
id : string
type : serviceType
}
2024-02-04 01:01:37 -05:00
type : 'song'
2024-03-06 21:13:12 -05:00
duration? : number
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
}
// audio: string <--- Because of youtube these will potentially expire. They are also not needed until a user requests that song, so instead fetch them as needed
// video?: string
releaseDate? : string
2024-02-03 02:47:23 -05:00
}
interface Album extends MediaItem {
2024-03-24 16:03:31 -04:00
connection : {
id : string
type : serviceType
}
2024-02-04 01:01:37 -05:00
type : 'album'
2024-03-06 21:13:12 -05:00
duration? : number
2024-02-28 03:03:40 -05:00
artists ? : {
2024-03-08 01:23:24 -05:00
// 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
}
2024-02-28 03:03:40 -05:00
// IMPORTANT: This interface is for Lazuli created and stored playlists. Use service-specific interfaces when pulling playlists from services
2024-02-03 02:47:23 -05:00
interface Playlist extends MediaItem {
2024-02-04 01:01:37 -05:00
type : 'playlist'
2024-02-03 02:47:23 -05:00
description? : string
2024-02-28 03:03:40 -05:00
items : {
connectionId : string
id : string
} [ ]
2024-02-03 02:47:23 -05:00
}
2024-02-04 01:01:37 -05:00
interface Artist extends MediaItem {
type : 'artist'
2024-02-03 02:47:23 -05:00
}
2024-02-02 03:05:42 -05:00
namespace Jellyfin {
// The jellyfin API will not always return the data it says it will, for example /Users/AuthenticateByName says it will
// retrun the ServerName, it wont. This must be fetched from /System/Info.
// So, ONLY DEFINE THE INTERFACES FOR DATA THAT IS GARUNTEED TO BE RETURNED (unless the data value itself is inherently optional)
2024-03-24 16:03:31 -04:00
type SerivceInfo = {
2024-02-22 00:36:44 -05:00
userId : string
2024-03-24 16:03:31 -04:00
urlOrigin : string
username? : string
serverName? : string
2024-02-12 17:54:29 -05:00
}
2024-03-24 16:03:31 -04:00
type Tokens = {
accessToken : string
2024-02-04 01:01:37 -05:00
}
2024-01-29 12:29:32 -05:00
}
2024-02-20 12:24:48 -05:00
namespace YouTubeMusic {
2024-03-24 16:03:31 -04:00
type SerivceInfo = {
2024-02-22 00:36:44 -05:00
userId : string
2024-03-24 16:03:31 -04:00
username? : string
profilePicture? : string
}
type Tokens = {
accessToken : string
refreshToken : string
expiry : number
2024-02-22 00:36:44 -05:00
}
2024-03-08 01:23:24 -05:00
interface HomeItems {
listenAgain : MediaItem [ ]
quickPicks : MediaItem [ ]
newReleases : MediaItem [ ]
}
2024-02-20 12:24:48 -05:00
}
2024-01-21 20:28:37 -05:00
}
2024-01-21 23:51:15 -05:00
export { }