import {z} from 'zod' export type UserGroupId = 'Nothing' | 'Limited' | 'Regular' | 'Trusted' | 'Moderator' | 'Admin'; export type UserLanguageProficiency = 'Nothing' | 'Basics' | 'Intermediate' | 'Advanced' | 'Native'; export type UserKnownLanguageContract = {cultureCode?: (string | null) | undefined, proficiency?: UserLanguageProficiency | undefined}; 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 OldUsernameContract = {date?: string | undefined, oldName?: (string | null) | undefined}; export type UserForApiContract = {active?: boolean | undefined, groupId?: UserGroupId | undefined, knownLanguages?: (Array | null) | undefined, mainPicture?: EntryThumbForApiContract | undefined, memberSince?: string | undefined, oldUsernames?: (Array | null) | undefined, verifiedArtist?: boolean | undefined, id?: number | undefined, name?: (string | 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 ContentLanguageSelection = 'Unspecified' | 'Japanese' | 'Romaji' | 'English'; export type DiscType = 'Unknown' | 'Album' | 'Single' | 'EP' | 'SplitAlbum' | 'Compilation' | 'Video' | 'Artbook' | 'Game' | 'Fanmade' | 'Instrumental' | 'Other' | 'Drama'; export type EntryType = 'Undefined' | 'Album' | 'Artist' | 'DiscussionTopic' | 'PV' | 'ReleaseEvent' | 'ReleaseEventSeries' | 'Song' | 'SongList' | 'Tag' | 'User' | 'Venue'; export type EventCategory = 'Unspecified' | 'AlbumRelease' | 'Anniversary' | 'Club' | 'Concert' | 'Contest' | 'Convention' | 'Other' | 'Festival'; 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 SongListFeaturedCategory = 'Nothing' | 'Concerts' | 'VocaloidRanking' | 'Pools' | 'Other'; export type SongType = 'Unspecified' | 'Original' | 'Remaster' | 'Remix' | 'Cover' | 'Arrangement' | 'Instrumental' | 'Mashup' | 'MusicPV' | 'DramaPV' | 'Live' | 'Illustration' | 'Other' | 'Rearrangement' | 'ShortVersion'; export type EntryStatus = 'Draft' | 'Finished' | 'Approved' | 'Locked'; 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 WebLinkCategory = 'Official' | 'Commercial' | 'Reference' | 'Other'; export type ArchivedWebLinkContract = {category?: WebLinkCategory | undefined, description?: (string | null) | undefined, disabled?: boolean | undefined, url?: (string | null) | undefined}; export type EntryForApiContract = {activityDate?: (string | null) | undefined, additionalNames?: (string | null) | undefined, artistString?: (string | null) | undefined, artistType?: ArtistType | undefined, createDate?: string | undefined, defaultName?: (string | null) | undefined, defaultNameLanguage?: ContentLanguageSelection | undefined, description?: (string | null) | undefined, discType?: DiscType | undefined, entryType?: EntryType | undefined, eventCategory?: EventCategory | undefined, id?: number | undefined, mainPicture?: EntryThumbForApiContract | undefined, name?: (string | null) | undefined, names?: (Array | null) | undefined, pvs?: (Array | null) | undefined, songListFeaturedCategory?: SongListFeaturedCategory | undefined, songType?: SongType | undefined, status?: EntryStatus | undefined, releaseEventSeriesName?: (string | null) | undefined, tagCategoryName?: (string | null) | undefined, tags?: (Array | null) | undefined, urlSlug?: (string | null) | undefined, version?: number | undefined, webLinks?: (Array | null) | undefined}; export type CommentForApiContract = {author?: UserForApiContract | undefined, authorName?: (string | null) | undefined, created?: string | undefined, entry?: EntryForApiContract | undefined, id?: number | undefined, message?: (string | null) | undefined}; export type CreateApiApiUsersIdProfileCommentsArgs = {id: number, body: CommentForApiContract}; export type CreateApiApiUsersIdProfileCommentsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const userGroupId = z.enum(["Nothing", "Limited", "Regular", "Trusted", "Moderator", "Admin"]); export const userLanguageProficiency = z.enum(["Nothing", "Basics", "Intermediate", "Advanced", "Native"]); export const userKnownLanguageContract = z.object({cultureCode: z.string().nullable().optional(), proficiency: userLanguageProficiency.optional()}); export const entryThumbForApiContract = z.object({mime: z.string().nullable().optional(), name: z.string().nullable().optional(), urlOriginal: z.string().nullable().optional(), urlSmallThumb: z.string().nullable().optional(), urlThumb: z.string().nullable().optional(), urlTinyThumb: z.string().nullable().optional()}); export const oldUsernameContract = z.object({date: z.string().optional(), oldName: z.string().nullable().optional()}); export const userForApiContract = z.object({active: z.boolean().optional(), groupId: userGroupId.optional(), knownLanguages: z.array(userKnownLanguageContract).nullable().optional(), mainPicture: entryThumbForApiContract.optional(), memberSince: z.string().optional(), oldUsernames: z.array(oldUsernameContract).nullable().optional(), verifiedArtist: z.boolean().optional(), id: z.number().int().optional(), name: z.string().nullable().optional()}); export const artistType = z.enum(["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 const contentLanguageSelection = z.enum(["Unspecified", "Japanese", "Romaji", "English"]); export const discType = z.enum(["Unknown", "Album", "Single", "EP", "SplitAlbum", "Compilation", "Video", "Artbook", "Game", "Fanmade", "Instrumental", "Other", "Drama"]); export const entryType = z.enum(["Undefined", "Album", "Artist", "DiscussionTopic", "PV", "ReleaseEvent", "ReleaseEventSeries", "Song", "SongList", "Tag", "User", "Venue"]); export const eventCategory = z.enum(["Unspecified", "AlbumRelease", "Anniversary", "Club", "Concert", "Contest", "Convention", "Other", "Festival"]); export const localizedStringContract = z.object({language: contentLanguageSelection.optional(), value: z.string().nullable().optional()}); export const pVExtendedMetadata = z.object({json: z.string().nullable().optional()}); export const pVService = z.enum(["NicoNicoDouga", "Youtube", "SoundCloud", "Vimeo", "Piapro", "Bilibili", "File", "LocalFile", "Creofuga", "Bandcamp"]); export const pVType = z.enum(["Original", "Reprint", "Other"]); export const pVContract = z.object({author: z.string().nullable().optional(), createdBy: z.number().int().nullable().optional(), description: z.string().nullable().optional(), disabled: z.boolean().optional(), extendedMetadata: pVExtendedMetadata.optional(), id: z.number().int().optional(), length: z.number().int().optional(), name: z.string().nullable().optional(), publishDate: z.string().nullable().optional(), pvId: z.string().nullable().optional(), service: pVService.optional(), pvType: pVType.optional(), thumbUrl: z.string().nullable().optional(), url: z.string().nullable().optional()}); export const songListFeaturedCategory = z.enum(["Nothing", "Concerts", "VocaloidRanking", "Pools", "Other"]); export const songType = z.enum(["Unspecified", "Original", "Remaster", "Remix", "Cover", "Arrangement", "Instrumental", "Mashup", "MusicPV", "DramaPV", "Live", "Illustration", "Other", "Rearrangement", "ShortVersion"]); export const entryStatus = z.enum(["Draft", "Finished", "Approved", "Locked"]); export const tagBaseContract = z.object({additionalNames: z.string().nullable().optional(), categoryName: z.string().nullable().optional(), id: z.number().int().optional(), name: z.string().nullable().optional(), urlSlug: z.string().nullable().optional()}); export const tagUsageForApiContract = z.object({count: z.number().int().optional(), tag: tagBaseContract.optional()}); export const webLinkCategory = z.enum(["Official", "Commercial", "Reference", "Other"]); export const archivedWebLinkContract = z.object({category: webLinkCategory.optional(), description: z.string().nullable().optional(), disabled: z.boolean().optional(), url: z.string().nullable().optional()}); export const entryForApiContract = z.object({activityDate: z.string().nullable().optional(), additionalNames: z.string().nullable().optional(), artistString: z.string().nullable().optional(), artistType: artistType.optional(), createDate: z.string().optional(), defaultName: z.string().nullable().optional(), defaultNameLanguage: contentLanguageSelection.optional(), description: z.string().nullable().optional(), discType: discType.optional(), entryType: entryType.optional(), eventCategory: eventCategory.optional(), id: z.number().int().optional(), mainPicture: entryThumbForApiContract.optional(), name: z.string().nullable().optional(), names: z.array(localizedStringContract).nullable().optional(), pvs: z.array(pVContract).nullable().optional(), songListFeaturedCategory: songListFeaturedCategory.optional(), songType: songType.optional(), status: entryStatus.optional(), releaseEventSeriesName: z.string().nullable().optional(), tagCategoryName: z.string().nullable().optional(), tags: z.array(tagUsageForApiContract).nullable().optional(), urlSlug: z.string().nullable().optional(), version: z.number().int().optional(), webLinks: z.array(archivedWebLinkContract).nullable().optional()}); export const commentForApiContract = z.object({author: userForApiContract.optional(), authorName: z.string().nullable().optional(), created: z.string().optional(), entry: entryForApiContract.optional(), id: z.number().int().optional(), message: z.string().nullable().optional()}); 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/users/{id}/profileComments */ export const createApiApiUsersIdProfileComments = async (args: CreateApiApiUsersIdProfileCommentsArgs, options: CreateApiApiUsersIdProfileCommentsOptions) => { 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/users/${encodeURIComponent(String(args.id))}/profileComments${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(commentForApiContract, await res.json()) };