mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +00:00
MASSIVE commit
- moved to typescript - axios rate limitmodule is busted, removed for now, do something else for that - sequelize-typescript - dotenv, not dotenv-flow - removed playlist details route types for API ton of minor fixes and improvements
This commit is contained in:
59
types/spotify_manager/common.types.ts
Normal file
59
types/spotify_manager/common.types.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
// COMMON
|
||||
export type AlbumType = "album" | "single" | "compilation";
|
||||
/**
|
||||
* The markets in which the album is available: {@link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2|ISO 3166-1 alpha-2 country codes}
|
||||
*
|
||||
* NOTE: an album is considered available in a market when at least 1 of its tracks is available in that market.
|
||||
*/
|
||||
export type AvailableMarkets = string[];
|
||||
export type CopyrightObject = {
|
||||
text: string;
|
||||
type: string;
|
||||
};
|
||||
export type ExternalURLs = {
|
||||
spotify: string;
|
||||
};
|
||||
export type ExternalIDs = {
|
||||
isrc: string;
|
||||
ean: string;
|
||||
upc: string;
|
||||
};
|
||||
export type Followers = {
|
||||
href: string | null;
|
||||
total: number;
|
||||
};
|
||||
export type ImageObject = {
|
||||
/** valid for 24 hours from retrieval */ url: string;
|
||||
/** in pixels */ height: number | null;
|
||||
/** in pixels */ width: number | null;
|
||||
};
|
||||
export type LinkedFrom = {
|
||||
external_urls?: ExternalURLs;
|
||||
href?: string;
|
||||
id?: string;
|
||||
type?: "track";
|
||||
uri?: string;
|
||||
};
|
||||
export type Pagination<T> = {
|
||||
href: string;
|
||||
limit: number;
|
||||
next: string | null;
|
||||
offset: number;
|
||||
previous: string | null;
|
||||
total: number;
|
||||
items: T[];
|
||||
};
|
||||
export type PaginationByCursor<T> = {
|
||||
href?: string;
|
||||
limit?: number;
|
||||
next?: string;
|
||||
cursors?: {
|
||||
after?: string;
|
||||
before?: string;
|
||||
};
|
||||
total?: number;
|
||||
items?: T[];
|
||||
};
|
||||
export type Restrictions = {
|
||||
reason: "market" | "product" | "explicit";
|
||||
};
|
||||
28
types/spotify_manager/custom.types.ts
Normal file
28
types/spotify_manager/custom.types.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// APPLICATION
|
||||
export type URIObject = {
|
||||
type: string;
|
||||
is_local: boolean;
|
||||
id: string;
|
||||
artist?: string;
|
||||
album?: string;
|
||||
title?: string;
|
||||
duration?: number;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
username: string;
|
||||
id: string;
|
||||
};
|
||||
|
||||
export interface PlaylistModel_Pl {
|
||||
playlistID: string;
|
||||
playlistName: string;
|
||||
}
|
||||
export interface PlaylistModel extends PlaylistModel_Pl {
|
||||
userID: string;
|
||||
}
|
||||
|
||||
export interface LinkModel_Edge {
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
134
types/spotify_manager/endpoints.types.ts
Normal file
134
types/spotify_manager/endpoints.types.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
import type {
|
||||
ImageObject,
|
||||
Pagination,
|
||||
PaginationByCursor,
|
||||
} from "./common.types.ts";
|
||||
import type {
|
||||
AlbumObject,
|
||||
ArtistObject,
|
||||
ArtistsAlbumObject,
|
||||
EpisodeObject,
|
||||
PlaylistObject,
|
||||
PlaylistTrackObject,
|
||||
SavedAlbumObject,
|
||||
SavedEpisodeObject,
|
||||
SavedShowObject,
|
||||
SavedTrackObject,
|
||||
ShowObject,
|
||||
SimplifiedAlbumObject,
|
||||
SimplifiedEpisodeObject,
|
||||
SimplifiedPlaylistObject,
|
||||
SimplifiedShowObject,
|
||||
SimplifiedTrackObject,
|
||||
SimplifiedUserObject,
|
||||
TrackObject,
|
||||
UserObject,
|
||||
} from "./objects.types.ts";
|
||||
|
||||
// GET method
|
||||
// Albums
|
||||
export type GetAlbum = AlbumObject;
|
||||
export type GetSeveralAlbums = { albums: AlbumObject[] };
|
||||
export type GetAlbumTracks = Pagination<SimplifiedTrackObject>;
|
||||
export type GetUsersSavedAlbums = Pagination<SavedAlbumObject>;
|
||||
export type CheckUsersSavedAlbums = boolean[];
|
||||
export type GetNewReleases = { albums: Pagination<SimplifiedAlbumObject> };
|
||||
|
||||
// Artists
|
||||
export type GetArtist = ArtistObject;
|
||||
export type GetSeveralArtists = { artists: ArtistObject[] };
|
||||
export type GetArtistsAlbums = Pagination<ArtistsAlbumObject>;
|
||||
export type GetArtistsTopTracks = { tracks: TrackObject[] };
|
||||
|
||||
// Episodes
|
||||
export type GetEpisode = EpisodeObject;
|
||||
export type GetSeveralEpisodes = { episodes: EpisodeObject[] };
|
||||
export type GetUsersSavedEpisodes = Pagination<SavedEpisodeObject>;
|
||||
|
||||
// Shows
|
||||
export type GetShow = ShowObject;
|
||||
export type GetSeveralShows = { shows: SimplifiedShowObject[] };
|
||||
export type GetShowEpisodes = Pagination<SimplifiedEpisodeObject>;
|
||||
export type GetUsersSavedShows = Pagination<SavedShowObject>;
|
||||
|
||||
// Playlists
|
||||
export type GetPlaylist = PlaylistObject;
|
||||
export type GetPlaylistItems = Pagination<PlaylistTrackObject>;
|
||||
export type GetCurrentUsersPlaylists = Pagination<SimplifiedPlaylistObject>;
|
||||
export type GetUsersPlaylists = GetCurrentUsersPlaylists;
|
||||
export type GetPlaylistCoverImage = ImageObject[];
|
||||
|
||||
// Tracks
|
||||
export type GetTrack = TrackObject;
|
||||
export type GetSeveralTracks = { tracks: TrackObject[] };
|
||||
export type GetUsersSavedTracks = Pagination<SavedTrackObject>;
|
||||
export type CheckUsersSavedTracks = boolean[];
|
||||
|
||||
// Users
|
||||
export type GetCurrentUsersProfile = UserObject;
|
||||
export type GetUsersTopItems =
|
||||
| Pagination<ArtistObject>
|
||||
| Pagination<TrackObject>;
|
||||
export type GetUsersProfile = SimplifiedUserObject;
|
||||
export type GetFollowedArtists = { artists: PaginationByCursor<ArtistObject> };
|
||||
export type CheckIfUserFollowsArtistsOrNot = boolean[];
|
||||
export type CheckIfCurrentUserFollowsPlaylist = boolean[];
|
||||
|
||||
// POST method
|
||||
// Albums
|
||||
// Artists
|
||||
// Episodes
|
||||
// Shows
|
||||
|
||||
// Playlists
|
||||
export type AddItemsToPlaylist = { snapshot_id: string };
|
||||
export type CreatePlaylist = PlaylistObject;
|
||||
|
||||
// Tracks
|
||||
// Users
|
||||
|
||||
// PUT method
|
||||
// Albums
|
||||
export type SaveAlbumsForCurrentUser = {};
|
||||
// Artists
|
||||
// Episodes
|
||||
// Shows
|
||||
|
||||
// Playlists
|
||||
export type ChangePlaylistDetails = {};
|
||||
export type UpdatePlaylistItems = { snapshot_id: string };
|
||||
export type AddCustomPlaylistCoverImage = {};
|
||||
|
||||
// Tracks
|
||||
export type SaveTracksForCurrentUser = {};
|
||||
|
||||
// Users
|
||||
export type FollowPlaylist = {};
|
||||
export type FollowArtistsOrUsers = {};
|
||||
|
||||
// DELETE method
|
||||
// Albums
|
||||
export type RemoveUsersSavedAlbums = {};
|
||||
|
||||
// Artists
|
||||
// Episodes
|
||||
// Shows
|
||||
|
||||
// Playlists
|
||||
export type RemovePlaylistItems = { snapshot_id: string };
|
||||
|
||||
// Tracks
|
||||
export type RemoveUsersSavedTracks = {};
|
||||
|
||||
// Users
|
||||
export type UnfollowPlaylist = {};
|
||||
export type UnfollowArtistsOrUsers = {};
|
||||
|
||||
// <insert other method> method
|
||||
// Albums
|
||||
// Artists
|
||||
// Episodes
|
||||
// Shows
|
||||
// Playlists
|
||||
// Tracks
|
||||
// Users
|
||||
5
types/spotify_manager/index.d.ts
vendored
Normal file
5
types/spotify_manager/index.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from "./common.types.ts";
|
||||
export * from "./custom.types.ts";
|
||||
export * from "./endpoints.types.ts";
|
||||
export * from "./objects.types.ts";
|
||||
export * from "./shorthands.types.ts";
|
||||
189
types/spotify_manager/objects.types.ts
Normal file
189
types/spotify_manager/objects.types.ts
Normal file
@@ -0,0 +1,189 @@
|
||||
import type {
|
||||
AlbumType,
|
||||
AvailableMarkets,
|
||||
CopyrightObject,
|
||||
ExternalIDs,
|
||||
ExternalURLs,
|
||||
Followers,
|
||||
ImageObject,
|
||||
LinkedFrom,
|
||||
Pagination,
|
||||
Restrictions,
|
||||
} from "./common.types.ts";
|
||||
|
||||
// OBJECTS
|
||||
export interface SimplifiedArtistObject {
|
||||
external_urls: ExternalURLs;
|
||||
href: string;
|
||||
id: string;
|
||||
name: string;
|
||||
type: "artist";
|
||||
uri: string;
|
||||
}
|
||||
export interface ArtistObject extends SimplifiedArtistObject {
|
||||
followers: Followers;
|
||||
genres: string[];
|
||||
images: ImageObject[];
|
||||
popularity: number;
|
||||
}
|
||||
export interface SimplifiedAlbumObject {
|
||||
album_type: AlbumType;
|
||||
artists: SimplifiedArtistObject[];
|
||||
available_markets: AvailableMarkets;
|
||||
external_urls: ExternalURLs;
|
||||
// genres: string[]; // deprecated
|
||||
href: string;
|
||||
id: string;
|
||||
images: ImageObject[];
|
||||
name: string;
|
||||
release_date: string;
|
||||
release_date_precision: "year" | "month" | "day";
|
||||
restrictions?: Restrictions;
|
||||
total_tracks: number;
|
||||
type: "album";
|
||||
uri: string;
|
||||
}
|
||||
export interface ArtistsAlbumObject extends SimplifiedAlbumObject {
|
||||
album_group: "album" | "single" | "compilation" | "appears_on";
|
||||
}
|
||||
export interface AlbumObject extends SimplifiedAlbumObject {
|
||||
copyrights: CopyrightObject[];
|
||||
external_ids: ExternalIDs;
|
||||
label: string;
|
||||
popularity: number;
|
||||
tracks: Pagination<SimplifiedTrackObject>;
|
||||
}
|
||||
export type SavedAlbumObject = {
|
||||
added_at: string;
|
||||
album: AlbumObject;
|
||||
};
|
||||
export interface SimplifiedEpisodeObject {
|
||||
description: string;
|
||||
html_description: string;
|
||||
duration_ms: number;
|
||||
explicit: boolean;
|
||||
external_urls: ExternalURLs;
|
||||
href: string;
|
||||
id: string;
|
||||
images: ImageObject[];
|
||||
is_externally_hosted: boolean;
|
||||
is_playable: boolean;
|
||||
languages: string[];
|
||||
name: string;
|
||||
release_date: string;
|
||||
release_date_precision: string;
|
||||
type: "episode";
|
||||
uri: string;
|
||||
restrictions?: Restrictions;
|
||||
}
|
||||
export interface EpisodeObject extends SimplifiedEpisodeObject {
|
||||
show: ShowObject;
|
||||
}
|
||||
export type SavedEpisodeObject = {
|
||||
added_at: string;
|
||||
episode: EpisodeObject;
|
||||
};
|
||||
export interface SimplifiedShowObject {
|
||||
available_markets?: AvailableMarkets;
|
||||
copyrights?: CopyrightObject[];
|
||||
description?: string;
|
||||
html_description?: string;
|
||||
explicit?: boolean;
|
||||
external_urls?: ExternalURLs;
|
||||
href?: string;
|
||||
id?: string;
|
||||
images?: ImageObject[];
|
||||
is_externally_hosted?: boolean;
|
||||
languages?: string[];
|
||||
media_type?: string;
|
||||
name?: string;
|
||||
publisher?: string;
|
||||
type: "show";
|
||||
uri?: string;
|
||||
total_episodes?: number;
|
||||
}
|
||||
export interface ShowObject extends SimplifiedShowObject {
|
||||
episodes?: Pagination<SimplifiedEpisodeObject>;
|
||||
}
|
||||
export type SavedShowObject = {
|
||||
added_at?: string;
|
||||
show?: SimplifiedShowObject;
|
||||
};
|
||||
export interface SimplifiedTrackObject {
|
||||
artists: SimplifiedArtistObject[];
|
||||
available_markets: AvailableMarkets;
|
||||
disc_number: number;
|
||||
duration_ms: number;
|
||||
explicit: boolean;
|
||||
external_urls: ExternalURLs;
|
||||
href: string;
|
||||
id: string;
|
||||
is_playable?: boolean;
|
||||
linked_from?: LinkedFrom;
|
||||
restrictions?: Restrictions;
|
||||
name: string;
|
||||
// preview_url?: string; // deprecated
|
||||
track_number: number;
|
||||
type: "track";
|
||||
uri: string;
|
||||
is_local: boolean;
|
||||
}
|
||||
export interface TrackObject extends SimplifiedTrackObject {
|
||||
album: SimplifiedAlbumObject;
|
||||
external_ids: ExternalIDs;
|
||||
popularity: number;
|
||||
}
|
||||
export type SavedTrackObject = {
|
||||
added_at: string;
|
||||
track: TrackObject;
|
||||
};
|
||||
export interface SimplifiedUserObject {
|
||||
display_name: string | null;
|
||||
external_urls: ExternalURLs;
|
||||
followers: Followers;
|
||||
href: string;
|
||||
id: string;
|
||||
images: ImageObject[];
|
||||
type: "user";
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export interface UserObject extends SimplifiedUserObject {
|
||||
country?: string;
|
||||
email?: string;
|
||||
explicit_content?: {
|
||||
filter_enabled: boolean;
|
||||
filter_locked: boolean;
|
||||
};
|
||||
product?: string;
|
||||
}
|
||||
export type PlaylistTrackObject = {
|
||||
added_at: string | null;
|
||||
added_by: SimplifiedUserObject | null;
|
||||
is_local: boolean;
|
||||
track: TrackObject | EpisodeObject;
|
||||
};
|
||||
interface BasePlaylistObject {
|
||||
collaborative: boolean;
|
||||
description: string | null;
|
||||
external_urls: ExternalURLs;
|
||||
href: string;
|
||||
id: string;
|
||||
images: ImageObject[];
|
||||
name: string;
|
||||
owner: SimplifiedUserObject;
|
||||
public: boolean | null;
|
||||
snapshot_id: string;
|
||||
type: "playlist";
|
||||
uri: string;
|
||||
}
|
||||
export interface SimplifiedPlaylistObject extends BasePlaylistObject {
|
||||
tracks: {
|
||||
href: string;
|
||||
total: number;
|
||||
};
|
||||
}
|
||||
export interface PlaylistObject extends BasePlaylistObject {
|
||||
tracks: Pagination<PlaylistTrackObject>;
|
||||
followers: Followers;
|
||||
}
|
||||
10
types/spotify_manager/shorthands.types.ts
Normal file
10
types/spotify_manager/shorthands.types.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Request, Response, NextFunction } from "express";
|
||||
|
||||
export type Req = Request;
|
||||
export type Res = Response;
|
||||
export type Next = NextFunction;
|
||||
|
||||
export interface EndpointHandlerBaseArgs {
|
||||
req: Req;
|
||||
res: Res;
|
||||
}
|
||||
Reference in New Issue
Block a user