Files
Lazuli/src/app.d.ts

193 lines
5.6 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.
2024-01-25 19:50:26 -05:00
interface User {
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 serviceType = 'jellyfin' | 'youtube-music'
2024-02-23 00:53:54 -05:00
type Connection<T extends serviceType> = T extends 'jellyfin' ? Jellyfin.Connection : T extends 'youtube-music' ? YouTubeMusic.Connection : never
2024-02-22 00:36:44 -05: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-02-28 03:03:40 -05:00
connectionId: string
serviceType: serviceType
2024-02-04 01:01:37 -05:00
type: 'song'
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-02-28 03:03:40 -05:00
connectionId: string
serviceType: serviceType
2024-02-04 01:01:37 -05:00
type: 'album'
duration: number
2024-02-28 03:03:40 -05:00
albumArtists?: {
2024-02-04 01:01:37 -05:00
id: string
name: 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
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
}
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-02-23 00:53:54 -05:00
interface Connection {
id: string
2024-02-22 00:36:44 -05:00
userId: string
2024-02-23 00:53:54 -05:00
type: 'jellyfin'
service: {
userId: string
urlOrigin: string
username?: string
serverName?: string
}
tokens: {
accessToken: string
}
2024-02-22 00:36:44 -05:00
}
interface User {
Name: string
Id: string
2024-02-12 17:54:29 -05:00
}
interface AuthData {
User: Jellyfin.User
AccessToken: string
}
interface System {
ServerName: string
}
2024-02-03 02:47:23 -05:00
interface MediaItem {
Name: string
Id: string
2024-02-04 01:01:37 -05:00
Type: 'Audio' | 'MusicAlbum' | 'Playlist' | 'MusicArtist'
2024-02-03 02:47:23 -05:00
ImageTags?: {
Primary?: string
}
}
2024-02-03 02:47:23 -05:00
interface Song extends Jellyfin.MediaItem {
2024-02-04 01:01:37 -05:00
RunTimeTicks: number
2024-02-03 02:47:23 -05:00
ProductionYear: number
Type: 'Audio'
2024-02-04 01:01:37 -05:00
ArtistItems: {
2024-02-03 02:47:23 -05:00
Name: string
Id: string
}[]
Album?: string
AlbumId?: string
AlbumPrimaryImageTag?: string
2024-02-04 01:01:37 -05:00
AlbumArtists: {
2024-02-03 02:47:23 -05:00
Name: string
Id: string
}[]
}
2024-01-29 12:29:32 -05:00
2024-02-03 02:47:23 -05:00
interface Album extends Jellyfin.MediaItem {
2024-02-04 01:01:37 -05:00
RunTimeTicks: number
2024-02-03 02:47:23 -05:00
ProductionYear: number
Type: 'MusicAlbum'
2024-02-04 01:01:37 -05:00
ArtistItems: {
2024-02-03 02:47:23 -05:00
Name: string
Id: string
}[]
2024-02-04 01:01:37 -05:00
AlbumArtists: {
2024-02-03 02:47:23 -05:00
Name: string
Id: string
2024-01-29 12:29:32 -05:00
}[]
}
2024-02-03 02:47:23 -05:00
interface Playlist extends Jellyfin.MediaItem {
2024-02-04 01:01:37 -05:00
RunTimeTicks: number
2024-02-03 02:47:23 -05:00
Type: 'Playlist'
ChildCount: number
}
2024-02-04 01:01:37 -05:00
interface Artist extends Jellyfin.MediaItem {
Type: 'MusicArtist'
}
2024-01-29 12:29:32 -05:00
}
2024-02-20 12:24:48 -05:00
namespace YouTubeMusic {
2024-02-23 00:53:54 -05:00
interface Connection {
id: string
2024-02-22 00:36:44 -05:00
userId: string
2024-02-23 00:53:54 -05:00
type: 'youtube-music'
service: {
userId: string
username?: string
profilePicture?: string
}
tokens: {
accessToken: string
refreshToken: string
expiry: number
}
2024-02-22 00:36:44 -05:00
}
2024-02-20 12:24:48 -05:00
}
2024-01-21 20:28:37 -05:00
}
export {}