Files
Amphlify/Packages/AmphlifyKit/Sources/Store/Library.swift
T

51 lines
1.7 KiB
Swift

import Domain
import Foundation
public enum AlbumSort: String, CaseIterable, Sendable {
case recentlyAdded, title, artist, year
}
public struct SearchResults: Sendable {
public var artists: [Artist] = []
public var albums: [Album] = []
public var tracks: [Track] = []
public var playlists: [Playlist] = []
public init() {}
public var isEmpty: Bool {
artists.isEmpty && albums.isEmpty && tracks.isEmpty && playlists.isEmpty
}
}
public protocol Library: Sendable {
func apply(_ changes: [Change]) async
func cursor(for source: SourceID) async -> Cursor?
func setCursor(_ cursor: Cursor, for source: SourceID) async
func updates() async -> AsyncStream<Void>
func artists() async -> [Artist]
func artist(_ id: EntityID) async -> Artist?
func albums(sortedBy sort: AlbumSort) async -> [Album]
func albums(byArtist id: EntityID) async -> [Album]
func albums(inGenre genre: String) async -> [Album]
func album(_ id: EntityID) async -> Album?
func tracks() async -> [Track]
func tracks(inAlbum id: EntityID) async -> [Track]
func tracks(byArtist id: EntityID) async -> [Track]
func tracks(inGenre genre: String) async -> [Track]
func tracks(inPlaylist id: EntityID) async -> [Track]
func playlists() async -> [Playlist]
func stations() async -> [RadioStation]
func genres() async -> [Genre]
func recentlyPlayed(limit: Int) async -> [Album]
func mostPlayed(limit: Int) async -> [Album]
func favoriteTracks() async -> [Track]
func favorites() async -> Set<EntityID>
func setFavorite(_ isFavorite: Bool, for id: EntityID) async
func recordPlay(of track: Track, at date: Date) async
func search(_ query: String) async -> SearchResults
}