mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
- 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
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import {
|
|
getAllPlatforms,
|
|
getTmdbProviderIdsByPlatformIds,
|
|
getTmdbProviderIdsForPlatform,
|
|
getUserPlatformIds,
|
|
getUserPlatforms,
|
|
hasUserPlatforms,
|
|
platformIdsExist,
|
|
setUserPlatforms,
|
|
} from "@sofa/db/queries/user-platforms";
|
|
|
|
export function listPlatforms() {
|
|
return getAllPlatforms();
|
|
}
|
|
|
|
export function getUserPlatformList(userId: string) {
|
|
return getUserPlatforms(userId);
|
|
}
|
|
|
|
export function getUserPlatformIdList(userId: string) {
|
|
return getUserPlatformIds(userId);
|
|
}
|
|
|
|
export function updateUserPlatforms(userId: string, platformIds: string[]): void {
|
|
if (platformIds.length > 0 && !platformIdsExist(platformIds)) {
|
|
throw new Error("One or more platform IDs do not exist");
|
|
}
|
|
setUserPlatforms(userId, platformIds);
|
|
}
|
|
|
|
export function hasUserSetPlatforms(userId: string): boolean {
|
|
return hasUserPlatforms(userId);
|
|
}
|
|
|
|
export function getPlatformTmdbIds(platformId: string): number[] {
|
|
return getTmdbProviderIdsForPlatform(platformId);
|
|
}
|
|
|
|
export function getPlatformTmdbIdMap(platformIds: string[]): Map<string, number[]> {
|
|
return getTmdbProviderIdsByPlatformIds(platformIds);
|
|
}
|