import type { VideoFeedSource } from './VideoFeedSource'; export type OpenVideoPlayerSource = | { type: 'channel'; channelId: string } | { type: 'playlist'; channelId: string; playlistId: string } | { type: 'dynamicContent'; channelId: string; parameters: Record; } | { type: 'hashtagPlaylist'; channelId: string; filterExpression: string } | { type: 'sku'; channelId: string; productIds: string[] } | { type: 'singleContent'; contentId: string }; // --------------------------------------------------------------------------- // Compile-time validation: keep OpenVideoPlayerSource in sync with VideoFeedSource. // // If a new type is added to VideoFeedSource, add it to OpenVideoPlayerSource // or to `_UnsupportedByPlayer`; otherwise the build will fail. // --------------------------------------------------------------------------- type _UnsupportedByPlayer = 'discover' | 'playlistGroup'; type _ExpectedPlayerTypes = Exclude; type _PublicPlayerTypes = OpenVideoPlayerSource['type']; type _Assert = T; // This type only compiles when both invariants hold: // 1. Every player-supported feed source (excluding the unsupported ones) is // present in OpenVideoPlayerSource. // 2. Every public OpenVideoPlayerSource type is a valid VideoFeedSource. export type _OpenVideoPlayerSourceChecks = [ _Assert<_ExpectedPlayerTypes extends _PublicPlayerTypes ? true : false>, _Assert<_PublicPlayerTypes extends VideoFeedSource ? true : false>, ];