/
master.ts
56 lines (52 loc) · 1.31 KB
/
master.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as t from 'io-ts'
import { ImageIO, ResourceURLIO, StatNumberIO, VideoIO } from './commons'
import { makeEnumIOType } from './helpers'
import { ReleaseArtistIO, TrackIO } from './release'
import { CommunityStatusesEnum, DataQualityEnum } from '../src/enums'
/**
* @internal
*/
export const MasterIO = t.intersection([
ResourceURLIO,
t.type({
id: t.Integer,
main_release: t.Integer,
main_release_url: t.string,
versions_url: t.string,
title: t.string,
artists: t.array(ReleaseArtistIO),
genres: t.array(t.string),
styles: t.array(t.string),
year: t.Integer,
tracklist: t.array(TrackIO),
lowest_price: t.number,
num_for_sale: t.Integer,
data_quality: makeEnumIOType(DataQualityEnum),
images: t.array(ImageIO),
videos: t.array(VideoIO),
uri: t.string,
}),
])
export type Master = t.TypeOf<typeof MasterIO>
/**
* @internal
*/
export const MasterVersionIO = t.intersection([
ResourceURLIO,
t.type({
id: t.Integer,
title: t.string,
format: t.string,
major_formats: t.array(t.string),
label: t.string,
catno: t.string,
released: t.string,
country: t.string,
status: makeEnumIOType(CommunityStatusesEnum),
stats: t.type({
user: StatNumberIO,
community: StatNumberIO,
}),
thumb: t.string,
}),
])