import { z } from 'zod';
import { EntityReferenceContainerSchema } from './entity-reference-container.schema';

/**
 * Generic schema factory for EntityDTOContainer<T>
 * Creates a schema for an entity container that extends EntityDTOReferenceContainer
 * and adds a typed `data` field.
 *
 * @param dataSchema - The Zod schema for the entity data type
 * @returns A Zod schema for EntityDTOContainer with the specified data type
 *
 * @example
 * const ShopItemContainerSchema = EntityDTOContainerSchema(ShopItemDTOSchema);
 */
export const EntityContainerSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>
  EntityReferenceContainerSchema.extend({
    data: dataSchema.describe('Data').optional(),
  });
