import {z} from 'zod' export type ImportedTurn = {role: string, text: string, speaker_name?: (string | null) | undefined, speaker_role?: (string | null) | undefined, start_ms?: (number | null) | undefined, end_ms?: (number | null) | undefined, real_user_turn_index?: (number | null) | undefined, responding_to_user_turn_index?: (number | null) | undefined}; export type ImportedFrame = {captured_at: number, data_b64: string, thumb_b64?: (string | null) | undefined, content_type?: string | undefined, width?: (number | null) | undefined, height?: (number | null) | undefined, motion_score?: (number | null) | undefined, user_turn_index?: (number | null) | undefined}; export type ImportRecordedSession = {template_id: string, imported_from: string, person_name?: string | undefined, person_email?: (string | null) | undefined, leader_name?: (string | null) | undefined, transcript: Array, frames?: Array | undefined, started_at?: (string | null) | undefined, duration_seconds?: (number | null) | undefined, metadata?: {[key: string]: unknown} | undefined}; export type CreateApiV1AdminSessionsImportRecordedArgs = {body: ImportRecordedSession}; export type CreateApiV1AdminSessionsImportRecordedOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV1AdminSessionsImportRecordedResponse = z.unknown(); 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 }; /** * Import Recorded Session * * POST /v1/admin/sessions/import-recorded */ export const createApiV1AdminSessionsImportRecorded = async (args: CreateApiV1AdminSessionsImportRecordedArgs, options: CreateApiV1AdminSessionsImportRecordedOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/admin/sessions/import-recorded${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(createApiV1AdminSessionsImportRecordedResponse, await res.json()) };