import {z} from 'zod' export type SongListFeaturedCategory = 'Nothing' | 'Concerts' | 'VocaloidRanking' | 'Pools' | 'Other'; export type EntryThumbForApiContract = {mime?: (string | null) | undefined, name?: (string | null) | undefined, urlOriginal?: (string | null) | undefined, urlSmallThumb?: (string | null) | undefined, urlThumb?: (string | null) | undefined, urlTinyThumb?: (string | null) | undefined}; export type DiscType = 'Unknown' | 'Album' | 'Single' | 'EP' | 'SplitAlbum' | 'Compilation' | 'Video' | 'Artbook' | 'Game' | 'Fanmade' | 'Instrumental' | 'Other' | 'Drama'; export type OptionalDateTimeContract = {day?: (number | null) | undefined, isEmpty?: boolean | undefined, month?: (number | null) | undefined, year?: (number | null) | undefined}; export type ArtistType = 'Unknown' | 'Circle' | 'Label' | 'Producer' | 'Animator' | 'Illustrator' | 'Lyricist' | 'Vocaloid' | 'UTAU' | 'CeVIO' | 'OtherVoiceSynthesizer' | 'OtherVocalist' | 'OtherGroup' | 'OtherIndividual' | 'Utaite' | 'Band' | 'Vocalist' | 'Character' | 'SynthesizerV' | 'CoverArtist' | 'NEUTRINO' | 'VoiSona' | 'NewType' | 'Voiceroid' | 'Instrumentalist' | 'Designer' | 'VOICEVOX' | 'ACEVirtualSinger' | 'AIVOICE'; export type EntryStatus = 'Draft' | 'Finished' | 'Approved' | 'Locked'; export type ArtistContract = {additionalNames?: (string | null) | undefined, artistType?: ArtistType | undefined, deleted?: boolean | undefined, id?: number | undefined, name?: (string | null) | undefined, pictureMime?: (string | null) | undefined, releaseDate?: (string | null) | undefined, status?: EntryStatus | undefined, version?: number | undefined}; export type ArtistEventRoles = 'Default' | 'Dancer' | 'DJ' | 'Instrumentalist' | 'Organizer' | 'Promoter' | 'VJ' | 'Vocalist' | 'VoiceManipulator' | 'OtherPerformer' | 'Other'; export type ArtistForEventContract = {artist?: ArtistContract | undefined, effectiveRoles?: ArtistEventRoles | undefined, id?: number | undefined, name?: (string | null) | undefined, roles?: ArtistEventRoles | undefined}; export type EventCategory = 'Unspecified' | 'AlbumRelease' | 'Anniversary' | 'Club' | 'Concert' | 'Contest' | 'Convention' | 'Other' | 'Festival'; export type ContentLanguageSelection = 'Unspecified' | 'Japanese' | 'Romaji' | 'English'; export type LocalizedStringContract = {language?: ContentLanguageSelection | undefined, value?: (string | null) | undefined}; export type PVExtendedMetadata = {json?: (string | null) | undefined}; export type PVService = 'NicoNicoDouga' | 'Youtube' | 'SoundCloud' | 'Vimeo' | 'Piapro' | 'Bilibili' | 'File' | 'LocalFile' | 'Creofuga' | 'Bandcamp'; export type PVType = 'Original' | 'Reprint' | 'Other'; export type PVContract = {author?: (string | null) | undefined, createdBy?: (number | null) | undefined, description?: (string | null) | undefined, disabled?: boolean | undefined, extendedMetadata?: PVExtendedMetadata | undefined, id?: number | undefined, length?: number | undefined, name?: (string | null) | undefined, publishDate?: (string | null) | undefined, pvId?: (string | null) | undefined, service?: PVService | undefined, pvType?: PVType | undefined, thumbUrl?: (string | null) | undefined, url?: (string | null) | undefined}; export type WebLinkCategory = 'Official' | 'Commercial' | 'Reference' | 'Other'; export type WebLinkContract = {category?: WebLinkCategory | undefined, description?: (string | null) | undefined, descriptionOrUrl?: (string | null) | undefined, disabled?: boolean | undefined, id?: number | undefined, url?: (string | null) | undefined}; export type ReleaseEventSeriesContract = {additionalNames?: (string | null) | undefined, category?: EventCategory | undefined, deleted?: boolean | undefined, description?: (string | null) | undefined, id?: number | undefined, name?: (string | null) | undefined, pictureMime?: (string | null) | undefined, status?: EntryStatus | undefined, urlSlug?: (string | null) | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined}; export type SongListBaseContract = {featuredCategory?: SongListFeaturedCategory | undefined, id?: number | undefined, name?: (string | null) | undefined}; export type TagBaseContract = {additionalNames?: (string | null) | undefined, categoryName?: (string | null) | undefined, id?: number | undefined, name?: (string | null) | undefined, urlSlug?: (string | null) | undefined}; export type TagUsageForApiContract = {count?: number | undefined, tag?: TagBaseContract | undefined}; export type OptionalGeoPointContract = {formatted?: (string | null) | undefined, hasValue?: boolean | undefined, latitude?: (number | null) | undefined, longitude?: (number | null) | undefined}; export type VenueContract = {additionalNames?: (string | null) | undefined, address?: (string | null) | undefined, addressCountryCode?: (string | null) | undefined, coordinates?: OptionalGeoPointContract | undefined, deleted?: boolean | undefined, description?: (string | null) | undefined, id?: number | undefined, name?: (string | null) | undefined, status?: EntryStatus | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined}; export type ReleaseEventContract = {additionalNames?: (string | null) | undefined, category?: EventCategory | undefined, customName?: boolean | undefined, date?: (string | null) | undefined, deleted?: boolean | undefined, description?: (string | null) | undefined, endDate?: (string | null) | undefined, hasVenueOrVenueName?: boolean | undefined, id?: number | undefined, inheritedCategory?: EventCategory | undefined, name?: (string | null) | undefined, pictureMime?: (string | null) | undefined, series?: ReleaseEventSeriesContract | undefined, songList?: SongListBaseContract | undefined, status?: EntryStatus | undefined, urlSlug?: (string | null) | undefined, venue?: VenueContract | undefined, venueName?: (string | null) | undefined, version?: number | undefined}; export type WebLinkForApiContract = {category?: WebLinkCategory | undefined, description?: (string | null) | undefined, descriptionOrUrl?: (string | null) | undefined, disabled?: boolean | undefined, id?: number | undefined, url?: (string | null) | undefined}; export type VenueForApiContract = {additionalNames?: (string | null) | undefined, address?: (string | null) | undefined, addressCountryCode?: (string | null) | undefined, coordinates?: OptionalGeoPointContract | undefined, deleted?: boolean | undefined, description?: (string | null) | undefined, events?: (Array | null) | undefined, id?: number | undefined, name?: (string | null) | undefined, names?: (Array | null) | undefined, status?: EntryStatus | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined}; export type ReleaseEventForApiContract = {additionalNames?: (string | null) | undefined, artists?: (Array | null) | undefined, category?: EventCategory | undefined, date?: (string | null) | undefined, description?: (string | null) | undefined, endDate?: (string | null) | undefined, id?: number | undefined, mainPicture?: EntryThumbForApiContract | undefined, name?: (string | null) | undefined, names?: (Array | null) | undefined, pvs?: (Array | null) | undefined, series?: ReleaseEventSeriesContract | undefined, seriesId?: (number | null) | undefined, seriesNumber?: number | undefined, seriesSuffix?: (string | null) | undefined, songList?: SongListBaseContract | undefined, status?: EntryStatus | undefined, tags?: (Array | null) | undefined, urlSlug?: (string | null) | undefined, venue?: VenueForApiContract | undefined, venueName?: (string | null) | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined}; export type AlbumContract = {additionalNames?: (string | null) | undefined, artistString?: (string | null) | undefined, coverPictureMime?: (string | null) | undefined, createDate?: string | undefined, deleted?: boolean | undefined, discType?: DiscType | undefined, id?: number | undefined, name?: (string | null) | undefined, ratingAverage?: number | undefined, ratingCount?: number | undefined, releaseDate?: OptionalDateTimeContract | undefined, releaseEvent?: ReleaseEventForApiContract | undefined, status?: EntryStatus | undefined, version?: number | undefined}; export type ArtistCategories = 'Nothing' | 'Vocalist' | 'Producer' | 'Animator' | 'Label' | 'Circle' | 'Other' | 'Band' | 'Illustrator' | 'Subject'; export type ArtistRoles = 'Default' | 'Animator' | 'Arranger' | 'Composer' | 'Distributor' | 'Illustrator' | 'Instrumentalist' | 'Lyricist' | 'Mastering' | 'Publisher' | 'Vocalist' | 'VoiceManipulator' | 'Other' | 'Mixer' | 'Chorus' | 'Encoder' | 'VocalDataProvider' | 'RecordingEngineer'; export type ArtistForSongContract = {artist?: ArtistContract | undefined, categories?: ArtistCategories | undefined, effectiveRoles?: ArtistRoles | undefined, id?: number | undefined, isCustomName?: boolean | undefined, isSupport?: boolean | undefined, name?: (string | null) | undefined, roles?: ArtistRoles | undefined}; export type TranslationType = 'Original' | 'Romanized' | 'Translation'; export type LyricsForSongContract = {cultureCodes?: (Array | null) | undefined, id?: number | undefined, source?: (string | null) | undefined, translationType?: TranslationType | undefined, url?: (string | null) | undefined, value?: (string | null) | undefined}; export type PVServices = 'Nothing' | 'NicoNicoDouga' | 'Youtube' | 'SoundCloud' | 'Vimeo' | 'Piapro' | 'Bilibili' | 'File' | 'LocalFile' | 'Creofuga' | 'Bandcamp'; export type SongType = 'Unspecified' | 'Original' | 'Remaster' | 'Remix' | 'Cover' | 'Arrangement' | 'Instrumental' | 'Mashup' | 'MusicPV' | 'DramaPV' | 'Live' | 'Illustration' | 'Other' | 'Rearrangement' | 'ShortVersion'; export type SongForApiContract = {additionalNames?: (string | null) | undefined, albums?: (Array | null) | undefined, artists?: (Array | null) | undefined, artistString?: (string | null) | undefined, createDate?: string | undefined, defaultName?: (string | null) | undefined, defaultNameLanguage?: ContentLanguageSelection | undefined, deleted?: boolean | undefined, favoritedTimes?: number | undefined, id?: number | undefined, lengthSeconds?: number | undefined, lyrics?: (Array | null) | undefined, mainPicture?: EntryThumbForApiContract | undefined, maxMilliBpm?: (number | null) | undefined, mergedTo?: number | undefined, minMilliBpm?: (number | null) | undefined, name?: (string | null) | undefined, names?: (Array | null) | undefined, originalVersionId?: number | undefined, publishDate?: (string | null) | undefined, pvs?: (Array | null) | undefined, pvServices?: PVServices | undefined, ratingScore?: number | undefined, releaseEvent?: ReleaseEventForApiContract | undefined, releaseEvents?: (Array | null) | undefined, songType?: SongType | undefined, status?: EntryStatus | undefined, tags?: (Array | null) | undefined, thumbUrl?: (string | null) | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined, cultureCodes?: (Array | null) | undefined}; export type SongInListEditContract = {songInListId?: number | undefined, notes?: (string | null) | undefined, order?: number | undefined, song?: SongForApiContract | undefined}; export type SongListForEditForApiContract = {deleted?: boolean | undefined, description?: (string | null) | undefined, eventDate?: (string | null) | undefined, featuredCategory?: SongListFeaturedCategory | undefined, id?: number | undefined, mainPicture?: EntryThumbForApiContract | undefined, name?: (string | null) | undefined, songLinks?: (Array | null) | undefined, status?: EntryStatus | undefined, updateNotes?: (string | null) | undefined}; export type CreateApiApiSongListsArgs = {body: SongListForEditForApiContract}; export type CreateApiApiSongListsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const createApiApiSongListsResponse = z.number().int(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * POST /api/songLists */ export const createApiApiSongLists = async (args: CreateApiApiSongListsArgs, options: CreateApiApiSongListsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/songLists${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 validateResponse(createApiApiSongListsResponse, await res.json()) };