2026-10-04 16:36:09 +00:00
|
|
|
import { z } from "zod/v4";
|
|
|
|
|
|
2026-10-09 18:03:56 +00:00
|
|
|
import { FieldTypeSchema, TemplateSectionSchema } from "./asset-definition";
|
2026-10-04 16:36:09 +00:00
|
|
|
|
|
|
|
|
export const AssetStatusSchema = z.enum(["available", "in_use", "maintenance", "retired"]);
|
|
|
|
|
export const AssetCharacteristicSchema = z.strictObject({
|
|
|
|
|
fieldId: z.uuid(),
|
|
|
|
|
name: z.string().min(1).max(100),
|
|
|
|
|
type: FieldTypeSchema,
|
|
|
|
|
unit: z.string().max(30),
|
|
|
|
|
choices: z.array(z.string().min(1).max(100)),
|
|
|
|
|
required: z.boolean(),
|
2026-10-09 18:03:56 +00:00
|
|
|
sectionId: z.uuid().optional(),
|
2026-10-04 16:36:09 +00:00
|
|
|
});
|
|
|
|
|
export const AssetValueSchema = z.union([z.string().max(10000), z.number().finite(), z.boolean()]);
|
|
|
|
|
export const AssetInputSchema = z.strictObject({
|
|
|
|
|
name: z.string().min(1).max(100),
|
|
|
|
|
templateId: z.uuid(),
|
|
|
|
|
siteId: z.uuid().nullable(),
|
2026-10-07 16:08:48 +00:00
|
|
|
brandId: z.uuid().nullable().optional(),
|
2026-10-04 16:36:09 +00:00
|
|
|
status: AssetStatusSchema,
|
|
|
|
|
notes: z.string().max(10000),
|
|
|
|
|
characteristics: z.record(z.uuid(), AssetValueSchema),
|
|
|
|
|
});
|
|
|
|
|
export const AssetSpecificationSchema = z.strictObject({
|
|
|
|
|
templateId: z.uuid(),
|
|
|
|
|
templateName: z.string().min(1).max(100),
|
2026-10-09 18:03:56 +00:00
|
|
|
sections: z.array(TemplateSectionSchema).max(30).optional(),
|
2026-10-04 16:36:09 +00:00
|
|
|
fields: z.array(AssetCharacteristicSchema).min(1).max(100),
|
|
|
|
|
});
|
|
|
|
|
export type AssetInput = z.infer<typeof AssetInputSchema>;
|
|
|
|
|
export type AssetSpecificationData = z.infer<typeof AssetSpecificationSchema>;
|
|
|
|
|
export type AssetCharacteristic = z.infer<typeof AssetCharacteristicSchema>;
|