import {z} from 'zod' export type GetApiV1InterviewsInterviewIdConversationsConversationIdArgs = {interview_id: string, conversation_id: string, locale?: (string | null) | undefined, transcript_locale?: (string | null) | undefined, 'X-Ontora-Locale'?: (string | null) | undefined, 'Accept-Language'?: (string | null) | undefined, 'X-API-Key'?: (string | null) | undefined}; export type GetApiV1InterviewsInterviewIdConversationsConversationIdOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const conversationContactOut = z.object({id: z.string().nullable(), name: z.string(), job_title: z.string().nullable(), department: z.string().nullable(), seniority_level: z.number().int().nullable()}); export const conversationPrivacyDriftOut = z.object({dimension: z.string(), direction: z.string()}); export const appApiCampaignInsightsSessionFeedbackOut = z.object({rating: z.number(), suggestions: z.array(z.string()), additional_feedback: z.string().nullable()}); export const conversationScreenObservationOut = z.object({id: z.string(), screen_share_id: z.string(), offset_seconds: z.number().int().nullable(), observed_at: z.string().nullable(), summary: z.string().nullable(), visible_tools: z.array(z.unknown()).nullable(), process_step: z.string().nullable(), visible_text: z.string().nullable(), suggested_probe: z.string().nullable(), confidence: z.number().nullable(), analysis_status: z.string(), image_available: z.boolean().optional()}); export const conversationScreenShareOut = z.object({id: z.string(), request_id: z.string().nullable(), prompt: z.string().nullable(), reason: z.string().nullable(), status: z.string(), started_at: z.string().nullable(), stopped_at: z.string().nullable(), completed_at: z.string().nullable(), duration_seconds: z.number().int().nullable(), expected_chunk_count: z.number().int().nullable().optional(), uploaded_bytes: z.number().int().optional(), upload_limit_bytes: z.number().int().nullable().optional(), recording_available: z.boolean().optional(), recording_mime_type: z.string().nullable().optional(), recording_size_bytes: z.number().int().nullable().optional(), recording_error: z.string().nullable().optional(), observations: z.array(conversationScreenObservationOut).optional()}); export const conversationSharedFileOut = z.object({id: z.string(), kind: z.string(), format: z.string(), content_type: z.string(), size_bytes: z.number().int(), filename: z.string().nullable(), summary: z.string().nullable(), shared_at: z.string(), turn_index: z.number().int().nullable(), download_available: z.boolean()}); export const topicCountOut = z.object({fulfilled: z.number().int(), total: z.number().int()}); export const conversationTopicOut = z.object({title: z.string(), status: z.string(), required: z.boolean()}); export const conversationDetailOut = z.object({id: z.string(), contact_id: z.string().nullable(), contact: conversationContactOut, is_anonymous: z.boolean().optional(), anonymity_level: z.string().optional(), campaign_anonymity_level: z.string().optional(), privacy_drift: z.array(conversationPrivacyDriftOut).optional(), summary: z.string().nullable(), transcript: z.array(z.record(z.string(), z.unknown())).nullable(), original_language_code: z.string().nullable().optional(), original_language_label: z.string().nullable().optional(), transcript_language_code: z.string().nullable().optional(), transcript_language_label: z.string().nullable().optional(), transcript_is_translated: z.boolean().optional(), available_transcript_languages: z.array(z.string()).optional(), duration_minutes: z.number().int().nullable(), findings: z.array(z.record(z.string(), z.unknown())).nullable().optional(), referenced_resources: z.array(z.string()).nullable().optional(), areas_discussed: z.array(z.string()).nullable().optional(), extracted_pain_points: z.array(z.record(z.string(), z.unknown())).nullable(), tools_mentioned: z.array(z.string()).nullable(), processes_touched: z.array(z.string()).nullable(), started_at: z.string().nullable(), ended_at: z.string().nullable(), recording_available: z.boolean().optional(), recording_mime_type: z.string().nullable().optional(), recording_size_bytes: z.number().int().nullable().optional(), recording_duration_seconds: z.number().int().nullable().optional(), user_recording_available: z.boolean().optional(), user_recording_mime_type: z.string().nullable().optional(), user_recording_size_bytes: z.number().int().nullable().optional(), user_recording_duration_seconds: z.number().int().nullable().optional(), agent_recording_available: z.boolean().optional(), agent_recording_mime_type: z.string().nullable().optional(), agent_recording_size_bytes: z.number().int().nullable().optional(), agent_recording_duration_seconds: z.number().int().nullable().optional(), session_feedback: appApiCampaignInsightsSessionFeedbackOut.nullable().optional(), screen_analysis_status: z.string().nullable().optional(), screen_analysis_summary: z.string().nullable().optional(), screen_analysis_json: z.record(z.string(), z.unknown()).nullable().optional(), screen_shares: z.array(conversationScreenShareOut).optional(), shared_files: z.array(conversationSharedFileOut).optional(), status: z.string().nullable().optional(), topic_count: topicCountOut.nullable().optional(), topics: z.array(conversationTopicOut).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 }; /** * Get Conversation Detail * * GET /v1/interviews/{interview_id}/conversations/{conversation_id} */ export const getApiV1InterviewsInterviewIdConversationsConversationId = async (args: GetApiV1InterviewsInterviewIdConversationsConversationIdArgs, options: GetApiV1InterviewsInterviewIdConversationsConversationIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.locale != null) query.append("locale", String(args.locale)) if (args.transcript_locale != null) query.append("transcript_locale", String(args.transcript_locale)) if (args['X-Ontora-Locale'] != null) headers.set("X-Ontora-Locale", String(args['X-Ontora-Locale'])) if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (args['X-API-Key'] != null) headers.set("X-API-Key", String(args['X-API-Key'])) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/interviews/${encodeURIComponent(String(args.interview_id))}/conversations/${encodeURIComponent(String(args.conversation_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(conversationDetailOut, await res.json()) };