You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
import * as api from '../../client/src/api'; |
|
import asJson from './asJson'; |
|
|
|
export function toApiTag(dbObj: any): api.TagDetails { |
|
return <api.TagDetails>{ |
|
tagId: dbObj['tags.id'], |
|
name: dbObj['tags.name'], |
|
parentId: dbObj['tags.parentId'], |
|
parent: dbObj.parent ? toApiTag(dbObj.parent) : undefined, |
|
}; |
|
} |
|
|
|
export function toApiArtist(dbObj: any) { |
|
return <api.ArtistDetails>{ |
|
artistId: dbObj['artists.id'], |
|
name: dbObj['artists.name'], |
|
storeLinks: asJson(dbObj['artists.storeLinks']), |
|
}; |
|
} |
|
|
|
export function toApiSong(dbObj: any, artists: any[], tags: any[], albums: any[]) { |
|
return <api.SongDetails>{ |
|
songId: dbObj['songs.id'], |
|
title: dbObj['songs.title'], |
|
storeLinks: asJson(dbObj['songs.storeLinks']), |
|
artists: artists.map((artist: any) => { |
|
return toApiArtist(artist); |
|
}), |
|
tags: tags.map((tag: any) => { |
|
return toApiTag(tag); |
|
}), |
|
albums: albums.map((album: any) => { |
|
return toApiAlbum(album); |
|
}), |
|
} |
|
} |
|
|
|
export function toApiAlbum(dbObj: any) { |
|
return <api.AlbumDetails>{ |
|
albumId: dbObj['albums.id'], |
|
name: dbObj['albums.name'], |
|
storeLinks: asJson(dbObj['albums.storeLinks']), |
|
}; |
|
} |