import type { ApiResponse, RecipeDraft, UrlImportResult, HarnessStatus } from './api-aux';
import type { Tag } from './tag';

export type { ApiResponse, RecipeDraft, UrlImportResult, HarnessStatus };
// Only import Tag from tag.ts
export type { Tag };

export interface Ingredient {
  id: number;
  recipe_id: number;
  position: number;
  quantity?: string | null;
  unit?: string | null;
  item: string;
  notes?: string | null;
}

export interface Step {
  id: number;
  recipe_id: number;
  position: number;
  instruction: string;
}

export interface Recipe {
  id: number;
  title: string;
  description: string | null;
  servings: number | null;
  prep_time_minutes: number | null;
  cook_time_minutes: number | null;
  source_url: string | null;
  created_at: number;
  updated_at: number;
  ingredients: Ingredient[];
  steps: Step[];
  tags: Tag[];
  last_cooked_at?: number | null;
  notes?: string | null;
  instructions?: string[]; // For FE compatibility only
}

export interface CreateRecipeInput {
  title: string;
  description?: string;
  servings?: number;
  prep_time_minutes?: number;
  cook_time_minutes?: number;
  source_url?: string;
  ingredients: Partial<Omit<Ingredient, 'id' | 'recipe_id'> & { position?: number }>;
  steps: Partial<Omit<Step, 'id' | 'recipe_id'> & { position?: number }>;
  tagIds?: number[];
}

export interface UpdateRecipeInput {
  title?: string;
  description?: string | null;
  servings?: number | null;
  prep_time_minutes?: number | null;
  cook_time_minutes?: number | null;
  source_url?: string | null;
  ingredients?: Partial<Omit<Ingredient, 'id' | 'recipe_id'> & { position?: number }>[];
  steps?: Partial<Omit<Step, 'id' | 'recipe_id'> & { position?: number }>[];
  tagIds?: number[];
}

export interface RecipeFilters {
  search?: string;
  offset?: number;
  limit?: number;
  tagId?: number | null;
  tagIds?: number[];
}
