ML-185.1: expose named cover sizes in collection API

This commit is contained in:
Claudio Ortolina
2026-05-15 22:49:06 +01:00
parent f1b33fdc5f
commit b4710e10c8
4 changed files with 61 additions and 23 deletions
@@ -1,10 +1,11 @@
---
id: ML-185.1
title: Expose named cover sizes in collection API
status: To Do
assignee: []
status: Done
assignee:
- Codex
created_date: "2026-05-15 21:20"
updated_date: "2026-05-15 21:40"
updated_date: "2026-05-15 21:44"
labels:
- api
- artwork
@@ -35,11 +36,11 @@ Context for implementer: `MusicLibraryWeb.CollectionJSON` currently builds `cove
<!-- AC:BEGIN -->
- [ ] #1 Collection API responses that render records include a named cover object with original, large, medium, and small URLs.
- [ ] #2 The generated URLs encode no width for original, 1000 px for large, 460 px for medium, and 80 px for small.
- [ ] #3 Legacy flat cover URL fields are removed from the collection JSON contract unless a compatibility decision is explicitly documented during implementation.
- [ ] #4 Controller tests assert the new cover contract for collection record responses.
- [ ] #5 Production Hurl smoke coverage captures and requests a cover URL from the new contract.
- [x] #1 Collection API responses that render records include a named cover object with original, large, medium, and small URLs.
- [x] #2 The generated URLs encode no width for original, 1000 px for large, 460 px for medium, and 80 px for small.
- [x] #3 Legacy flat cover URL fields are removed from the collection JSON contract unless a compatibility decision is explicitly documented during implementation.
- [x] #4 Controller tests assert the new cover contract for collection record responses.
- [x] #5 Production Hurl smoke coverage captures and requests a cover URL from the new contract.
<!-- AC:END -->
## Implementation Plan
@@ -52,3 +53,23 @@ Context for implementer: `MusicLibraryWeb.CollectionJSON` currently builds `cove
4. Update `test/prod.hurl` to capture a cover URL from the new cover object.
5. Run `mix test test/music_library_web/controllers/collection_controller_test.exs` and any focused asset-controller test if URL generation or transform behavior changes.
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Implemented the collection record cover contract as a `covers` object with `original`, `large`, `medium`, and `small` URLs. The old flat fields were removed from `MusicLibraryWeb.CollectionJSON`; exact-map controller expectations verify the legacy fields are absent. Ran `mix test test/music_library_web/controllers/collection_controller_test.exs` successfully: 16 tests passed. Dependency warnings were emitted during compilation, but no warnings from the changed project files.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Updated the collection API record representation to expose named cover variants through `covers.original`, `covers.large`, `covers.medium`, and `covers.small`. The generated asset transform widths are unscaled for `original`, 1000 px for `large`, 460 px for `medium`, and 80 px for `small`; the legacy flat cover URL fields are no longer emitted.
Updated the controller test expected payloads to assert the new exact response shape and switched the production Hurl smoke capture to `$.covers.original`.
Tests run: `mix test test/music_library_web/controllers/collection_controller_test.exs` (16 passed).
<!-- SECTION:FINAL_SUMMARY:END -->