import * as v from "valibot"; export enum DeviceStatus { ONLINE = "online", OFFLINE = "offline", BUSY = "busy", ERROR = "error", } export const deviceStatusSchema = v.picklist(["online", "offline", "busy", "error"]); export type DeviceStatusValue = v.InferOutput; export const deviceSchema = v.object({ id: v.number(), title: v.string(), version: v.string(), status: deviceStatusSchema, isActive: v.boolean(), containerId: v.nullable(v.string()), host: v.string(), wsPort: v.nullable(v.string()), createdAt: v.date(), updatedAt: v.date(), }); export type Device = v.InferOutput; export const createDeviceSchema = v.object({ title: v.pipe(v.string(), v.minLength(1)), version: v.pipe(v.string(), v.minLength(1)), host: v.pipe(v.string(), v.minLength(1)), containerId: v.optional(v.string()), wsPort: v.optional(v.string()), isActive: v.optional(v.boolean()), }); export type CreateDevice = v.InferOutput; export const updateDeviceSchema = v.partial( v.object({ title: v.string(), version: v.string(), host: v.string(), containerId: v.nullable(v.string()), wsPort: v.nullable(v.string()), isActive: v.boolean(), status: deviceStatusSchema, }), ); export type UpdateDevice = v.InferOutput;