/** Product variant and rich-data domain models. */
export type JsonRecord = Record<string, unknown>;
export type NutritionSource = 'manual' | 'manufacturer' | 'openfoodfacts';

export const NUTRITION_SOURCES: readonly NutritionSource[] = [
  'manual',
  'manufacturer',
  'openfoodfacts',
];

export interface ProductVariant {
  id: string;
  productId: string;
  sku: string;
  ean: string | null;
  attributes: JsonRecord;
  createdAt: Date;
  updatedAt: Date;
}

export interface NewProductVariant {
  sku: string;
  ean?: string | null;
  attributes?: JsonRecord;
}

export type ProductVariantPatch = Partial<NewProductVariant>;

export interface ProductRichData {
  productId: string;
  ingredients: string | null;
  allergens: string[];
  nutrition: JsonRecord | null;
  nutritionSource: NutritionSource | null;
  isOrganic: boolean;
  organicCertification: string | null;
  createdAt: Date;
  updatedAt: Date;
}

export interface RichDataPatch {
  ingredients?: string | null;
  allergens?: string[];
  nutrition?: JsonRecord | null;
  nutritionSource?: NutritionSource;
  isOrganic?: boolean;
  organicCertification?: string | null;
}
