Skip to content
Visibility internal Owner _ Approver _ Created _ Updated _

AnalyzeLifeDomainQuizSchema.ts



FieldValue
TypeTypeScript
SourceProduct/Projects/Domain_Quiz/Schemas/AnalyzeLifeDomainQuizSchema.ts
ParentProduct
GitHubProduct/Projects/Domain_Quiz/Schemas/AnalyzeLifeDomainQuizSchema.ts

This page is auto-generated. Edit the source to change the content.



import { z } from 'zod';
import { LifeDomainIdSchema } from '@dakoda/database/zod/enums/LifeDomainId.schema';
import {
  ProfileFieldFromAnalysisSchema,
  FactoidFromAnalysisSchema,
} from '@dakoda/memory/shared/MemoryAnalysisSchemas';

/**
 * Life Domain Quiz Analysis Output Schema
 *
 * Produced by the AnalyzeLifeDomainQuiz bot after a domain quiz is completed.
 * Each Life Domain Quiz assesses a single Domain of Life Balance in depth.
 *
 * Design rationale — three analysis types form a complete picture:
 *   - AnalyzeOnboardingQuiz:  broad baseline across all domains (taken once)
 *   - AnalyzeLifeDomainQuiz:  deep assessment of ONE domain (taken periodically)
 *   - AnalyzeConvo:           ongoing context from coaching conversations
 *
 * Root-level fields map to distinct storage destinations:
 *   - structuredAnalysis  → stored with the quiz result for AI reference
 *   - profileFields       → written to the user profile
 *   - factoids            → entered into the factoid memory system
 *   - userEvaluation      → displayed to the user
 *
 * NOTE: Numeric scoring (gradePercent, bracket, per-section scores) is computed
 * in TypeScript before this bot runs. The bot receives pre-computed scores as
 * context and focuses on qualitative interpretation and coaching guidance.
 */

// --- Sub-schemas ---

export const StrengthSchema = z.object({
  area: z.string(),
  evidence: z.string(),
  coachingNote: z.string(),
});

export const ConcernSchema = z.object({
  area: z.string(),
  severity: z.enum(['mild', 'moderate', 'significant']),
  evidence: z.string(),
  coachingNote: z.string(),
});

export const CoachingPrioritySchema = z.object({
  rank: z.number().int().min(1),
  area: z.string(),
  rationale: z.string(),
  suggestedApproach: z.string(),
  relatedTaxonomy: z.array(z.string()).nullable(),
});

export const UviloTagsSchema = z.object({
  lifeDomains: z.array(LifeDomainIdSchema).nullable(),
  issues: z.array(z.string()).nullable(),
  aspirations: z.array(z.string()).nullable(),
  practices: z.array(z.string()).nullable(),
});

// --- Structured Analysis ---

export const DomainStructuredAnalysisSchema = z.object({
  oneLiner: z.string(),
  interpretation: z.string(),
  strengths: z.array(StrengthSchema).min(1),
  concerns: z.array(ConcernSchema),
  patterns: z.array(z.string()),
  coachingPriorities: z.array(CoachingPrioritySchema).min(1).max(5),
  onboardingComparison: z.string().nullable(),
  uviloTags: UviloTagsSchema.nullable(),
});

// --- Root analysis output ---

export const AnalyzeLifeDomainQuizSchema = z.object({
  structuredAnalysis: DomainStructuredAnalysisSchema,
  profileFields: z.array(ProfileFieldFromAnalysisSchema),
  factoids: z.array(FactoidFromAnalysisSchema),
  userEvaluation: z.string(),
});

// --- Exported types ---

export type Strength = z.infer<typeof StrengthSchema>;
export type Concern = z.infer<typeof ConcernSchema>;
export type CoachingPriority = z.infer<typeof CoachingPrioritySchema>;
export type UviloTags = z.infer<typeof UviloTagsSchema>;
export type DomainStructuredAnalysis = z.infer<typeof DomainStructuredAnalysisSchema>;
export type AnalyzeLifeDomainQuiz = z.infer<typeof AnalyzeLifeDomainQuizSchema>;