All files / src/services aiPromptService.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                  1x 3x 2x     1x 3x 2x     1x       3x 3x 2x     1x 3x 2x    
/**
 * AI Prompt Management Service
 *
 * Provides CRUD access to the three organizer-editable OpenAI prompts:
 *   - event_description  — GPT-4o event description generation
 *   - theme_image        — DALL-E theme image generation
 *   - abstract_quality   — GPT-4o abstract quality review
 *
 * CRITICAL: Always use this service — never call apiClient directly from components.
 */
 
import apiClient from '@/services/api/apiClient';
import type { components } from '@/types/generated/event-ai-api.types';
 
export type AiPromptResponse = components['schemas']['AiPromptResponse'];
export type UpdateAiPromptRequest = components['schemas']['UpdateAiPromptRequest'];
 
export const listAiPrompts = async (): Promise<AiPromptResponse[]> => {
  const response = await apiClient.get<AiPromptResponse[]>('/ai-prompts');
  return response.data;
};
 
export const getAiPrompt = async (promptKey: string): Promise<AiPromptResponse> => {
  const response = await apiClient.get<AiPromptResponse>(`/ai-prompts/${promptKey}`);
  return response.data;
};
 
export const updateAiPrompt = async (
  promptKey: string,
  promptText: string
): Promise<AiPromptResponse> => {
  const body: UpdateAiPromptRequest = { promptText };
  const response = await apiClient.put<AiPromptResponse>(`/ai-prompts/${promptKey}`, body);
  return response.data;
};
 
export const resetAiPrompt = async (promptKey: string): Promise<AiPromptResponse> => {
  const response = await apiClient.post<AiPromptResponse>(`/ai-prompts/${promptKey}/reset`);
  return response.data;
};