-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.ts
54 lines (42 loc) · 1.08 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { z } from "zod";
export const Stat = z.object({
label: z.string(),
value: z.string().or(z.number()),
prefix: z.string().optional(),
});
export type Stat = z.infer<typeof Stat>;
const Table = z.object({
columns: z.array(z.string()),
data: z.array(z.array(z.string().or(z.number()))),
});
export type Table = z.infer<typeof Table>;
export const LineChart = z.object({
label: z.string(),
type: z.literal("line"),
lines: z.array(
z.object({
id: z.string(),
color: z.string(),
data: z.array(
z.object({
y: z.number(),
x: z.string(),
})
),
})
),
});
export type LineChart = z.infer<typeof LineChart>;
export const Chart = LineChart;
export type Chart = z.infer<typeof Chart>;
export const Section = z.object({
title: z.string(),
stats: z.array(Stat).optional(),
table: Table.optional(),
chart: Chart.optional(),
});
export type Section = z.infer<typeof Section>;
export const DashboardSchema = z.object({
sections: z.array(Section),
});
export type DashboardSchema = z.infer<typeof DashboardSchema>;