feat(sessions): accept artistId on POST /api/sessions

Merged
AR
5mo ago
+92-2

Threads optional artistId through POST /api/sessions so new sessions can be linked to the artist they were created in. Backs the sidebar's artist filter once the chat client passes it through.

  • validateCreateSessionBody accepts artistId (UUID, optional).
  • buildSessionInsertRow writes artist_id from artistId (defaults to null).
  • createSessionHandler forwards the validated artistId into the insert.
  • toSessionResponse exposes artistId on the camelCase response.
  • types/database.types.ts updated with sessions.artist_id (Row/Insert/Update + sessions_artist_id_fkey relationship) — mirrors what pnpm update-types would emit after database#27 applies.

Depends on database#27 applying to prod for the new column to actually persist. Until then, inserts will fail at the DB layer; the types/code shape is correct and waits.

Test plan

  • After database#27 applies, POST /api/sessions { artistId: "<uuid>" } returns { session: { artistId: "<uuid>", ... }, chat }.
  • POST /api/sessions {} returns { session: { artistId: null, ... }, chat }.
  • POST /api/sessions { artistId: "not-a-uuid" } returns 400.

Summary by cubic

Adds optional artistId to POST /api/sessions and exposes it on session reads. Threads artistId through validation, insert, and responses; updates GET session test to expect artistId.

  • New Features

    • Accepts artistId (UUID, optional) in request body.
    • Persists artist_id on sessions (defaults to null).
    • Returns artistId on session responses (create and read).
  • Migration

    • Depends on database#27 adding sessions.artist_id and its FK. Apply before deploy.
    • Types updated to match the post-migration schema; regenerating should be a no-op afterward.

Summary by CodeRabbit

  • New Features
    • Sessions now support optional artist association. When creating a session, you can specify an artist ID, which will be stored and included in session responses. The artist ID field is optional and defaults to null if not provided.

Review Change Stack