feat(sessions): accept artistId on POST /api/sessions
Merged
AR
5mo ago+92+92+01234567890123456789-2-2-0123456789
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.
validateCreateSessionBodyacceptsartistId(UUID, optional).buildSessionInsertRowwritesartist_idfromartistId(defaults tonull).createSessionHandlerforwards the validatedartistIdinto the insert.toSessionResponseexposesartistIdon the camelCase response.types/database.types.tsupdated withsessions.artist_id(Row/Insert/Update +sessions_artist_id_fkeyrelationship) — mirrors whatpnpm update-typeswould 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_idonsessions(defaults to null). - Returns
artistIdon session responses (create and read).
- Accepts
-
Migration
- Depends on database#27 adding
sessions.artist_idand its FK. Apply before deploy. - Types updated to match the post-migration schema; regenerating should be a no-op afterward.
- Depends on database#27 adding
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.