import {z} from 'zod' export type GetApiApiV1AdminProjectsProjectIdOllieTranscriptArgs = {project_id: string}; export type GetApiApiV1AdminProjectsProjectIdOllieTranscriptOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const toolCallSummary = z.object({id: z.string().nullable().optional(), name: z.string().nullable().optional(), is_error: z.boolean().optional()}); export const transcriptMessageRead = z.object({id: z.string(), role: z.string(), content: z.string(), created_at: z.string().nullable().optional(), tool_calls: z.array(toolCallSummary).optional()}); export const transcriptPartIntentRead = z.object({part_id: z.string(), part_name: z.string(), intent_status: z.string(), purpose: z.string().nullable().optional(), primary_function: z.string().nullable().optional(), environment: z.string().nullable().optional(), critical_features: z.array(z.record(z.string(), z.unknown())).optional(), mating_surfaces: z.array(z.record(z.string(), z.unknown())).optional(), load_paths: z.array(z.record(z.string(), z.unknown())).optional(), tolerance_rationale: z.array(z.record(z.string(), z.unknown())).optional(), performance_requirements: z.array(z.record(z.string(), z.unknown())).optional(), free_text_notes: z.string().nullable().optional()}); export const transcriptNoteRead = z.object({id: z.string(), part_id: z.string(), part_name: z.string(), feature_id: z.string().nullable().optional(), note: z.string(), author: z.string(), excluded_from_drawing: z.boolean(), created_at: z.string().nullable().optional()}); export const ollieTranscriptResponse = z.object({project_id: z.string(), project_name: z.string(), messages: z.array(transcriptMessageRead), part_intents: z.array(transcriptPartIntentRead), notes: z.array(transcriptNoteRead)}); 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 Ollie Transcript * * GET /api/v1/admin/projects/{project_id}/ollie-transcript */ export const getApiApiV1AdminProjectsProjectIdOllieTranscript = async (args: GetApiApiV1AdminProjectsProjectIdOllieTranscriptArgs, options: GetApiApiV1AdminProjectsProjectIdOllieTranscriptOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2PasswordBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (OAuth2PasswordBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2PasswordBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/admin/projects/${encodeURIComponent(String(args.project_id))}/ollie-transcript${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(ollieTranscriptResponse, await res.json()) };