feat(web): extend ArtistRef/AlbumRef + add HomePayload + new query keys

Adds sort_name/cover_url to ArtistRef, sort_title to AlbumRef (matching
backend Task 5 wire shape), HomePayload type, and qk.home/albumsAlpha/
artistTracks query keys. Updates existing test fixtures to satisfy the
new required fields.

Verified clean via 'npm run check' (0 errors, only pre-existing warnings).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 20:12:25 -04:00
parent c5e42ec8c2
commit b1f2227d62
12 changed files with 42 additions and 16 deletions
+8
View File
@@ -30,3 +30,11 @@ describe('qk search keys', () => {
expect(qk.searchTracks('foo')).toEqual(['searchTracks', { q: 'foo' }]);
});
});
describe('qk M6a keys', () => {
test('M6a query keys are stable', () => {
expect(qk.home()).toEqual(['home']);
expect(qk.albumsAlpha()).toEqual(['albumsAlpha']);
expect(qk.artistTracks('a1')).toEqual(['artistTracks', 'a1']);
});
});
+3
View File
@@ -34,6 +34,9 @@ export const qk = {
['adminQuarantineActions', { limit: limit ?? 50 }] as const,
suggestions: (limit?: number) =>
['suggestions', { limit: limit ?? 12 }] as const,
home: () => ['home'] as const,
albumsAlpha: () => ['albumsAlpha'] as const,
artistTracks: (artistId: string) => ['artistTracks', artistId] as const,
};
export function createArtistsQuery(sort: ArtistSort) {
+13
View File
@@ -12,12 +12,15 @@ export type Page<T> = {
export type ArtistRef = {
id: string;
name: string;
sort_name: string;
album_count: number;
cover_url: string; // "" when no representative album cover
};
export type AlbumRef = {
id: string;
title: string;
sort_title: string;
artist_id: string;
artist_name: string;
year?: number;
@@ -236,3 +239,13 @@ export type ArtistSuggestion = {
score: number;
attribution: SeedContribution[]; // up to 3 entries, ordered by contribution DESC
};
// Mirrors internal/api/types.go HomePayload. All slices are non-null
// per the server contract — empty sections render as [].
export type HomePayload = {
recently_added_albums: AlbumRef[];
rediscover_albums: AlbumRef[];
rediscover_artists: ArtistRef[];
most_played_tracks: TrackRef[];
last_played_artists: ArtistRef[];
};