- Implemented CatalogTemplateForm for creating and managing asset templates. - Added inventory management components including AssetInventoryPage and related forms. - Introduced internationalization support for asset and inventory components in English and Spanish. - Created tests for catalog and inventory functionalities to ensure proper rendering and behavior. - Established API interactions for inventory management and asset catalog retrieval. - Enhanced user experience with form dialogs for quick creation of sites and persons within company inventory.
29 lines
957 B
TypeScript
29 lines
957 B
TypeScript
import { z } from "zod/v4";
|
|
|
|
const title = z.string().min(1).max(100);
|
|
export const FieldTypeSchema = z.enum(["text", "number", "date", "boolean", "choice"]);
|
|
export const TemplateFieldSchema = z.strictObject({ fieldId: z.uuid(), required: z.boolean() });
|
|
export const AssetDefinitionSchema = z.discriminatedUnion("kind", [
|
|
z.strictObject({
|
|
kind: z.literal("field"),
|
|
name: title,
|
|
description: z.string().max(1000),
|
|
type: FieldTypeSchema,
|
|
unit: z.string().max(30),
|
|
choices: z.array(title).max(100),
|
|
}),
|
|
z.strictObject({
|
|
kind: z.literal("template"),
|
|
name: title,
|
|
description: z.string().max(1000),
|
|
fields: z.array(TemplateFieldSchema).min(1).max(100),
|
|
}),
|
|
]);
|
|
export type AssetDefinitionSpec = z.infer<typeof AssetDefinitionSchema>;
|
|
export type AssetFieldType = z.infer<typeof FieldTypeSchema>;
|
|
export class AssetCatalogError extends Error {
|
|
constructor(public readonly code: string) {
|
|
super(code);
|
|
}
|
|
}
|