import { buildProjectCostEstimate } from '../cost-estimate.js'; import { safeErrorBody } from '../http-error-safety.js'; import { buildProjectReadiness } from '../readiness.js'; import { buildProjectStatusReport } from '../status.js'; export interface CreatorUiProjectSnapshot { project: string; status: Awaited>; readiness: Awaited>; costEstimate: Awaited> | null; costUnavailableReason?: string; } export async function buildCreatorUiProjectSnapshot( root: string, project: string, ): Promise { const [status, readiness, costResult] = await Promise.all([ buildProjectStatusReport(project, root, 'storyboard'), buildProjectReadiness(project, root, 'storyboard'), buildProjectCostEstimate({ projectSlug: project, root }) .then((costEstimate) => ({ costEstimate, costUnavailableReason: undefined })) .catch((error: unknown) => ({ costEstimate: null, costUnavailableReason: safeErrorBody(error instanceof Error ? error.message : String(error)), })), ]); return { project, status, readiness, costEstimate: costResult.costEstimate, ...(costResult.costUnavailableReason ? { costUnavailableReason: costResult.costUnavailableReason } : {}), }; }