import { z } from 'zod';
import { EntitySchema, EntityContainerSchema } from '@isa/common/data-access';

export const CategorySchema: z.ZodType<{
  changed?: string;
  created?: string;
  id?: number;
  pId?: string;
  status?: number;
  uId?: string;
  version?: number;
  name?: string;
  parent?: {
    id?: number;
    pId?: string;
    uId?: string;
    data?: any;
  };
  type?: string;
  key?: string;
  sort?: number;
  start?: string;
  stop?: string;
  tenant?: {
    id?: number;
    pId?: string;
    uId?: string;
    data?: any;
  };
}> = EntitySchema.extend({
  name: z.string().describe('Name').optional(),
  parent: z.lazy(() => EntityContainerSchema(CategorySchema)).describe('Parent').optional(),
  type: z.string().describe('Type').optional(),
  key: z.string().describe('Key').optional(),
  sort: z.number().int().describe('Sort criteria').optional(),
  start: z.string().describe('Start').optional(),
  stop: z.string().describe('Stop').optional(),
  tenant: EntityContainerSchema(z.any()).describe('Tenant identifier').optional(),
});

export type Category = z.infer<typeof CategorySchema>;
