update leaderboard schema to match new API wire format with flattened FL points
This commit is contained in:
@@ -12,6 +12,7 @@ export const leaderboardDriverSchema = z.object({
|
||||
export type LeaderboardDriver = z.infer<typeof leaderboardDriverSchema>;
|
||||
|
||||
const pointsEntryFields = {
|
||||
id: z.string(),
|
||||
points: z.number().int().min(0),
|
||||
label: z.string().min(1),
|
||||
color: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
||||
@@ -22,10 +23,17 @@ const pointsEntryFields = {
|
||||
export const pointsEntrySchema = z.object(pointsEntryFields);
|
||||
export type PointsEntry = z.infer<typeof pointsEntrySchema>;
|
||||
|
||||
export const flPointsSchema = z.object(pointsEntryFields);
|
||||
export const flPointsSchema = z.object({
|
||||
points: z.number().int().min(0),
|
||||
label: z.string().min(1),
|
||||
color: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
||||
textColor: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
||||
priority: z.number().int().min(0)
|
||||
});
|
||||
export type FlPoints = z.infer<typeof flPointsSchema>;
|
||||
|
||||
export const leaderboardTrackSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string().min(1),
|
||||
results: z.array(z.object({ driverId: z.string(), score: resultValueSchema })),
|
||||
fastestLapDriverId: z.string()
|
||||
@@ -33,9 +41,13 @@ export const leaderboardTrackSchema = z.object({
|
||||
export type LeaderboardTrack = z.infer<typeof leaderboardTrackSchema>;
|
||||
|
||||
export const leaderboardSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
serverId: z.string().optional(),
|
||||
drivers: z.array(leaderboardDriverSchema),
|
||||
pointsTable: z.array(pointsEntrySchema),
|
||||
flPoints: flPointsSchema,
|
||||
flPoints: z.number().int().min(0),
|
||||
flColor: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
||||
flTextColor: z.string().regex(/^#[0-9a-fA-F]{6}$/),
|
||||
tracks: z.array(leaderboardTrackSchema)
|
||||
});
|
||||
export type Leaderboard = z.infer<typeof leaderboardSchema>;
|
||||
@@ -43,7 +55,9 @@ export type Leaderboard = z.infer<typeof leaderboardSchema>;
|
||||
export const emptyLeaderboard: Leaderboard = {
|
||||
drivers: [],
|
||||
pointsTable: [],
|
||||
flPoints: { points: 1, label: 'FL +1', color: '#8b5cf6', textColor: '#000000', priority: 3 },
|
||||
flPoints: 1,
|
||||
flColor: '#8b5cf6',
|
||||
flTextColor: '#000000',
|
||||
tracks: []
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user