refactor: update dashboard types and schemas for improved validation

- Removed unused import for `createMetricsRawLlmMessageEntry` in visualization tools.
- Introduced Zod schemas for `Dashboard` and `DashboardConfig` to enhance type validation and structure.
- Cleaned up the interface definitions for better clarity and maintainability.

These changes improve the robustness of the dashboard configuration and streamline the codebase.
This commit is contained in:
dal 2025-08-08 13:00:20 -06:00
parent ff8530a08f
commit e75f90ceab
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 39 additions and 25 deletions

View File

@ -22,7 +22,6 @@ import type {
CreateMetricsState, CreateMetricsState,
} from './create-metrics-tool'; } from './create-metrics-tool';
import { import {
createMetricsRawLlmMessageEntry,
createMetricsReasoningMessage, createMetricsReasoningMessage,
createMetricsResponseMessage, createMetricsResponseMessage,
} from './helpers/create-metrics-transform-helper'; } from './helpers/create-metrics-transform-helper';

View File

@ -1,26 +1,41 @@
import type { VerificationStatus } from '../share'; import { z } from 'zod';
import { VerificationStatusSchema } from '../share';
export interface Dashboard { // Dashboard Config Schema
config: DashboardConfig; export const DashboardConfigSchema = z.object({
created_at: string; rows: z
created_by: string; .array(
deleted_at: string | null; z.object({
description: string | null; columnSizes: z.array(z.number().min(1).max(12)).optional(), // columns sizes 1 - 12. MUST add up to 12
id: string; rowHeight: z.number().optional(), // pixel based!
name: string; id: z.string(),
updated_at: string | null; items: z.array(
updated_by: string; z.object({
status: VerificationStatus; id: z.string(),
version_number: number; })
file: string; //yaml file ),
file_name: string; })
} )
.optional(),
});
export interface DashboardConfig { // Dashboard Schema
rows?: { export const DashboardSchema = z.object({
columnSizes?: number[]; //columns sizes 1 - 12. MUST add up to 12 config: DashboardConfigSchema,
rowHeight?: number; //pixel based! created_at: z.string(),
id: string; created_by: z.string(),
items: { id: string }[]; deleted_at: z.string().nullable(),
}[]; description: z.string().nullable(),
} id: z.string(),
name: z.string(),
updated_at: z.string().nullable(),
updated_by: z.string(),
status: VerificationStatusSchema,
version_number: z.number(),
file: z.string(), // yaml file
file_name: z.string(),
});
// Export inferred types
export type DashboardConfig = z.infer<typeof DashboardConfigSchema>;
export type Dashboard = z.infer<typeof DashboardSchema>;