export type PrimaryArtistInput = {name: string, spotify_artist_url?: string | undefined, apple_music_artist_url?: string | undefined, soundcloud_artist_url?: string | undefined, meta_artist_url?: string | undefined}; export type ContributorInput = {name?: string | undefined, role?: string | undefined, roleId?: number | undefined, contributorRoleGroupId?: number | undefined}; export type ArtistLocalizationInput = {name?: string | undefined, language?: string | undefined, languageId?: number | undefined, phoneticName?: string | undefined, language_and_script_code?: string | undefined}; export type TitleLocalizationInput = {name?: string | undefined, language?: string | undefined, languageId?: number | undefined, phoneticName?: string | undefined, language_and_script_code?: string | undefined}; export type ReleaseInput = {title: string, title_version?: string | undefined, primary_artist_name: string, primary_artists?: Array | undefined, spotify_artist_urls?: (Array) | undefined, apple_music_artist_urls?: (Array) | undefined, spotify_artist_url?: string | undefined, apple_music_artist_url?: string | undefined, genre: string, sub_genre?: string | undefined, second_genre?: string | undefined, release_date: string, label?: string | undefined, audio_language?: string | undefined, metadata_language?: string | undefined, metadata_language_country?: string | undefined, language_and_script_code?: string | undefined, distribution_store_ids?: (Array | null) | undefined, pline_year?: string | undefined, pline_owner?: string | undefined, cline_year?: string | undefined, cline_owner?: string | undefined, cover_art_file_url: string, contributors?: Array | undefined, artist_locals?: Array | undefined, title_locals?: Array | undefined}; export type WriterInput = {name: string, society?: string | undefined, ipi?: string | undefined, share_percent?: number | undefined}; export type TrackInput = {title: string, title_version?: string | undefined, primary_artist_name?: string | undefined, primary_artists?: Array | undefined, audio_file_url: string, explicit_flag: boolean, track_type?: ('original' | 'cover' | 'public_domain') | undefined, isrc?: string | undefined, genre?: string | undefined, language?: string | undefined, language_and_script_code?: string | undefined, lyrics?: string | undefined, preview_start_seconds?: number | undefined, pline_year?: string | undefined, pline_owner?: string | undefined, cline_year?: string | undefined, cline_owner?: string | undefined, writers: Array, contributors?: Array | undefined, artist_locals?: Array | undefined, title_locals?: Array | undefined}; export type DraftRequest = {release?: ReleaseInput | undefined, tracks?: Array | undefined, track_patches?: Array> | undefined, upload_requests?: Array> | undefined, status?: string | undefined, mode?: ('delta' | 'replace') | undefined, release_id?: string | undefined, conversation_id?: string | undefined}; export type CreateApiDraftsArgs = {body: DraftRequest}; export type CreateApiDraftsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upsert a work-in-progress release snapshot * * POST /drafts */ export const createApiDrafts = async (args: CreateApiDraftsArgs, options?: CreateApiDraftsOptions) => { const {baseUrl = "https://once.app/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/drafts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };