import {z} from 'zod' export type CreateApiApiV1DesignIntentsIntentIdSkipArgs = {intent_id: string}; export type CreateApiApiV1DesignIntentsIntentIdSkipOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const criticalFeatureEntry = z.object({feature_id: z.string(), reason: z.string().max(500), source_certainty: z.enum(["user_asserted", "user_hypothetical", "agent_inferred"])}); export const matingSurfaceEntry = z.object({feature_id: z.string(), mate_type: z.string().max(64), counterpart: z.string().max(256).nullable().optional(), notes: z.string().max(500).nullable().optional(), source_certainty: z.enum(["user_asserted", "user_hypothetical", "agent_inferred"])}); export const loadPathEntry = z.object({path: z.string().max(500), magnitude: z.string().max(128).nullable().optional(), direction: z.string().max(64).nullable().optional(), source_certainty: z.enum(["user_asserted", "user_hypothetical", "agent_inferred"])}); export const toleranceRationaleEntry = z.object({feature_id: z.string().nullable().optional(), spec: z.string().max(64), why: z.string().max(500), source_certainty: z.enum(["user_asserted", "user_hypothetical", "agent_inferred"])}); export const performanceRequirementEntry = z.object({metric: z.string().max(128), target: z.string().max(128), source_certainty: z.enum(["user_asserted", "user_hypothetical", "agent_inferred"])}); export const designIntentRead = z.object({id: z.string(), part_id: z.string(), cad_file_version_id: z.string(), captured_via_conversation_id: z.string().nullable(), interview_status: z.enum(["not_started", "in_progress", "completed", "skipped", "superseded", "carry_forward_pending"]), nudge_dismissed_at: z.string().nullable(), inferred_purpose: z.string().nullable(), inferred_primary_function: z.string().nullable(), purpose: z.string().nullable(), primary_function: z.string().nullable(), environment: z.string().nullable(), critical_features: z.array(criticalFeatureEntry), mating_surfaces: z.array(matingSurfaceEntry), load_paths: z.array(loadPathEntry), tolerance_rationale: z.array(toleranceRationaleEntry), performance_requirements: z.array(performanceRequirementEntry), free_text_notes: z.string().nullable(), confidence_score: z.number().nullable(), fields_captured_count: z.number().int(), questions_asked: z.number().int(), passive_writes_count: z.number().int(), interview_started_at: z.string().nullable(), interview_completed_at: z.string().nullable(), created_at: z.string(), updated_at: z.string()}); 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 }; /** * Skip Intent * * POST /api/v1/design-intents/{intent_id}/skip */ export const createApiApiV1DesignIntentsIntentIdSkip = async (args: CreateApiApiV1DesignIntentsIntentIdSkipArgs, options: CreateApiApiV1DesignIntentsIntentIdSkipOptions) => { 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/design-intents/${encodeURIComponent(String(args.intent_id))}/skip${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(designIntentRead, await res.json()) };