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.
186 lines
6.2 KiB
186 lines
6.2 KiB
import { |
|
Album, |
|
AlbumBaseWithRefs, |
|
AlbumWithRefs, |
|
Artist, |
|
ArtistBaseWithRefs, |
|
ArtistWithRefs, |
|
IntegrationData, |
|
IntegrationDataWithId, |
|
IntegrationDataWithSecret, |
|
isAlbumBaseWithRefs, |
|
isAlbumWithRefs, |
|
isArtistBaseWithRefs, |
|
isArtistWithRefs, |
|
isIntegrationData, |
|
isPartialIntegrationData, |
|
isTagBaseWithRefs, |
|
isTagWithRefs, |
|
isTrackBaseWithRefs, |
|
isTrackWithRefs, |
|
PartialIntegrationData, |
|
Tag, |
|
TagBaseWithRefs, |
|
TagWithRefs, |
|
TrackBaseWithRefs, |
|
TrackWithDetails, |
|
TrackWithRefs |
|
} from "../types/resources"; |
|
|
|
// The API supports RESTful access to single API resources: |
|
// - GET for retrieving details about a single item |
|
// - PUT for replacing a single item |
|
// - POST for creating a new item |
|
// - PATCH for modifying a single item |
|
// - DELETE for deleting a single item |
|
// |
|
// The above are implemented for: |
|
// - tracks |
|
// - artists |
|
// - albums |
|
// - tags |
|
// - integrations |
|
// |
|
// The following special requests exist in addition: |
|
// - Merge a tag into another using a POST |
|
// - List all integrations using a GET |
|
|
|
// Get track details (GET). |
|
export const GetTrackEndpoint = '/track/:id'; |
|
export type GetTrackResponse = TrackWithDetails; |
|
|
|
// Get artist details (GET). |
|
export const GetArtistEndpoint = '/artist/:id'; |
|
export type GetArtistResponse = Artist; |
|
|
|
// Get album details (GET). |
|
export const GetAlbumEndpoint = "/album/:id"; |
|
export type GetAlbumResponse = Album; |
|
|
|
// Get tag details (GET). |
|
export const GetTagEndpoint = "/tag/:id"; |
|
export type GetTagResponse = Tag; |
|
|
|
// Get integration details (GET). |
|
export const GetIntegrationEndpoint = "/integration/:id"; |
|
export type GetIntegrationResponse = IntegrationData; |
|
|
|
// Post new track (POST). |
|
export const PostTrackEndpoint = "/track"; |
|
export type PostTrackRequest = TrackWithRefs; |
|
export interface PostTrackResponse { id: number }; |
|
export const checkPostTrackRequest: (v: any) => boolean = isTrackWithRefs; |
|
|
|
// Post new artist (POST). |
|
export const PostArtistEndpoint = "/artist"; |
|
export type PostArtistRequest = ArtistWithRefs; |
|
export interface PostArtistResponse { id: number }; |
|
export const checkPostArtistRequest: (v: any) => boolean = isArtistWithRefs; |
|
|
|
// Post new album (POST). |
|
export const PostAlbumEndpoint = "/album"; |
|
export type PostAlbumRequest = AlbumWithRefs; |
|
export interface PostAlbumResponse { id: number }; |
|
export const checkPostAlbumRequest: (v: any) => boolean = isAlbumWithRefs; |
|
|
|
// Post new tag (POST). |
|
export const PostTagEndpoint = "/tag"; |
|
export type PostTagRequest = TagWithRefs; |
|
export interface PostTagResponse { id: number }; |
|
export const checkPostTagRequest: (v: any) => boolean = isTagWithRefs; |
|
|
|
// Post new integration (POST). |
|
export const PostIntegrationEndpoint = "/integration"; |
|
export type PostIntegrationRequest = IntegrationDataWithSecret; |
|
export interface PostIntegrationResponse { id: number }; |
|
export const checkPostIntegrationRequest: (v: any) => boolean = isIntegrationData; |
|
|
|
// Replace track (PUT). |
|
export const PutTrackEndpoint = "/track/:id"; |
|
export type PutTrackRequest = TrackWithRefs; |
|
export type PutTrackResponse = void; |
|
export const checkPutTrackRequest: (v: any) => boolean = isTrackWithRefs; |
|
|
|
// Replace artist (PUT). |
|
export const PutArtistEndpoint = "/artist/:id"; |
|
export type PutArtistRequest = ArtistWithRefs; |
|
export type PutArtistResponse = void; |
|
export const checkPutArtistRequest: (v: any) => boolean = isArtistWithRefs; |
|
|
|
// Replace album (PUT). |
|
export const PutAlbumEndpoint = "/album/:id"; |
|
export type PutAlbumRequest = AlbumWithRefs; |
|
export type PutAlbumResponse = void; |
|
export const checkPutAlbumRequest: (v: any) => boolean = isAlbumWithRefs; |
|
|
|
// Replace tag (PUT). |
|
export const PutTagEndpoint = "/tag/:id"; |
|
export type PutTagRequest = TagWithRefs; |
|
export type PutTagResponse = void; |
|
export const checkPutTagRequest: (v: any) => boolean = isTagWithRefs; |
|
|
|
// Replace integration (PUT). |
|
export const PutIntegrationEndpoint = "/integration/:id"; |
|
export type PutIntegrationRequest = IntegrationDataWithSecret; |
|
export type PutIntegrationResponse = void; |
|
export const checkPutIntegrationRequest: (v: any) => boolean = isIntegrationData; |
|
|
|
// Modify track (PATCH). |
|
export const PatchTrackEndpoint = "/track/:id"; |
|
export type PatchTrackRequest = TrackBaseWithRefs; |
|
export type PatchTrackResponse = void; |
|
export const checkPatchTrackRequest: (v: any) => boolean = isTrackBaseWithRefs; |
|
|
|
// Modify artist (PATCH). |
|
export const PatchArtistEndpoint = "/artist/:id"; |
|
export type PatchArtistRequest = ArtistBaseWithRefs; |
|
export type PatchArtistResponse = void; |
|
export const checkPatchArtistRequest: (v: any) => boolean = isArtistBaseWithRefs; |
|
|
|
// Modify album (PATCH). |
|
export const PatchAlbumEndpoint = "/album/:id"; |
|
export type PatchAlbumRequest = AlbumBaseWithRefs; |
|
export type PatchAlbumResponse = void; |
|
export const checkPatchAlbumRequest: (v: any) => boolean = isAlbumBaseWithRefs; |
|
|
|
// Modify tag (PATCH). |
|
export const PatchTagEndpoint = "/tag/:id"; |
|
export type PatchTagRequest = TagBaseWithRefs; |
|
export type PatchTagResponse = void; |
|
export const checkPatchTagRequest: (v: any) => boolean = isTagBaseWithRefs; |
|
|
|
// Modify integration (PATCH). |
|
export const PatchIntegrationEndpoint = "/integration/:id"; |
|
export type PatchIntegrationRequest = PartialIntegrationData; |
|
export type PatchIntegrationResponse = void; |
|
export const checkPatchIntegrationRequest: (v: any) => boolean = isPartialIntegrationData; |
|
|
|
// DELETE track. |
|
export const DeleteTrackEndpoint = '/track/:id'; |
|
export type DeleteTrackResponse = void |
|
|
|
// DELETE artist. |
|
export const DeleteArtistEndpoint = '/artist/:id'; |
|
export type DeleteArtistResponse = void |
|
|
|
// DELETE album. |
|
export const DeleteAlbumEndpoint = "/album/:id"; |
|
export type DeleteAlbumResponse = void |
|
|
|
// DELETE tag. |
|
export const DeleteTagEndpoint = "/tag/:id"; |
|
export type DeleteTagResponse = void |
|
|
|
// DELETE integration. |
|
export const DeleteIntegrationEndpoint = "/integration/:id"; |
|
export type DeleteIntegrationResponse = void |
|
|
|
// List integrations (GET). |
|
export const ListIntegrationsEndpoint = "/integration"; |
|
export type ListIntegrationsResponse = IntegrationDataWithId[]; |
|
|
|
// Merge tag (POST). |
|
// This will tag any items which are tagged by :id |
|
// with :toId instead, and then delete tag :id. |
|
export const MergeTagEndpoint = '/tag/:id/merge/:toId'; |
|
export type MergeTagResponse = void; |