Files
Lazuli/src/app.d.ts

151 lines
4.4 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'
serviceInfo: Jellyfin.SerivceInfo
tokens: Jellyfin.Tokens
}
| {
type: 'youtube-music'
serviceInfo: YouTubeMusic.SerivceInfo
tokens: YouTubeMusic.Tokens
}
)
interface Connection {
2024-03-27 23:53:59 -04:00
getRecommendations: () => Promise<(Song | Album | Playlist)[]>
getConnectionInfo: () => Promise<ConnectionInfo>
2024-03-27 23:53:59 -04:00
search: (searchTerm: string) => Promise<(Song | Album | Playlist)[]>
}
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: serviceType
}
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
}
// 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
}
2024-03-27 23:53:59 -04:00
type Album = {
connection: {
id: string
type: serviceType
}
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
}
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-03-27 23:53:59 -04:00
type Playlist = {
id: string
name: string
2024-02-04 01:01:37 -05:00
type: 'playlist'
2024-03-27 23:53:59 -04:00
thumbnail?: string
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-03-27 23:53:59 -04:00
type Artist = {
id: string
name: string
2024-02-04 01:01:37 -05:00
type: 'artist'
2024-03-27 23:53:59 -04:00
thumbnail?: string
2024-02-03 02:47:23 -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)
type SerivceInfo = {
2024-02-22 00:36:44 -05:00
userId: string
urlOrigin: string
username?: string
serverName?: string
2024-02-12 17:54:29 -05: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 {
type SerivceInfo = {
2024-02-22 00:36:44 -05:00
userId: string
username?: string
profilePicture?: string
}
type Tokens = {
accessToken: string
refreshToken: string
expiry: number
2024-02-22 00:36:44 -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
}
export {}