dacb8b9278
Replace the faked ConnectPage login with a real /auth/login -> /auth/me
flow, including loading/error states. Add a backend-contract adapter layer
(api/mappers.ts) translating the backend's snake_case, lean *Out schemas and
{items,total,limit,offset} paging into the UI's camelCase domain types, so
swapping backends only touches the mappers.
- auth: chained login (tokens) + /auth/me (user); refresh on snake_case;
expiresIn optional (reauth is 401-driven, backend sends no TTL)
- streaming: GET /stream/{id}?token= (token query param for <audio>); SW
audio cache route + tests follow the path change (token stays cache-stable)
- library/playlists/likes/admin: correct paths (/tracks not /library/tracks),
page/pageSize<->limit/offset, duration_seconds->durationMs, likes as
append-only POST /likes event-log, admin is_superuser<->role
- downloads/storage: marked provisional (backend routes still stubs)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { api } from '../index';
|
|
import type { StorageStats } from '../types';
|
|
|
|
// NOTE: the backend `/storage` routes are still unimplemented stubs (no body /
|
|
// no schema), and the real paths differ from these placeholders (`GET /storage`,
|
|
// `/storage/duplicates`, `/storage/broken`, `/storage/missing-metadata`,
|
|
// `POST /storage/cleanup`). Re-point paths and add snake→camel mappers (see
|
|
// `mappers.ts`) once the backend defines the storage response shapes; until then
|
|
// these are provisional and unused by the UI.
|
|
|
|
export const storageApi = api.injectEndpoints({
|
|
endpoints: (build) => ({
|
|
getStorageStats: build.query<StorageStats, void>({
|
|
query: () => '/storage/stats',
|
|
providesTags: ['Storage'],
|
|
}),
|
|
scanStorage: build.mutation<{ jobId: string }, void>({
|
|
query: () => ({ url: '/storage/scan', method: 'POST' }),
|
|
invalidatesTags: ['Storage', 'Track', 'Album', 'Artist'],
|
|
}),
|
|
deleteTrackFile: build.mutation<void, string>({
|
|
query: (trackId) => ({
|
|
url: `/storage/tracks/${trackId}`,
|
|
method: 'DELETE',
|
|
}),
|
|
invalidatesTags: ['Storage', { type: 'Track', id: undefined }],
|
|
}),
|
|
}),
|
|
overrideExisting: false,
|
|
});
|
|
|
|
export const {
|
|
useGetStorageStatsQuery,
|
|
useScanStorageMutation,
|
|
useDeleteTrackFileMutation,
|
|
} = storageApi;
|