mirror of https://github.com/buster-so/buster.git
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:
parent
ff8530a08f
commit
e75f90ceab
|
@ -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';
|
||||||
|
|
|
@ -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>;
|
||||||
|
|
Loading…
Reference in New Issue