metis-desk/modules/assets/src/common/inventory.ts

34 lines
1.2 KiB
TypeScript
Raw Normal View History

import { z } from "zod/v4";
import {
AssetInputSchema,
AssetSpecificationSchema,
AssetStatusSchema,
AssetValueSchema,
} from "../api/domain/asset-values";
export type { AssetCharacteristic, AssetInput } from "../api/domain/asset-values";
export { AssetInputSchema, AssetSpecificationSchema, AssetStatusSchema, AssetValueSchema };
export const InventoryParamsSchema = z.strictObject({ companyId: z.uuid() });
export const AssetParamsSchema = InventoryParamsSchema.extend({ id: z.uuid() });
export const SaveAssetRequestSchema = z.strictObject({ values: AssetInputSchema });
export const AssetRevisionSchema = z.strictObject({
id: z.uuid(),
values: AssetInputSchema,
actorId: z.uuid(),
actorName: z.string().min(1),
recordedAt: z.iso.datetime(),
});
export const AssetSchema = z.strictObject({
id: z.uuid(),
companyId: z.uuid(),
specification: AssetSpecificationSchema,
values: AssetInputSchema,
history: z.array(AssetRevisionSchema).min(1),
});
export const InventoryResponseSchema = z.strictObject({ assets: z.array(AssetSchema) });
export const AssetResponseSchema = z.strictObject({ asset: AssetSchema });
export type AssetDTO = z.infer<typeof AssetSchema>;
export type AssetResponseDTO = z.infer<typeof AssetResponseSchema>;