making strides in the device and link domain setup
This commit is contained in:
48
packages/logic/domains/device/data.ts
Normal file
48
packages/logic/domains/device/data.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
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<typeof deviceStatusSchema>;
|
||||
|
||||
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<typeof deviceSchema>;
|
||||
|
||||
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<typeof createDeviceSchema>;
|
||||
|
||||
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<typeof updateDeviceSchema>;
|
||||
Reference in New Issue
Block a user