import { api } from "./axiosInstance"; import type { CommitRecipesResult, GeneratedRecipeDraft, RecipeGeneratorConstraints, RecipeGeneratorSession, } from "@/types/generator.types"; export async function createRecipeSession(constraints: RecipeGeneratorConstraints): Promise { const { data } = await api.post("/recipe-generator/sessions", constraints); return data; } export async function fetchRecipeSession(id: number): Promise { const { data } = await api.get(`/recipe-generator/sessions/${id}`); return data; } export async function generateRecipeDrafts(sessionId: number, count = 3): Promise { const { data } = await api.post(`/recipe-generator/sessions/${sessionId}/generate`, { count, }); return data; } export async function regenerateRecipePart( sessionId: number, draftId: string, mode: "ingredients" | "steps" | "full", instruction?: string, ): Promise { const { data } = await api.post(`/recipe-generator/sessions/${sessionId}/regenerate`, { draftId, mode, instruction, }); return data; } export async function removeRecipeDraft(sessionId: number, draftId: string): Promise { const { data } = await api.delete( `/recipe-generator/sessions/${sessionId}/drafts/${encodeURIComponent(draftId)}`, ); return data; } export async function updateRecipeDraft( sessionId: number, draft: GeneratedRecipeDraft, ): Promise { const { data } = await api.put(`/recipe-generator/sessions/${sessionId}/draft`, draft); return data; } export async function commitRecipes(sessionId: number, draftIds?: string[]): Promise { const { data } = await api.post(`/recipe-generator/sessions/${sessionId}/commit`, { draftIds: draftIds?.length ? draftIds : undefined, }); return data; }