import * as R from './Resource'; import * as P from './Presentation'; import * as A from './Application'; import * as T from './Theme'; import { Rule } from './Rule'; type Weekday = 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA' | 'SU'; export enum Frequency { weekly = 'weekly', monthly = 'monthly', } export type RecurrenceRule = { byday?: Weekday[]; bymonthday?: number[]; dtstart: string; freq: Frequency; interval: number; }; export type PlaylistItemResponse = { id: number; presentation_id: string | null; presentation: P.PresentationResponse | null; playlist_id: string | null; order?: number; // Note: The API does not return playlist items for a nested playlist. playlist: PlaylistResponse | null; }; export type PlaylistResponse = { id: string; name: string; description: string; schedule_type: string; auto_remove_on_schedule_end?: boolean; tzid: string | null; start_datetime: string | null; end_datetime: string | null; recurrence_rule: RecurrenceRule | null; items: PlaylistItemResponse[] | null; is_rule_on_items: boolean; rule: Rule | null; resource: R.ResourceResponse; }; export type PlaylistPlaybackContentResponse = { playlist_id?: string | null; playlists?: { [key: string]: PlaylistV2Response; }; presentations?: { [key: string]: P.PresentationV2Response; }; application_versions?: { [key: string]: A.ApplicationVersionResponse; }; themes?: { [key: string]: T.ThemeV2Response; }; applications?: { [key: string]: A.ApplicationV2Response; }; }; export type Playlist = { id: string; name: string; description: string; scheduleType: string; autoRemoveOnScheduleEnd?: boolean; tzid: string | null; startDatetime: string | null; endDatetime: string | null; recurrenceRule: RecurrenceRule | null; items: PlaylistItem[]; isRuleOnItems: boolean; rule: Rule | null; resource: R.Resource; }; export type PlaylistItem = { id: string; presentationId: string | null; presentation?: P.Presentation | null; playlistId: string | null; playlist?: Playlist | null; order?: number; }; export type PlaylistPlaybackContent = { playlistId?: string | null; playlists?: { [key: string]: PlaylistV2; }; presentations?: { [key: string]: P.PresentationV2; }; applicationVersions?: { [key: string]: A.ApplicationVersion; }; themes?: { [key: string]: T.ThemeV2; }; applications?: { [key: string]: A.ApplicationV2; }; }; export type PlaylistItemRequest = { presentation_id: string | null; playlist_id: string | null; }; export type CreatePlaylist = { name: string; description: string; scheduleType: string; autoRemoveOnScheduleEnd?: boolean; tzid: string | null; startDatetime: string | null; endDatetime: string | null; recurrenceRule: RecurrenceRule | null; items: Array<{ playlistId: string | null; presentationId: string | null; }>; isRuleOnItems: boolean; rule: Rule | null; resource: { r: { tags?: R.CreateTag[]; }; }; }; export type UpdatePlaylist = { name?: string; description?: string; scheduleType?: string; autoRemoveOnScheduleEnd?: boolean; tzid?: string | null; startDatetime?: string | null; endDatetime?: string | null; recurrenceRule?: RecurrenceRule | null; rule?: Rule | null; items?: Array<{ // NOTE: All playlist items are re-created on update. id: string; playlistId: string | null; presentationId: string | null; }>; isRuleOnItems?: boolean; resource?: { // NOTE: All tags are re-created on update. r?: { tags?: R.CreateTag[]; }; }; }; export type GetPlaylistsRequest = undefined; export type GetPlaylistsResponse = PlaylistResponse[]; export type CreatePlaylistRequest = { name: string; description: string; schedule_type: string; auto_remove_on_schedule_end?: boolean; tzid: string | null; start_datetime: string | null; end_datetime: string | null; recurrence_rule: RecurrenceRule | null; items: PlaylistItemRequest[] | null; is_rule_on_items: boolean; rule: Rule | null; resource?: { r?: { tags?: R.CreateTagResponse[]; }; }; }; export type CreatePlaylistResponse = PlaylistResponse; export type UpdatePlaylistRequest = Partial; export type UpdatePlaylistResponse = PlaylistResponse; export type DeletePlaylistRequest = undefined; export type DeletePlaylistResponse = string; export type CopyPlaylistRequest = { name?: string; target_folder_id?: string; copy_out_of_tree_unowned?: boolean; }; export type CopyPlaylistResponse = | { has_out_of_tree_unowned: true } | (PlaylistResponse & { has_out_of_tree_unowned?: boolean; supporting_content_folder_created?: boolean; }); export type CopyPlaylist = | { hasOutOfTreeUnowned: true; supportingContentFolderCreated: false } | (Playlist & { supportingContentFolderCreated: boolean }); // v2 types export interface PlaylistV2Response { id: string; name: string; mode: string; items_per_pass: number | null; schedule_type: string; tzid: string | null; start_datetime: string | null; end_datetime: string | null; parent_playlist_id: string | null; recurrence_rule: RecurrenceRule | null; rule: Rule | null; is_rule_on_items: boolean | false; r: { resource: R.ResourceV2Response; playlist_items: PlaylistItemV2Response[]; }; } export interface PlaylistItemV2Response { id: number; item_presentation_id: string | null; item_playlist_id: string | null; order: number; created_at: string; } export interface PlaylistV2 { id: string; name: string; mode: string; itemsPerPass: number | null; scheduleType: string; tzid: string | null; startDatetime: string | null; endDatetime: string | null; parentPlaylistId: string | null; recurrenceRule: RecurrenceRule | null; rule: Rule | null; isRuleOnItems?: boolean | false; r: { resource: R.ResourceV2; playlistItems: PlaylistItemV2[]; }; } export interface PlaylistItemV2 { id: string; presentationId: string | null; playlistId: string | null; order: number; createdAt: string; }