export type GetApiApiV1MusicReleasesArgs = {genres?: boolean | undefined, tracks?: boolean | undefined, artists?: boolean | undefined, thumbnails?: boolean | undefined, metadata?: boolean | undefined, libraries?: Array | undefined, favorites?: boolean | undefined, orderBy?: ('createdAt' | 'title' | 'favoritedAt') | undefined, take?: number | undefined, skip?: number | undefined, order?: ('ASC' | 'DESC') | undefined}; export type GetApiApiV1MusicReleasesOptions = {baseUrl: string, LocalUserJWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * 🛡️ Query music releases. * * GET /api/v1/music/releases */ export const getApiApiV1MusicReleases = async (args: GetApiApiV1MusicReleasesArgs, options: GetApiApiV1MusicReleasesOptions) => { const {baseUrl, fetch: fetchFn = fetch, LocalUserJWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.genres != null) query.append("genres", String(args.genres)) if (args.tracks != null) query.append("tracks", String(args.tracks)) if (args.artists != null) query.append("artists", String(args.artists)) if (args.thumbnails != null) query.append("thumbnails", String(args.thumbnails)) if (args.metadata != null) query.append("metadata", String(args.metadata)) for (const item of args.libraries ?? []) query.append("libraries", String(item)) if (args.favorites != null) query.append("favorites", String(args.favorites)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.take != null) query.append("take", String(args.take)) if (args.skip != null) query.append("skip", String(args.skip)) if (args.order != null) query.append("order", String(args.order)) if (LocalUserJWT !== undefined) headers.set('authorization', `Bearer ${LocalUserJWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/music/releases${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };