test: implement resource template propagation tests for resource revisions feat: create prepareResourceTemplateUpdates function for handling resource template updates feat: add resource revision specifications for managing resource revisions in the database test: add tests for entity column visibility and local storage handling feat: implement entity column visibility storage for managing column preferences feat: create synchronizeTemplateStructure utility for managing template field and section synchronization
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { z } from "zod/v4";
|
|
|
|
import { FieldTypeSchema, TemplateSectionSchema } from "./asset-definition";
|
|
|
|
export const AssetStatusSchema = z.enum(["operational", "broken", "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(),
|
|
sectionId: z.uuid().optional(),
|
|
});
|
|
|
|
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(),
|
|
brandId: z.uuid().nullable().optional(),
|
|
registeredOn: z.iso.date().nullable().optional(),
|
|
status: AssetStatusSchema,
|
|
notes: z.string().max(10000),
|
|
characteristics: z.record(z.uuid(), AssetValueSchema),
|
|
});
|
|
|
|
// Las revisiones conservan el estado registrado en su momento.
|
|
export const AssetRecordedInputSchema = AssetInputSchema.extend({
|
|
status: z.enum(["available", "in_use", ...AssetStatusSchema.options]),
|
|
});
|
|
|
|
export type AssetRecordedInput = z.infer<typeof AssetRecordedInputSchema>;
|
|
|
|
export const AssetSpecificationSchema = z.strictObject({
|
|
templateId: z.uuid(),
|
|
templateName: z.string().min(1).max(100),
|
|
sections: z.array(TemplateSectionSchema).optional(),
|
|
fields: z.array(AssetCharacteristicSchema).min(1),
|
|
});
|
|
|
|
export type AssetInput = z.infer<typeof AssetInputSchema>;
|
|
|
|
export type AssetSpecificationData = z.infer<typeof AssetSpecificationSchema>;
|
|
|
|
export type AssetCharacteristic = z.infer<typeof AssetCharacteristicSchema>;
|