METANOIA/dbschema/default.esdl

251 lines
6.3 KiB
Plaintext

module default {
}
module metadata {
scalar type ReleaseMediaSource extending enum<CD, Web, Analog>;
type License {
property name -> str;
property url -> str {
constraint exclusive;
}
}
type Name {
required property language -> str;
required property value -> str;
}
type Tag {
required property name -> str {
constraint exclusive;
}
index on (.name);
multi link albums := .<tags[is metadata::Album];
multi link songs := .<tags[is metadata::Song];
}
type Album {
required multi link names -> Name;
link cover -> media::Art;
multi link art -> media::Art;
multi link artists -> Artist {
property kind -> str;
}
multi link tags -> Tag;
multi link releases -> Release {
constraint exclusive;
}
property metadata -> json;
}
type Release {
property media_source -> ReleaseMediaSource;
property release_date -> datetime;
multi link discs -> Disc {
property number -> int32;
constraint exclusive;
}
link album := .<releases[is Album];
link license -> License;
property metadata -> json;
}
type Disc {
property catalog_number -> str;
multi link tracks -> Song {
property number -> int32;
}
property metadata -> json;
link release := .<discs[is Release];
index on (.catalog_number);
}
type Artist {
required multi link names -> Name;
property metadata -> json;
}
type Song {
required multi link names -> Name;
multi link artists -> Artist {
property kind -> str;
}
required multi link recordings -> media::Recording {
property start_sample -> int64;
property end_sample -> int64;
}
multi link tags -> Tag;
required property length -> duration;
multi link lyrics -> media::Lyrics;
property isrc -> str {
constraint exclusive;
}
property metadata -> json;
multi link related -> Song {
property kind -> str;
}
multi link discs := .<tracks[is Disc];
index on (.isrc);
}
}
module media {
scalar type LyricsKind extending enum<ASS, LRC, WebVTT, SubRip, Text>;
scalar type ArtResourceType extending enum<Original, Large, Small>;
abstract type Resource {
required property hash -> bytes {
annotation description := "SHA256 of the resource";
}
required property size -> int64;
required property mime -> str;
property metadata -> json;
multi property sources -> str;
property path -> str {
constraint exclusive;
annotation description := "full path or URI to resource";
}
property blob -> bytes {
annotation description := "full contents of resource";
}
property name -> str {
annotation description := "base name of path / filename";
}
index on (.hash);
}
type Blob extending Resource {
}
type Lyrics extending Resource {
required property kind -> LyricsKind;
required property language -> str;
}
type Art extending Resource {
required property kind -> str;
required property type -> ArtResourceType;
multi link thumbnails -> Art;
}
type RecordingGroup {
annotation description := "a group of Recording placed within the same folder/group";
property toc -> array<int32>;
property crc32 -> int32;
property cuetools_crc32 -> int32;
property cddb1 -> int32;
property discid -> str;
property tocid -> str;
required multi link recordings -> Recording {
property number -> int32;
}
multi link resources -> Resource {
annotation description := "other resources included around the group (same folder, one folder down, and one folder up if applicable)";
}
}
type Recording extending Resource {
required property processed -> bool {
default := false
}
property crc32 -> int32;
property cuetools_crc32 -> int32;
property accurip_v1 -> int32;
property accurip_v2 -> int32;
required property length -> duration;
required property lossless -> bool;
required property sample_rate -> int32;
required property channels -> int32;
required property samples -> int64;
link recording_group := .<recordings[is RecordingGroup];
link song := .<recordings[is metadata::Song];
}
}
module radio {
type HistoryEntry {
required link song -> metadata::Song;
link recording -> media::Recording;
required property date -> datetime;
property source -> user::User;
}
}
module user {
scalar type KeyKind extending enum<Ed25519, Secp256k1, Secp256r1, Passphrase>;
type UserGroup {
required property name -> str {
constraint exclusive;
}
multi property permissions -> str;
}
type UserKey {
required property kind -> KeyKind;
required property value -> bytes;
}
type User {
required property name -> str {
constraint exclusive;
}
required multi link keys -> UserKey {
property name -> str;
}
required multi link groups -> UserGroup;
property metadata -> json;
multi link favorites := .<owner[is Favorite];
multi link tagged := .<owner[is Tagging];
multi link playlists := .<owner[is Playlist];
index on (.name);
}
type Favorite {
required link owner -> User;
required link song -> metadata::Song;
multi link tags -> metadata::Tag;
index on (.owner);
}
type Tagging {
required link owner -> User;
required link song -> metadata::Song;
multi link tags -> metadata::Tag;
index on (.owner);
}
type Playlist {
required link owner -> User;
multi link songs -> metadata::Song {
property number -> int32;
}
property name -> str;
index on (.owner);
}
}