Files
Lazuli/src/app.d.ts

200 lines
5.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 {
user: User
}
// 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
password?: string
}
2024-01-29 12:29:32 -05:00
type serviceType = 'jellyfin' | 'youtube-music'
2024-02-01 18:10:15 -05:00
interface Service {
type: serviceType
2024-02-01 18:10:15 -05:00
userId: string
urlOrigin: string
}
interface Tokens {
accessToken: string
refreshToken?: string
expiry?: number
}
2024-02-01 18:10:15 -05:00
interface Connection {
id: string
user: User
service: Service
tokens: Tokens
2024-02-01 18:10:15 -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
connectionId: string
serviceType: serviceType
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-04 01:01:37 -05:00
type: 'song'
duration: number
artists: {
id: string
name: string
}[]
2024-02-03 02:47:23 -05:00
albumId?: string
audio: string
video?: string
releaseDate: string
}
interface Album extends MediaItem {
2024-02-04 01:01:37 -05:00
type: 'album'
duration: number
albumArtists: {
id: string
name: string
}[]
artists: {
id: string
name: string
}[]
2024-02-03 02:47:23 -05:00
releaseDate: string
}
interface Playlist extends MediaItem {
2024-02-04 01:01:37 -05:00
type: 'playlist'
duration: number
2024-02-03 02:47:23 -05:00
description?: string
}
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)
interface JFService extends Service {
type: 'jellyfin'
}
interface JFTokens implements Tokens {
accessToken: string
}
interface JFConnection extends Connection {
service: JFService
tokens: JFTokens
}
interface AuthData {
User: {
Id: string
}
AccessToken: string
}
interface User {
Name: string
Id: 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-03 02:47:23 -05:00
namespace YouTubeMusic {
interface YTService extends Service {
type: 'youtube-music'
}
interface YTTokens implements Tokens {
accessToken: string,
refreshToken: string,
expiry: number
2024-02-03 02:47:23 -05:00
}
2024-01-29 12:29:32 -05:00
2024-02-03 02:47:23 -05:00
interface YTConnection extends Connection {
service: YTService
tokens: YTTokens
2024-02-03 02:47:23 -05:00
}
2024-01-29 12:29:32 -05:00
}
2024-01-21 20:28:37 -05:00
}
export {}