funkwhale/front/src/types.ts

363 wiersze
6.5 KiB
TypeScript
Czysty Zwykły widok Historia

2022-04-18 08:24:47 +00:00
import type { App } from 'vue'
import type { Store } from 'vuex'
2022-07-04 22:02:39 +00:00
import type { Router } from 'vue-router'
import type { AxiosError } from 'axios'
import type { RootState } from '~/store'
import type { ComponentPublicInstance } from '@vue/runtime-core'
export type FunctionRef = Element | ComponentPublicInstance | null
declare global {
interface Window {
$: JQueryStatic
jQuery: JQueryStatic
}
}
// App structure stuff
2022-04-23 12:35:12 +00:00
export interface InitModuleContext {
app: App
2022-04-30 18:07:40 +00:00
router: Router
store: Store<RootState>
}
2022-04-23 12:35:12 +00:00
export type InitModule = (ctx: InitModuleContext) => void
// Theme stuff
export type Theme = 'auto' | 'light' | 'dark'
export interface ThemeEntry {
icon: string
name: string
key: Theme
}
// Track stuff
2022-07-04 18:17:58 +00:00
export type ContentCategory = 'podcast' | 'music'
2022-05-02 08:25:37 +00:00
export interface Artist {
2022-05-02 08:25:37 +00:00
id: string
2022-07-04 18:17:58 +00:00
fid: string
mbid?: string
2022-05-02 15:06:44 +00:00
name: string
2022-05-02 15:06:44 +00:00
description: Content
cover?: Cover
2022-07-04 18:17:58 +00:00
channel?: Channel
2022-05-02 15:06:44 +00:00
tags: string[]
2022-05-02 08:25:37 +00:00
content_category: ContentCategory
2022-05-02 15:06:44 +00:00
albums: Album[]
2022-07-04 18:17:58 +00:00
tracks_count: number
attributed_to: Actor
is_local: boolean
2022-07-11 00:31:08 +00:00
is_playable: boolean
modification_date?: string
}
export interface Album {
2022-05-02 08:25:37 +00:00
id: string
2022-07-04 18:17:58 +00:00
fid: string
mbid?: string
2022-05-02 15:06:44 +00:00
title: string
description: Content
release_date?: string
cover?: Cover
tags: string[]
artist: Artist
2022-05-02 08:25:37 +00:00
tracks_count: number
2022-05-02 15:06:44 +00:00
tracks: Track[]
2022-07-04 18:17:58 +00:00
is_playable: boolean
is_local: boolean
}
export interface Track {
2022-05-02 08:25:37 +00:00
id: string
2022-07-04 18:17:58 +00:00
fid: string
mbid?: string
2022-05-02 15:06:44 +00:00
title: string
2022-05-02 15:06:44 +00:00
description: Content
cover?: Cover
position?: number
copyright?: string
license?: License
tags: string[]
2022-07-02 23:49:07 +00:00
uploads: Upload[]
2022-05-02 15:06:44 +00:00
album?: Album
artist?: Artist
2022-07-04 18:17:58 +00:00
disc_number: number
listen_url: string
2022-07-04 18:17:58 +00:00
creation_date: string
attributed_to: Actor
is_playable: boolean
is_local: boolean
}
2022-05-02 08:25:37 +00:00
export interface Channel {
id: string
2022-07-04 18:17:58 +00:00
uuid: string
2022-05-02 08:25:37 +00:00
artist?: Artist
2022-07-04 18:17:58 +00:00
actor: Actor
attributed_to: Actor
url?: string
rss_url: string
subscriptions_count: number
downloads_count: number
2022-07-11 00:31:08 +00:00
content_category: ContentCategory
2022-07-04 18:17:58 +00:00
}
2022-07-04 18:56:46 +00:00
export type PrivacyLevel = 'everyone' | 'instance' | 'me'
2022-07-04 18:17:58 +00:00
export interface Library {
id: string
uuid: string
fid?: string
name: string
actor: Actor
uploads_count: number
size: number
description: string
2022-07-04 18:56:46 +00:00
privacy_level: PrivacyLevel
2022-07-04 18:17:58 +00:00
creation_date: string
follow?: LibraryFollow
latest_scan: LibraryScan
}
2022-07-04 18:56:46 +00:00
export type ImportStatus = 'scanning' | 'pending' | 'finished' | 'errored' | 'draft' | 'skipped'
2022-07-04 18:17:58 +00:00
export interface LibraryScan {
processed_files: number
total_files: number
2022-07-04 18:56:46 +00:00
status: ImportStatus
2022-07-04 18:17:58 +00:00
errored_files: number
modification_date: string
}
export interface LibraryFollow {
uuid: string
approved: boolean
2022-07-19 02:09:16 +00:00
// TODO (wvffle): Check if it's not added only on frontend side
isLoading?: boolean
2022-05-02 08:25:37 +00:00
}
2022-05-02 15:06:44 +00:00
export interface Cover {
uuid: string
2022-07-04 18:17:58 +00:00
urls: {
original: string
medium_square_crop: string
}
2022-05-02 15:06:44 +00:00
}
export interface License {
code: string
name: string
url: string
}
2022-06-30 22:07:54 +00:00
export interface Playlist {
id: string
name: string
2022-07-05 22:34:11 +00:00
modification_date: string
user: User
privacy_level: PrivacyLevel
tracks_count: number
duration: number
2022-07-11 00:31:08 +00:00
album_covers: string[]
2022-07-05 22:34:11 +00:00
is_playable: boolean
}
export interface PlaylistTrack {
track: Track
position?: number
}
export interface Radio {
id: string
name: string
user: User
2022-06-30 22:07:54 +00:00
}
export interface Listening {
id: string
track: Track
user: User
actor: Actor
creation_date: string
}
// API stuff
2022-07-01 11:13:07 +00:00
export interface APIErrorResponse extends Record<string, APIErrorResponse | string[] | { code: string }[]> {}
2022-07-01 11:13:07 +00:00
export interface BackendError extends AxiosError {
backendErrors: string[]
rawPayload?: APIErrorResponse
}
export interface RateLimitStatus {
limit: string
scope: string
remaining: string
duration: string
availableSeconds: number
reset: string
resetSeconds: string
}
// WebSocket stuff
export interface PendingReviewEditsWSEvent {
pending_review_count: number
}
export interface PendingReviewReportsWSEvent {
unresolved_count: number
}
export interface PendingReviewRequestsWSEvent {
pending_count: number
}
export interface ListenWsEventObject {
local_id: string
}
export interface ListenWSEvent {
actor: ListenWsEventObject
object: ListenWsEventObject
}
// TODO (wvffle): Add reactivity to recently listened / favorited / added (#1316, #1534)
// export interface ListenWSEvent extends Listening {
// type: 'Listen'
// }
export type WebSocketEvent = PendingReviewEditsWSEvent | PendingReviewReportsWSEvent | PendingReviewRequestsWSEvent | ListenWSEvent
2022-04-30 20:46:37 +00:00
// FS Browser
export interface FSEntry {
dir: boolean
name: string
}
export interface FileSystem {
root: boolean
content: FSEntry[]
}
2022-05-02 15:06:44 +00:00
// Content stuff
export interface Content {
content_type: 'text/plain' | 'text/markdown'
text: string // TODO (wvffle): Ensure it's not nullable from backend side
}
2022-05-02 15:06:44 +00:00
// Form stuff
export interface FormField {
label: string
input_type: 'short_text' | 'long_text'
required: boolean
}
export interface Form {
fields: FormField[]
2022-05-02 15:06:44 +00:00
help_text: Content
}
// Upload stuff
export interface Upload {
filename?: string
source?: string
uuid: string
2022-07-02 23:49:07 +00:00
duration?: number
mimetype: string
extension: string
listen_url: string
2022-07-20 22:44:19 +00:00
import_status: ImportStatus
import_details?: {
detail: object
error_code: string
}
}
2022-06-30 01:32:37 +00:00
// FileSystem Logs
export interface FSLogs {
status: 'pending' | 'started'
reference: unknown // TODO (wvffle): Find correct type
logs: string[]
}
2022-07-04 18:17:58 +00:00
// Profile stuff
2022-04-30 20:46:37 +00:00
export interface Actor {
2022-07-05 22:34:11 +00:00
id: string
2022-07-04 18:17:58 +00:00
fid?: string
name?: string
icon?: Cover
summary: string
2022-04-30 20:46:37 +00:00
preferred_username: string
full_username: string
is_local: boolean
domain: string
}
2022-07-04 22:02:39 +00:00
2022-07-05 22:34:11 +00:00
export interface User {
id: string
2022-07-11 00:31:08 +00:00
avatar?: Cover
2022-07-05 22:34:11 +00:00
username: string
full_username: string
instance_support_message_display_date: string
funkwhale_support_message_display_date: string
is_superuser: boolean
privacy_level: PrivacyLevel
}
2022-07-04 22:02:39 +00:00
// Settings stuff
export type SettingsId = 'instance'
export interface SettingsGroup {
label: string
id: SettingsId
settings: SettingsField[]
}
export interface SettingsField {
name: string
fieldType?: 'markdown'
fieldParams?: {
charLimit: number | null
permissive: boolean
}
}
export interface SettingsDataEntry {
identifier: string
fieldType: string
fieldParams: object
help_text: string
verbose_name: string
value: unknown
field: {
class: string
widget: {
class: string
}
}
additional_data: {
choices: [string, string]
}
2022-07-11 00:31:08 +00:00
}
// Note stuff
export interface Note {
uuid: string
author: Actor // TODO (wvffle): Check if is valid
summary: string
creation_date: string
2022-07-04 22:02:39 +00:00
}