import {z} from 'zod' export type PBPodcast = {key?: string | undefined, title: string, coverArtUrl?: string | undefined, summary?: string | undefined, description: string, author?: string | undefined, ownerName: string, ownerEmail: string, categories: Array, language: string, link?: string | undefined, explicit?: boolean | undefined, rssFeed?: string | undefined, interviewPodcastKey?: string | undefined}; export type PBPodcastRecordingSchedule = {frequency: 'weekly' | 'monthly', daysOfWeek?: (Array<'SUN' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT'>) | undefined, daysOfMonth?: Array | undefined, startTime: string, durationMinutes: number, timezone: string, enabled?: boolean | undefined}; export type PBPodcastRecordingConfig = {streamUrl: string, recordingSchedule: PBPodcastRecordingSchedule, introAudioUrl?: string | undefined, outroAudioUrl?: string | undefined}; export type PBPodcastProcessingPresets = {removeBackgroundMusic?: boolean | undefined, introAudioUrl?: string | undefined, outroAudioUrl?: string | undefined, aiTitleSummary?: boolean | undefined, customPromptTitle?: string | undefined, customPromptDescription?: string | undefined}; export type PBPodcastAiAdsConfig = {removeAds?: boolean | undefined, insertProgrammaticAds?: boolean | undefined, adsFrequency?: number | undefined}; export type PBPodcastInterviewConfig = {extractInterviews?: boolean | undefined, interviewPodcastName?: string | undefined, interviewMinLengthMinutes?: number | undefined, customPromptInterviewTitle?: string | undefined, customPromptInterviewDescription?: string | undefined}; export type Colors = {accent?: string | undefined, background?: string | undefined, text?: string | undefined, barGradientFrom?: string | undefined, barGradientTo?: string | undefined}; export type Text = {episodeLabel?: string | undefined, title?: string | undefined, subtitle?: string | undefined, caption?: string | undefined}; export type Assets = {primaryLogo?: string | undefined, secondaryLogo?: string | undefined, hostPhoto?: string | undefined}; export type Captions = {show?: boolean | undefined, synced?: boolean | undefined, embedded_srt_file?: boolean | undefined}; export type PBVideoConfig = {style?: ('waveformBars' | 'equalizer' | 'radialPulse' | 'hostSplit' | 'hostCentered' | 'podcastCardDotted') | undefined, font?: ('inter' | 'oswald' | 'bebasNeue' | 'montserrat' | 'anton' | 'poppins') | undefined, showEqualizer?: boolean | undefined, fps?: number | undefined, colors?: Colors | undefined, text?: Text | undefined, assets?: Assets | undefined, captions?: Captions | undefined, aspect_ratios?: (Array<'16:9' | '9:16' | '1:1' | '4:5'>) | undefined}; export type PbClip = {label?: string | undefined, video?: PBVideoConfig | undefined, clip_generation?: string | undefined, count?: number | undefined, min_clip_duration?: number | undefined, max_clip_duration?: number | undefined, segment_types?: Array | undefined}; export type PBAutoClipConfig = {video?: PBVideoConfig | undefined, generate_chapters?: boolean | undefined, clip_generation?: string | undefined, max_clips?: number | undefined, min_clip_duration?: number | undefined, max_clip_duration?: number | undefined, padding_seconds?: number | undefined, segment_types?: Array | undefined, clip_groups?: Array | undefined}; export type PBCreateRecordingPodcast = {podcast: PBPodcast, recordingConfig: PBPodcastRecordingConfig, processingPresets?: PBPodcastProcessingPresets | undefined, aiAdsConfig?: PBPodcastAiAdsConfig | undefined, interviewConfig?: PBPodcastInterviewConfig | undefined, videoConfig?: PBVideoConfig | undefined, autoClipConfig?: PBAutoClipConfig | undefined}; export type CreateApiPodcastBotPodcastsRecordingCreateArgs = {body: PBCreateRecordingPodcast}; export type CreateApiPodcastBotPodcastsRecordingCreateOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const pBPodcast = z.object({key: z.string().optional(), title: z.string(), coverArtUrl: z.string().optional(), summary: z.string().optional(), description: z.string(), author: z.string().optional(), ownerName: z.string(), ownerEmail: z.string(), categories: z.array(z.string()), language: z.string(), link: z.string().optional(), explicit: z.boolean().optional(), rssFeed: z.string().optional(), interviewPodcastKey: z.string().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 }; /** * Create recording podcast * * POST /podcast-bot/podcasts/recording/create */ export const createApiPodcastBotPodcastsRecordingCreate = async (args: CreateApiPodcastBotPodcastsRecordingCreateArgs, options?: CreateApiPodcastBotPodcastsRecordingCreateOptions) => { const {baseUrl = "https://api.zeno.fm", 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(/\/+$/, '')}/podcast-bot/podcasts/recording/create${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(pBPodcast, await res.json()) };