/** Shared types and schemas for the questionnaire tool. */ import { Type } from "typebox"; export interface QuestionOption { value: string; label: string; description?: string; } export type RenderOption = QuestionOption & { isOther?: boolean }; export interface Question { id: string; label: string; prompt: string; options: QuestionOption[]; allowOther: boolean; } export interface Answer { id: string; value: string; label: string; wasCustom: boolean; index?: number; } export interface QuestionnaireResult { questions: Question[]; answers: Answer[]; cancelled: boolean; } export const QuestionOptionSchema = Type.Object({ value: Type.String({ description: "The value returned when selected" }), label: Type.String({ description: "Display label for the option" }), description: Type.Optional(Type.String({ description: "Optional description shown below label" })), }); export const QuestionSchema = Type.Object({ id: Type.String({ description: "Unique identifier for this question" }), label: Type.Optional( Type.String({ description: "Short contextual label for tab bar, e.g. 'Scope', 'Priority' (defaults to Q1, Q2)", }), ), prompt: Type.String({ description: "The full question text to display" }), options: Type.Array(QuestionOptionSchema, { description: "Available options to choose from" }), allowOther: Type.Optional(Type.Boolean({ description: "Allow 'Type something' option (default: true)" })), }); export const QuestionnaireParams = Type.Object({ questions: Type.Array(QuestionSchema, { description: "Questions to ask the user" }), });