import {
  EntitySchema,
  QuantityUnitTypeSchema,
} from '@isa/common/data-access';
import { z } from 'zod';
import { ComponentItemSchema } from './component-item.schema';
import { SetTypeSchema } from './set-type.schema';

export const ComponentsSchema = z
  .object({
    items: z.array(ComponentItemSchema).describe('List of items').optional(),
    type: SetTypeSchema.describe('Type').optional(),
    overallQuantityMin: z.number().describe('Overall quantity min').optional(),
    overallQuantityMax: z.number().describe('Overall quantity max').optional(),
    quantityUnitType: QuantityUnitTypeSchema.describe('QuantityUnit type').optional(),
    unit: z.string().describe('Unit').optional(),
    referenceQuantity: z.number().describe('Reference quantity').optional(),
  })
  .extend(EntitySchema.shape);

export type Components = z.infer<typeof ComponentsSchema>;
