Test

Merged
SW
4mo ago
+562-5

Summary by cubic

Adds POST /api/catalogs to create a catalog or materialize one from a valuation snapshot. Enforces auth-derived ownership, input validation, and idempotent snapshot claims.

  • New Features

    • POST /api/catalogs accepts { name?, snapshot? } (at least one); includes CORS preflight.
    • Auth via validateAuthContext; owner comes from credentials, not the body.
    • Name-only: creates a catalog and links account_catalogs; returns { status, catalog, songs_added: 0 }.
    • Snapshot: verifies ownership, returns existing catalog if already claimed, else creates catalog, links account, adds deduped songs from song_measurements, updates the snapshot; returns { songs_added }.
    • Supabase helpers added: insertCatalog, selectCatalogById, insertAccountCatalog; selectSongMeasurements now supports a snapshot filter.
  • Bug Fixes

    • Materializes songs from song_measurements by snapshot instead of snapshot.isrcs to avoid empty catalogs for album-scoped runs.