feat: initial work on stores
This commit is contained in:
44
src/stores.ts
Normal file
44
src/stores.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import z from "zod";
|
||||
import type { StoreType } from "./entities/Stores";
|
||||
|
||||
export const locationStore = z.object({
|
||||
lat: z.number().min(-90).max(90),
|
||||
lng: z.number().min(-180).max(180),
|
||||
name: z.string().min(1).max(100)
|
||||
}).strict();
|
||||
|
||||
export const vehicleStore = z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
legalMaxSpeed: z.number().min(0).max(300),
|
||||
actualMaxSpeed: z.number().min(0).max(300),
|
||||
type: z.enum([
|
||||
"car", "truck", "motorcycle", "bicycle", "motor_scooter"
|
||||
]),
|
||||
weight: z.number().min(0).max(100000).optional(),
|
||||
width: z.number().min(0).max(10).optional(),
|
||||
axisLoad: z.number().min(0).max(100000).optional(),
|
||||
height: z.number().min(0).max(20).optional(),
|
||||
length: z.number().min(0).max(100).optional(),
|
||||
emissionClass: z.string().min(1).max(50),
|
||||
fuelType: z.enum(["petrol", "diesel", "electric"]),
|
||||
preferredFuel: z.string().min(1).max(50)
|
||||
}).strict();
|
||||
|
||||
export const routeStore = z.object({
|
||||
locations: z.array(z.object({
|
||||
lat: z.number().min(-90).max(90),
|
||||
lon: z.number().min(-180).max(180)
|
||||
})),
|
||||
legs: z.array(z.object({
|
||||
shape: z.string(),
|
||||
maneuvers: z.array(z.object({
|
||||
type: z.number()
|
||||
}))
|
||||
}))
|
||||
})
|
||||
|
||||
export const storeTypes: Record<StoreType, z.ZodSchema> = {
|
||||
location: locationStore,
|
||||
vehicle: vehicleStore,
|
||||
route: routeStore,
|
||||
};
|
||||
Reference in New Issue
Block a user