-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
types.ts
executable file
·260 lines (234 loc) · 5.59 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import { LovelaceCardConfig } from 'custom-card-helpers';
import { TemplateResult } from 'lit-element';
export enum DisplayStyle {
Grid = 'grid',
List = 'list',
}
export enum PlaylistType {
default = 'default',
featured = 'featured',
discover_weekly = 'discover-weekly',
}
export enum ConfigEntry {
Name,
Account,
Spotify_Entity,
Country_Code,
Limit,
Playlist_Type,
Always_Play_Random_Song,
Height,
Display_Style,
Grid_Covers_Per_Row,
Grid_Center_Covers,
Grid_Show_Title,
Hide_Warning,
Default_Device,
Filter_Devices,
Known_Connect_Devices,
Include_Playlists,
Hide_Connect_Devices,
Hide_Chromecast_Devices,
Hide_Top_Header,
Hide_Currently_Playing,
Hide_Playback_Controls,
}
export interface SpotifyCardConfig extends LovelaceCardConfig {
//card type
type: string;
// name of the spotify entity
spotify_entity?: string;
//optinal account
account?: string;
//optinal card title
name?: string;
//displayed playlist type
playlist_type: string;
//country code for featured playlist
country_code?: string;
//optional height of the card
height?: number;
//amount of playlist shown
limit?: number;
//hide warnings if some are present
hide_warning?: boolean;
//display style of playlist e.g. list or grid
display_style?: string;
//start always random when clicking a playlist. usefull especially in grid-view mode
always_play_random_song?: boolean;
//number of covers per row in grid
grid_covers_per_row?: number;
//Show album title in grid
grid_show_title?: boolean;
//preselected device
default_device?: string;
//filter the devices based on regex
filter_devices?: Array<string>;
//known spotify connect devices which not show by default (e.g. Sonos)
known_connect_devices?: Array<KnownConnectDevice>;
//select the playlists based on regex
include_playlists?: Array<string>;
//hide all Spotify Connect devices
hide_connect_devices?: boolean;
//hide all Chromecast devices
hide_chromecast_devices?: boolean;
//hide the top header row and display the spotify icon at the bottom
hide_top_header?: boolean;
//hide the currently playing row
hide_currently_playing?: boolean;
//hide the playback controls
hide_playback_controls?: boolean;
// locale
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function isConnectDevice(object: any): object is ConnectDevice {
return 'name' in object;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function isCurrentPlayer(object: any): object is CurrentPlayer {
return 'currently_playing_type' in object;
}
export interface PlaybackOptions {
uri: string;
force_playback: boolean;
random_song: boolean;
account?: string;
device_name?: string;
spotify_device_id?: string;
}
export interface ConnectDevice {
id: string;
is_active: boolean;
is_private_session: boolean;
is_restricted: boolean;
name: string;
type: string;
volume_percent: number;
}
export interface KnownConnectDevice {
id: string;
name: string;
entity_id?: string;
}
export interface ChromecastDevice {
id: string;
friendly_name: string;
}
export interface CurrentPlayer {
device: ConnectDevice;
shuffle_state: boolean;
repeat_state: string;
timestamp: number;
context: Context;
progress_ms: number;
item: Item;
currently_playing_type: string;
actions: Actions;
is_playing: boolean;
}
export interface Playlist {
collaborative: boolean;
description: string;
external_urls: ExternalUrls;
href: string;
id: string;
images: Image[];
name: string;
owner: Owner;
primary_color?: any;
public: boolean;
snapshot_id: string;
tracks: Tracks;
type: string;
uri: string;
}
export interface ExternalUrls {
spotify: string;
}
export interface Context {
external_urls: ExternalUrls;
href: string;
type: string;
uri: string;
}
export interface Artist {
external_urls: ExternalUrls;
href: string;
id: string;
name: string;
type: string;
uri: string;
}
export interface Image {
height?: number;
url: string;
width?: number;
}
export interface Album {
album_type: string;
artists: Artist[];
available_markets: string[];
external_urls: ExternalUrls;
href: string;
id: string;
images: Image[];
name: string;
release_date: string;
release_date_precision: string;
total_tracks: number;
type: string;
uri: string;
}
export interface ExternalIds {
isrc: string;
}
export interface Item {
album: Album;
artists: Artist[];
available_markets: string[];
disc_number: number;
duration_ms: number;
explicit: boolean;
external_ids: ExternalIds;
external_urls: ExternalUrls;
href: string;
id: string;
is_local: boolean;
name: string;
popularity: number;
preview_url: string;
tags: any[];
track_number: number;
type: string;
uri: string;
}
export interface Disallows {
resuming: boolean;
}
export interface Actions {
disallows: Disallows;
}
export interface Owner {
display_name: string;
external_urls: ExternalUrls;
href: string;
id: string;
type: string;
uri: string;
}
export interface Tracks {
href: string;
total: number;
}
export interface ValueChangedEvent extends Event {
target: any;
timeStamp: number;
}
export interface DeviceList {
html: TemplateResult;
count: number;
}
export interface PlaylistFilter {
key: string;
pattern: RegExp;
}