← Public packages
@kentcdodds/spotify
Spotify playback, playlist, search, library, and device helpers.
src/lib/export-types.ts
150 lines · 3.3 KB · TypeScriptimport type { SpotifyAccountAlias } from './accounts.ts'
/** Optional Spotify account alias on export params (defaults to personal). */
export type WithAccount = { account?: SpotifyAccountAlias | string }
export type DeviceParams = WithAccount & {
/**
* Preferred device selector for agents: match a Connect device by name
* (case-insensitive substring). Resolved inside the package so opaque
* Spotify device ids never need to cross the agent tool boundary.
*/
deviceName?: string
device_name?: string
/** Optional Connect device type filter (e.g. "Speaker", "Computer"). */
deviceType?: string
device_type?: string
/**
* Advanced escape hatch: raw Spotify Connect device id. Prefer
* `deviceName` / `deviceType`. Omit all selectors to use the active device.
*/
deviceId?: string
device_id?: string
}
export type PlayPauseParams = DeviceParams & {
fallbackDeviceId?: string | null
}
export type SeekParams = DeviceParams & {
positionMs?: number
position_ms?: number
}
export type PlaybackStateParams = WithAccount
export type GetQueueParams = WithAccount
export type GetDevicesParams = WithAccount
export type SkipParams = DeviceParams & {
direction?: 'next' | 'previous'
}
export type TransferPlaybackParams = DeviceParams & {
play?: boolean
}
export type SetVolumeParams = DeviceParams & {
volumePercent?: number
volume?: number
}
export type SetRepeatParams = DeviceParams & {
state: 'track' | 'context' | 'off'
}
export type SetShuffleParams = DeviceParams & {
state: boolean
}
export type PlayContextParams = DeviceParams & {
contextUri?: string
context_uri?: string
shuffled?: boolean
offsetIndex?: number
}
export type AddToQueueParams = DeviceParams & {
uri?: string
spotifyUri?: string
}
export type CreatePlaylistParams = WithAccount & {
name: string
description?: string
public?: boolean
}
export type PlaylistIdParams = WithAccount & {
playlistId?: string
playlist_id?: string
}
export type PlaylistTracksParams = PlaylistIdParams & {
uris: string[]
}
export type ListPlaylistsParams = WithAccount & {
limit?: number
}
export type SaveTracksParams = WithAccount & {
uris?: string[]
ids?: string[]
}
export type GetRecentlyPlayedParams = WithAccount & {
limit?: number
}
export type GetRecommendationsParams = WithAccount & {
seedTracks?: string[]
seedArtists?: string[]
seedGenres?: string[]
limit?: number
targetEnergy?: number
targetValence?: number
}
export type GetTopItemsParams = WithAccount & {
type: 'tracks' | 'artists'
timeRange?: 'short_term' | 'medium_term' | 'long_term'
time_range?: string
limit?: number
}
export type GetTrackParams = WithAccount & {
ids: string[]
}
export type SearchParams = WithAccount & {
query?: string
q?: string
types?: Array<'track' | 'album' | 'artist' | 'playlist'>
/** Alias of `types`. A single value or array; same allowed kinds. */
type?: 'track' | 'album' | 'artist' | 'playlist' | Array<'track' | 'album' | 'artist' | 'playlist'>
limit?: number
}
export type PlaybackControllerAction =
| 'status'
| 'state'
| 'queue'
| 'play'
| 'pause'
| 'play-pause'
| 'next'
| 'previous'
| 'transfer'
| 'set-volume'
| 'add-to-queue'
export type PlaybackControllerParams = DeviceParams & {
action?: PlaybackControllerAction
fallbackDeviceId?: string | null
volumePercent?: number
volume?: number
uri?: string
spotifyUri?: string
}