feat: refactor platforms to support multiple TMDB provider IDs per platform

- Replace `tmdbProviderId` (single int) with a many-to-many `platformTmdbProviders` join table so one platform entry can map to multiple TMDB provider IDs (e.g. a single "Max" platform covers several regional TMDB IDs)
- Add `isSubscription` flag to platforms to distinguish subscription services from transactional ones, replacing the old `displayOrder` field in API responses
- Add `getPlatformTmdbIds` / `getPlatformTmdbIdMap` helpers in `@sofa/core/platforms` and thread them through discover, explore, and platform list procedures
- Replace `providerId: number` with `platformId: string` (UUID) in discover input schema so the client never needs to resolve TMDB IDs
- Add `scripts/sync-tmdb-providers.ts` script to pull live provider data from TMDB and update `platforms.json`
- Split native title detail availability into separate "Stream" and "Buy or Rent" sections matching the web pattern
- Add two new DB migrations for the join table and platform schema changes
This commit is contained in:
2026-03-24 20:54:34 -04:00
parent 7fedccb4fd
commit b0172a2b25
58 changed files with 8291 additions and 907 deletions
+7 -3
View File
@@ -16,6 +16,7 @@ const {
userEpisodeWatches,
userTitleStatus,
userRatings,
platformTmdbIds,
platforms,
titleAvailability,
userPlatforms,
@@ -178,9 +179,9 @@ export function insertPlatform(
id?: string;
name?: string;
tmdbProviderId?: number;
tmdbProviderIds?: number[];
logoPath?: string;
urlTemplate?: string;
displayOrder?: number;
} = {},
) {
const id = overrides.id ?? "platform-1";
@@ -189,12 +190,15 @@ export function insertPlatform(
.values({
id,
name: overrides.name ?? "Netflix",
tmdbProviderId: overrides.tmdbProviderId ?? 8,
logoPath: overrides.logoPath ?? "/logo.png",
urlTemplate: overrides.urlTemplate ?? "https://www.netflix.com/search?q={title}",
displayOrder: overrides.displayOrder ?? 1,
})
.run();
const tmdbIds = overrides.tmdbProviderIds ?? [overrides.tmdbProviderId ?? 8];
for (const tmdbId of tmdbIds) {
testDb.insert(platformTmdbIds).values({ platformId: id, tmdbProviderId: tmdbId }).run();
}
return id;
}