Skip to content

Commit

Permalink
feat(types): add missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvdkolk committed Feb 23, 2024
1 parent 89f129d commit 0db350e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 89 deletions.
27 changes: 16 additions & 11 deletions src/interfaces/Spotify/Album.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Artist, ArtistSimplified } from './Artist';
import { ExternalUrls, ExternalIds } from './shared';
import { ExternalUrls, ExternalIds, PagingObject } from './shared';
import { Copyright } from './shared/Copyrights';
import { Image } from './shared/Image';
import { Track } from './Track';
import { Track, TrackSimplified } from './Track';

Check warning on line 5 in src/interfaces/Spotify/Album.ts

View workflow job for this annotation

GitHub Actions / lint

'Track' is defined but never used

export interface AlbumBase {
/**
Expand Down Expand Up @@ -72,6 +73,18 @@ export interface AlbumBase {
* Known external IDs for the track.
*/
external_ids?: ExternalIds;
/**
* The label for the album.
*/
label: string;
/**
* The genres of the album.
*/
genres: string[];
/**
* The copyright statements of the album.
*/
copyrights: Copyright[];
}

export interface AlbumSimplified extends AlbumBase {
Expand All @@ -94,13 +107,5 @@ export interface Album extends AlbumBase {
/**
* The tracks of the album.
*/
tracks: {
href: string;
items: Track[];
limit: number;
next: string;
offset: number;
previous: string;
total: number;
};
tracks: PagingObject<TrackSimplified>;
}
8 changes: 1 addition & 7 deletions src/interfaces/Spotify/Artist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ export interface ArtistSimplified {
uri: string;
}

export interface Artist {
external_urls: ExternalUrls;
export interface Artist extends ArtistSimplified {
followers: Followers;
genres: string[];
href: string;
id: string;
images: Image[];
name: string;
popularity: number;
type: string;
uri: string;
}
93 changes: 22 additions & 71 deletions src/interfaces/Spotify/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { ArtistSimplified } from './Artist';
import { ExternalIds } from './shared/ExternalIds';
import { ExternalUrls } from './shared/ExternalUrls';

export interface Track {
/**
* The album on which the track appears.
*/
album: AlbumSimplified;
export interface TrackSimplified {
/**
* The artists who performed the track.
*/
Expand All @@ -29,10 +25,6 @@ export interface Track {
* Whether or not the track has explicit lyrics.
*/
explicit: boolean;
/**
* Known external IDs for the track.
*/
external_ids: ExternalIds;
/**
* Known external URLs for this track.
*/
Expand All @@ -51,22 +43,14 @@ export interface Track {
restrictions?: {
reason: 'market' | 'product' | 'explicit';
};
/**
* Whether or not the track is from a local file.
*/
is_local: boolean;
/**
* Name of the track.
*/
name: string;
/**
* The popularity of the track. The value will be between 0 and 100, with 100 being the most popular.
*/
popularity: number;
/**
* A link to a 30 second preview (MP3 format) of the track.
*/
preview_url?: string;
preview_url: string | null;
/**
* The number of the track. If an album has several discs, the track number is the number on the specified disc.
*/
Expand All @@ -79,70 +63,37 @@ export interface Track {
* The Spotify URI for the track.
*/
uri: string;
}

export interface TrackSimplified {
/**
* The artists who performed the track.
*/
artists: ArtistSimplified[];
/**
* The markets in which the album is available: [ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes.
* Note that an album is considered available in a market when at least 1 of its tracks is available in that market.
*/
available_markets: string[];
/**
* The disc number (usually 1 unless the album consists of more than one disc).
*/
disc_number: number;
/**
* The track length in milliseconds.
*/
duration_ms: number;
/**
* Whether or not the track has explicit lyrics.
*/
explicit: boolean;
/**
* Known external URLs for this track.
*/
external_urls: ExternalUrls;
/**
* A link to the Web API endpoint providing full details of the track.
* Whether or not the track is from a local file.
*/
href: string;
is_local: boolean;
/**
* The Spotify ID for the track.
* Part of the response when [Track Relinking](https://developer.spotify.com/documentation/web-api/concepts/track-relinking) is applied. If true, the track is playable in the given market. Otherwise false.
*/
id: string;
is_playable?: boolean;
/**
* Included in the response when a content restriction is applied.
* Part of the response when [Track Relinking](https://developer.spotify.com/documentation/web-api/concepts/track-relinking) is applied, and the requested track has been replaced with different track. The track in the linked_from object contains information about the originally requested track.
*/
restrictions?: {
reason: 'market' | 'product' | 'explicit';
linked_from?: {
external_urls: ExternalUrls;
href: string;
id: string;
type: string;
uri: string;
};
}

export interface Track extends TrackSimplified {
/**
* Name of the track.
*/
name: string;
/**
* A link to a 30 second preview (MP3 format) of the track.
*/
preview_url?: string;
/**
* The number of the track. If an album has several discs, the track number is the number on the specified disc.
*/
track_number: number;
/**
* The object type: "track".
* The album on which the track appears.
*/
type: 'track';
album: AlbumSimplified;
/**
* The Spotify URI for the track.
* Known external IDs for the track.
*/
uri: string;
external_ids: ExternalIds;
/**
* Whether or not the track is from a local file.
* The popularity of the track. The value will be between 0 and 100, with 100 being the most popular.
*/
is_local: boolean;
popularity: number;
}
4 changes: 4 additions & 0 deletions src/interfaces/Spotify/shared/Copyrights.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Copyright {
text: string;
type: string;
}

0 comments on commit 0db350e

Please sign in to comment.