import {z} from 'zod' export type TranscriptionConfig = {keywords?: Array | undefined, language?: ('en-US' | 'en-IN' | 'de' | 'hi' | 'sv' | 'ru' | 'pl' | 'el' | 'fr' | 'nl') | undefined, profanity_filter?: boolean | undefined}; export type SummarizationConfig = {word_limit?: number | undefined, text_format?: ('plain_text' | 'markdown') | undefined, summary_type?: ('general' | 'team_meeting' | 'sales_call' | 'client_check_in' | 'interview' | 'daily_standup' | 'one_on_one_meeting' | 'lecture' | 'code_review') | undefined}; export type AIConfig = {transcription?: TranscriptionConfig | undefined, summarization?: SummarizationConfig | undefined}; export type PatchApiMeetingsMeetingIdArgs = {meeting_id: string, body: {title?: string | undefined, preferred_region?: ('ap-south-1' | 'ap-southeast-1' | 'us-east-1' | 'eu-central-1') | undefined, record_on_start?: boolean | undefined, live_stream_on_start?: boolean | undefined, status?: ('ACTIVE' | 'INACTIVE') | undefined, persist_chat?: boolean | undefined, summarize_on_end?: boolean | undefined, ai_config?: AIConfig | undefined}}; export type PatchApiMeetingsMeetingIdOptions = {baseUrl?: string | undefined, Authorization?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const videoConfig = z.object({codec: z.enum(["H264", "VP8"]).optional(), width: z.number().int().gte(1).lte(1920).optional(), height: z.number().int().gte(1).lte(1920).optional(), watermark: z.object({url: z.string().optional(), size: z.object({width: z.number().int().gte(1).optional(), height: z.number().int().gte(1).optional()}).optional(), position: z.enum(["left top", "right top", "left bottom", "right bottom"]).optional()}).optional(), export_file: z.boolean().optional()}); export const audioConfig = z.object({codec: z.enum(["MP3", "AAC"]).optional(), channel: z.enum(["mono", "stereo"]).optional(), export_file: z.boolean().optional()}); export const storageConfig = z.object({type: z.enum(["aws", "azure", "digitalocean", "gcs", "sftp"]), access_key: z.string().optional(), secret: z.string().optional(), bucket: z.string().optional(), region: z.string().optional(), path: z.string().optional(), auth_method: z.enum(["KEY", "PASSWORD"]).optional(), username: z.string().optional(), password: z.string().optional(), host: z.string().optional(), port: z.number().optional(), private_key: z.string().optional()}).nullable(); export const dyteBucketConfig = z.object({enabled: z.boolean()}); export const livestreamingConfig = z.object({rtmp_url: z.string().optional()}); export const recordingConfig = z.object({max_seconds: z.number().gte(60).lte(86400).optional(), file_name_prefix: z.string().optional(), video_config: videoConfig.optional(), audio_config: audioConfig.optional(), storage_config: storageConfig.optional(), dyte_bucket_config: dyteBucketConfig.optional(), live_streaming_config: livestreamingConfig.optional()}); export const transcriptionConfig = z.object({keywords: z.array(z.string()).optional(), language: z.enum(["en-US", "en-IN", "de", "hi", "sv", "ru", "pl", "el", "fr", "nl"]).optional(), profanity_filter: z.boolean().optional()}); export const summarizationConfig = z.object({word_limit: z.number().int().gte(150).lte(1000).optional(), text_format: z.enum(["plain_text", "markdown"]).optional(), summary_type: z.enum(["general", "team_meeting", "sales_call", "client_check_in", "interview", "daily_standup", "one_on_one_meeting", "lecture", "code_review"]).optional()}); export const aIConfig = z.object({transcription: transcriptionConfig.optional(), summarization: summarizationConfig.optional()}); export const patchApiMeetingsMeetingIdResponse = z.object({success: z.boolean(), data: z.object({id: z.string(), title: z.string().optional(), preferred_region: z.enum(["ap-south-1", "ap-southeast-1", "us-east-1", "eu-central-1", "null"]).nullable().optional(), created_at: z.string(), record_on_start: z.boolean().optional(), updated_at: z.string(), live_stream_on_start: z.boolean().optional(), persist_chat: z.boolean().optional(), summarize_on_end: z.boolean().optional(), status: z.enum(["ACTIVE", "INACTIVE"]).optional(), recording_config: recordingConfig.optional(), ai_config: aIConfig.optional()}).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 }; /** * Update a meeting * * PATCH /meetings/{meeting_id} */ export const patchApiMeetingsMeetingId = async (args: PatchApiMeetingsMeetingIdArgs, options?: PatchApiMeetingsMeetingIdOptions) => { const {baseUrl = "https://api.dyte.io/v2", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Authorization !== undefined) headers.set('authorization', `Basic ${btoa(`${Authorization.username}:${Authorization.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/meetings/${encodeURIComponent(String(args.meeting_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiMeetingsMeetingIdResponse, await res.json()) };