Skip to content

feat: add flowsheet entry_type discriminated union with V2 API#134

Merged
jakebromberg merged 8 commits intomainfrom
feature/flowsheet-entry-type-discriminated-union
Jan 31, 2026
Merged

feat: add flowsheet entry_type discriminated union with V2 API#134
jakebromberg merged 8 commits intomainfrom
feature/flowsheet-entry-type-discriminated-union

Conversation

@jakebromberg
Copy link
Member

@jakebromberg jakebromberg commented Jan 22, 2026

Summary

Add an explicit entry_type discriminated union to flowsheet entries in the database, with V1 API compatibility and a V2 playlist endpoint for clean discriminated union responses.

Entry Types

Type Description
track Song play
show_start Show begins
show_end Show ends
dj_join DJ joins show
dj_leave DJ leaves show
talkset DJ talk segment (announcements, station ID)
breakpoint Hour marker (top of hour transitions)
message Custom message

Database Changes

  • Add flowsheet_entry_type enum
  • Add entry_type column with migration and backfill
  • Add index for filtering by entry type

API Changes

V1 API - Additive change only:

  • All responses now include entry_type field
  • No breaking changes

V2 API - Single endpoint:

GET /v2/flowsheet/playlist  - Returns show info with entries in discriminated union format

V1 vs V2 Playlist Response

V1 /flowsheet/playlist: entries include all fields

{
  "entries": [{
    "id": 123,
    "entry_type": "track",
    "artist_name": "Built to Spill",
    "message": null,
    ...
  }]
}

V2 /v2/flowsheet/playlist: entries use clean discriminated union (no irrelevant fields)

{
  "entries": [{
    "id": 123,
    "entry_type": "track",
    "artist_name": "Built to Spill",
    ...
  }]
}

Test plan

  • 23 unit tests for transformToV2() function
  • V2 playlist integration test
  • V1 entry_type compatibility test
  • Run migration on dev database
  • Verify backfill: SELECT entry_type, COUNT(*) FROM flowsheet GROUP BY entry_type
  • Test legacy mirror sync with MySQL database

@jakebromberg jakebromberg force-pushed the feature/flowsheet-entry-type-discriminated-union branch 3 times, most recently from 782a2a3 to cc1136e Compare January 22, 2026 06:22
@jakebromberg jakebromberg force-pushed the feature/flowsheet-entry-type-discriminated-union branch from cc1136e to 262b1fe Compare January 22, 2026 18:41
@jakebromberg jakebromberg force-pushed the feature/flowsheet-entry-type-discriminated-union branch 2 times, most recently from 917a948 to 305797d Compare January 31, 2026 12:51
Jake Bromberg added 3 commits January 31, 2026 05:03
Add explicit entry_type field to flowsheet entries, enabling cleaner API
responses and type-safe client code. Maintains V1 compatibility while
providing a new V2 API with discriminated union responses.

Database changes:
- Add flowsheet_entry_type enum (track, show_start, show_end, dj_join,
  dj_leave, talkset, breakpoint, message)
- Add entry_type column with migration and backfill
- Add index for filtering by entry_type

V2 API endpoints:
- GET /v2/flowsheet - Returns discriminated union format
- POST /v2/flowsheet/track - Add track entry
- POST /v2/flowsheet/talkset - Add talkset entry
- POST /v2/flowsheet/breakpoint - Add breakpoint entry
- POST /v2/flowsheet/message - Add custom message
- PATCH/DELETE /v2/flowsheet/:id - Update/delete by path param

Tests:
- 23 unit tests for transformToV2() function
- ~350 lines of V2 API integration tests
@jakebromberg jakebromberg force-pushed the feature/flowsheet-entry-type-discriminated-union branch from b524661 to 61980f1 Compare January 31, 2026 18:02
Jake Bromberg and others added 5 commits January 31, 2026 10:05
Add entry_type to FSEntryRaw type and transformToIFSEntry function
so that GET /flowsheet returns the entry_type field as expected.
The /request route was missing after rebase onto main.
@jakebromberg jakebromberg merged commit 40c3a87 into main Jan 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant