- Created apps/web/src/services/api/tracks.ts with tracksApi object - Exports: list, get, create, update, delete, getStats, getHistory, download, like, unlike, getLikes, createShare - Includes chunked upload methods: initiateChunkedUpload, uploadChunk, completeChunkedUpload - Includes batch operations: batchDelete, batchUpdate - Wraps existing track API functions from features/tracks/api/trackApi.ts - Includes getTrack from features/tracks/services/trackService.ts for single track retrieval - Re-exports all related types for convenience - Added to services/api/index.ts for barrel export - No TypeScript errors - Follows existing service layer pattern (similar to auth.ts) - Action 6.1.1.1 complete
149 lines
2.5 KiB
TypeScript
149 lines
2.5 KiB
TypeScript
/**
|
|
* Tracks API Service
|
|
* Action 6.1.1.1: Create tracks API service
|
|
* Service layer for track-related API operations
|
|
* Wraps existing track API functions into a unified service object
|
|
*/
|
|
|
|
import {
|
|
uploadTrack,
|
|
getTracks,
|
|
updateTrack,
|
|
getTrackStats,
|
|
getTrackHistory,
|
|
downloadTrack,
|
|
likeTrack,
|
|
unlikeTrack,
|
|
deleteTrack,
|
|
getTrackLikes,
|
|
createTrackShare,
|
|
initiateChunkedUpload,
|
|
uploadChunk,
|
|
completeChunkedUpload,
|
|
batchDeleteTracks,
|
|
batchUpdateTracks,
|
|
type TrackMetadata,
|
|
type UpdateTrackRequest,
|
|
type TrackStats,
|
|
type TrackHistory,
|
|
type CreateShareRequest,
|
|
type Share,
|
|
type TrackLikesResponse,
|
|
type GetTracksParams,
|
|
type GetTracksResponse,
|
|
type BatchDeleteRequest,
|
|
type BatchDeleteResponse,
|
|
type BatchUpdateRequest,
|
|
type BatchUpdateResponse,
|
|
} from '@/features/tracks/api/trackApi';
|
|
import { getTrack } from '@/features/tracks/services/trackService';
|
|
import type { Track } from '@/features/tracks/types/track';
|
|
|
|
/**
|
|
* Tracks API Service Object
|
|
* Action 6.1.1.1: Exports unified tracksApi object with all track operations
|
|
*/
|
|
export const tracksApi = {
|
|
/**
|
|
* List tracks with pagination and filters
|
|
*/
|
|
list: getTracks,
|
|
|
|
/**
|
|
* Get a single track by ID
|
|
*/
|
|
get: getTrack,
|
|
|
|
/**
|
|
* Create/upload a new track
|
|
*/
|
|
create: uploadTrack,
|
|
|
|
/**
|
|
* Update track metadata
|
|
*/
|
|
update: updateTrack,
|
|
|
|
/**
|
|
* Delete a track
|
|
*/
|
|
delete: deleteTrack,
|
|
|
|
/**
|
|
* Get track statistics
|
|
*/
|
|
getStats: getTrackStats,
|
|
|
|
/**
|
|
* Get track history
|
|
*/
|
|
getHistory: getTrackHistory,
|
|
|
|
/**
|
|
* Download a track
|
|
*/
|
|
download: downloadTrack,
|
|
|
|
/**
|
|
* Like a track
|
|
*/
|
|
like: likeTrack,
|
|
|
|
/**
|
|
* Unlike a track
|
|
*/
|
|
unlike: unlikeTrack,
|
|
|
|
/**
|
|
* Get track likes information
|
|
*/
|
|
getLikes: getTrackLikes,
|
|
|
|
/**
|
|
* Create a share link for a track
|
|
*/
|
|
createShare: createTrackShare,
|
|
|
|
/**
|
|
* Initiate chunked upload
|
|
*/
|
|
initiateChunkedUpload,
|
|
|
|
/**
|
|
* Upload a chunk
|
|
*/
|
|
uploadChunk,
|
|
|
|
/**
|
|
* Complete chunked upload
|
|
*/
|
|
completeChunkedUpload,
|
|
|
|
/**
|
|
* Batch delete tracks
|
|
*/
|
|
batchDelete: batchDeleteTracks,
|
|
|
|
/**
|
|
* Batch update tracks
|
|
*/
|
|
batchUpdate: batchUpdateTracks,
|
|
};
|
|
|
|
// Re-export types for convenience
|
|
export type {
|
|
Track,
|
|
TrackMetadata,
|
|
UpdateTrackRequest,
|
|
TrackStats,
|
|
TrackHistory,
|
|
CreateShareRequest,
|
|
Share,
|
|
TrackLikesResponse,
|
|
GetTracksParams,
|
|
GetTracksResponse,
|
|
BatchDeleteRequest,
|
|
BatchDeleteResponse,
|
|
BatchUpdateRequest,
|
|
BatchUpdateResponse,
|
|
};
|