types.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //#SECTION server
  2. export type ServerResponse<T> = SuccessResponse<T> | ErrorResponse;
  3. export type SuccessResponse<T> = {
  4. error: false;
  5. matches: number;
  6. } & T;
  7. export type ErrorResponse = {
  8. error: true;
  9. matches: 0 | null;
  10. message: string;
  11. }
  12. //#SECTION meta
  13. interface Artist {
  14. name: string | null;
  15. url: string | null;
  16. image: string | null;
  17. headerImage: string | null;
  18. }
  19. /** geniURL song meta object */
  20. export interface SongMeta {
  21. url: string;
  22. path: string;
  23. language: string | null;
  24. meta: {
  25. title: string;
  26. fullTitle: string;
  27. artists: string;
  28. releaseDate: {
  29. year: number | null;
  30. month: number | null;
  31. day: number | null;
  32. };
  33. primaryArtist: Artist | null;
  34. featuredArtists: Artist[];
  35. };
  36. resources: {
  37. thumbnail: string | null;
  38. image: string | null;
  39. };
  40. lyricsState: string;
  41. id: number;
  42. }
  43. export type MetaSearchHit = SongMeta & { uuid?: string; };
  44. export interface GetMetaArgs {
  45. q?: string;
  46. artist?: string;
  47. song?: string;
  48. threshold?: number;
  49. preferLang?: string;
  50. }
  51. export type SearchFilterArgs = GetMetaArgs;
  52. export type ScoredResults<T> = {
  53. score: number;
  54. result: T;
  55. };
  56. export interface GetMetaResult {
  57. top: SongMeta;
  58. all: SongMeta[];
  59. }
  60. //#SECTION translations
  61. export interface SongTranslation {
  62. language: string;
  63. id: number;
  64. path: string;
  65. title: string;
  66. url: string;
  67. }
  68. export interface GetTranslationsArgs {
  69. preferLang?: string;
  70. }
  71. //#SECTION server
  72. export type ResponseType = "serverError" | "clientError" | "success";
  73. export type ResponseFormat = "json" | "xml";
  74. //#SECTION API
  75. /** The entire object returned by the search endpoint of the genius API */
  76. export type ApiSearchResult = {
  77. response: {
  78. hits: SearchHit[];
  79. };
  80. };
  81. /** The entire object returned by the songs endpoint of the genius API */
  82. export type ApiSongResult = {
  83. response: {
  84. song: SongObj;
  85. }
  86. }
  87. /** One result returned by the genius API search */
  88. export type SearchHit = {
  89. type: "song";
  90. result: SongBaseObj & {
  91. release_date_components: {
  92. year: number;
  93. month: number;
  94. day: number;
  95. };
  96. featured_artists: ArtistObj[];
  97. };
  98. };
  99. /** Result returned by the songs endpoint of the genius API */
  100. export type SongObj = SongBaseObj & {
  101. album: {
  102. api_path: string;
  103. cover_art_url: string;
  104. full_title: string;
  105. id: number;
  106. name: string;
  107. url: string;
  108. artist: ArtistObj;
  109. },
  110. translation_songs: {
  111. api_path: string;
  112. id: number;
  113. language: string;
  114. lyrics_state: string;
  115. path: string;
  116. title: string;
  117. url: string;
  118. }[];
  119. };
  120. type SongBaseObj = {
  121. api_path: string;
  122. artist_names: string;
  123. primary_artist: ArtistObj;
  124. full_title: string;
  125. header_image_thumbnail_url: string;
  126. header_image_url: string;
  127. id: number;
  128. language: string;
  129. lyrics_owner_id: number;
  130. lyrics_state: "complete";
  131. path: string;
  132. pyongs_count: number;
  133. relationships_index_url: string;
  134. song_art_image_thumbnail_url: string;
  135. song_art_image_url: string;
  136. title: string;
  137. title_with_featured: string;
  138. url: string;
  139. };
  140. type ArtistObj = {
  141. api_path: string;
  142. header_image_url: string;
  143. id: number;
  144. image_url: string;
  145. name: string;
  146. url: string;
  147. }
  148. export interface Album {
  149. name: string;
  150. fullTitle: string;
  151. url: string;
  152. coverArt: string | null;
  153. id: number;
  154. artist: Artist;
  155. }
  156. //#SECTION internal
  157. export type SupportedMethods = "GET";