Skip to content

Commit 51591b3

Browse files
committed
docs!: update type documentation
1 parent 4ae2c2d commit 51591b3

File tree

1 file changed

+88
-56
lines changed

1 file changed

+88
-56
lines changed

src/spotify-types.ts

Lines changed: 88 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,37 @@ export type SpotifyPlayerCallback = (token: string) => void;
1414
export interface SpotifyDevice {
1515
/** Device ID. */
1616
id: string;
17-
is_active: boolean;
18-
is_private_session: boolean;
19-
is_restricted: boolean;
2017
/** Device name. */
2118
name: string;
22-
/** Device type. */
19+
/** Device type, such as "Computer", "Smartphone", or "Speaker". */
2320
type: string;
2421
/** Volume level (as a percentage between `0` and `100`). */
2522
volume_percent: number;
23+
/** Indicates if this device is the user's currently active device. */
24+
is_active: boolean;
25+
/** Indicates if this device is currently in a private session. */
26+
is_private_session: boolean;
27+
/** Indicates if this device is restricted from accepting Web API commands. */
28+
is_restricted: boolean;
2629
}
2730

2831
/**
2932
* An artist on Spotify.
3033
*/
3134
export interface SpotifyArtist {
32-
external_urls: {
33-
spotify: string;
34-
};
35-
href: string;
3635
/** Artist ID. */
3736
id: string;
3837
/** Artist name. */
3938
name: string;
40-
type: string;
39+
/** Artist URI. */
4140
uri: string;
41+
external_urls: {
42+
/** The open.spotify.com URL. */
43+
spotify: string;
44+
};
45+
/** The Web API endpoint providing full details of the artist. */
46+
href: string;
47+
type: string;
4248
}
4349

4450
/**
@@ -53,71 +59,97 @@ export interface SpotifyImage {
5359
url: string;
5460
}
5561

56-
export interface SpotifyPlayOptions {
57-
context_uri?: string;
58-
deviceId: string;
59-
offset?: number;
60-
uris?: string[];
61-
}
62+
/**
63+
* A Spotify album.
64+
*/
65+
export interface SpotifyAlbum {
66+
/** Album ID. */
67+
id: string;
68+
/** Album name. */
69+
name: string;
70+
type: string; // 'artist'
71+
/** Album type. */
72+
album_type: string; // 'album' | 'single' | 'compilation'
73+
/** List of artists for this album. */
74+
artists: SpotifyArtist[];
75+
/** List of markets this track is available in. */
76+
available_markets: string[];
77+
/** Web browser URLs. */
78+
external_urls: {
79+
/** The open.spotify.com URL. */
80+
spotify: string;
81+
};
82+
/** The api.spotify.com URL. */
83+
href: string;
84+
/** List of images for this album. */
85+
images: SpotifyImage[];
86+
/** Release date (YYYY-MM-DD). */
87+
release_date: string;
88+
/** The precision with which the release date is known. */
89+
release_date_precision: 'year' | 'month' | 'day';
90+
/** Number of tracks in this album. */
91+
total_tracks: number;
92+
uri: string;
93+
};
94+
95+
export interface SpotifyTrack {
96+
/** Album information. */
97+
album: SpotifyAlbum;
98+
/** List of artists. */
99+
artists: SpotifyArtist[];
100+
/** List of markets this track is available in. */
101+
available_markets: string[];
102+
/** The disc number (set to 1 unless the album has more than one disc). */
103+
disc_number: number;
104+
/** Track length in milliseconds. */
105+
duration_ms: number;
106+
/** Indicates if this track has explicit material. */
107+
explicit: false;
108+
external_ids: {
109+
isrc: string;
110+
};
111+
external_urls: {
112+
spotify: string;
113+
};
114+
href: string;
115+
id: string;
116+
/** Indicates if this track is a local file or not. */
117+
is_local: false;
118+
/** The popularity of this album (`0` to `100`). */
119+
popularity: number;
120+
preview_url: string;
121+
track_number: number;
122+
type: string;
123+
uri: string;
124+
};
62125

63126
/**
64127
* Status of a Spotify player.
65128
*/
66129
export interface SpotifyPlayerStatus {
130+
name: string;
67131
actions: {
132+
/** Indicates which actions are not allowed. */
68133
disallows: {
69134
resuming: boolean;
70135
skipping_prev: boolean;
71136
};
72137
};
73138
/** @hidden */
74139
context: null;
75-
currently_playing_type: string;
140+
/** The object type of the currently playing item. */
141+
currently_playing_type: 'track' | 'episode' | 'ad' | 'unknown';
76142
/** Current device. */
77143
device: SpotifyDevice;
144+
/** Indicates if something is currently playing. */
78145
is_playing: boolean;
79-
item: {
80-
album: {
81-
album_type: string;
82-
artists: SpotifyArtist[];
83-
available_markets: string[];
84-
external_urls: {
85-
spotify: string;
86-
};
87-
href: string;
88-
id: string;
89-
images: SpotifyImage[];
90-
name: string;
91-
release_date: string;
92-
release_date_precision: string;
93-
total_tracks: number;
94-
type: string;
95-
uri: string;
96-
};
97-
artists: SpotifyArtist[];
98-
available_markets: string[];
99-
disc_number: number;
100-
duration_ms: number;
101-
explicit: false;
102-
external_ids: {
103-
isrc: string;
104-
};
105-
external_urls: {
106-
spotify: string;
107-
};
108-
href: string;
109-
id: string;
110-
is_local: false;
111-
name: string;
112-
popularity: number;
113-
preview_url: string;
114-
track_number: number;
115-
type: string;
116-
uri: string;
117-
};
146+
/** The currently active track. */
147+
item: SpotifyTrack;
118148
/** Progress (in milliseconds). */
119149
progress_ms: number;
120-
repeat_state: string;
150+
/** What (if anything) is being repeated. */
151+
repeat_state: 'off' | 'track' | 'context';
152+
/** Indicates if shuffle mode is on. */
121153
shuffle_state: false;
122154
/** Timestamp. */
123155
timestamp: number;

0 commit comments

Comments
 (0)