fix(validation): extract schema to shared file for client/server compatibility

Move ValidationResultSchema to lib/validation-schema.ts to avoid importing
server-side modules (ai-providers) into client-side code. This fixes the
Turbopack build error caused by the hook importing from the API route.
This commit is contained in:
Jinze Yu
2026-01-19 01:30:51 +09:00
parent 85513b8c00
commit 6b0296a97f
3 changed files with 46 additions and 42 deletions

View File

@@ -6,18 +6,13 @@
import { experimental_useObject as useObject } from "@ai-sdk/react"
import { useCallback, useRef } from "react"
import { ValidationResultSchema } from "@/app/api/validate-diagram/route"
import { getApiEndpoint } from "@/lib/base-path"
import {
type ValidationResult,
ValidationResultSchema,
} from "@/lib/validation-schema"
export type ValidationResult = {
valid: boolean
issues: Array<{
type: "overlap" | "edge_routing" | "text" | "layout" | "rendering"
severity: "critical" | "warning"
description: string
}>
suggestions: string[]
}
export type { ValidationResult }
// Default valid result for fallback cases
const DEFAULT_VALID_RESULT: ValidationResult = {