feat(entities): production + report — types, lib, api, tests floutage (Sprint 3 étape 13)
This commit is contained in:
parent
ca4291d7eb
commit
b31e8666a5
8 changed files with 301 additions and 0 deletions
37
src/entities/report/api.ts
Normal file
37
src/entities/report/api.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Appels API du domaine `report`.
|
||||
*
|
||||
* Toutes les requêtes passent par `apiFetch` (Règle J / Règle F).
|
||||
* Timeout 30 s : DeepSeek (EE) et Gemini (EO) peuvent mettre jusqu'à 20-25 s.
|
||||
* Retry désactivé : POST non-idempotent — une double soumission créerait
|
||||
* deux corrections facturées sur le quota Free.
|
||||
*
|
||||
* Erreurs notables : SIMULATION_NOT_FOUND (404), AUTH_REQUIRED (401),
|
||||
* QUOTA_REACHED (403 — côté simulation, pas correction).
|
||||
*/
|
||||
|
||||
import { apiFetch } from '@/shared/lib/api-client'
|
||||
import type { CorrectEePayload, CorrectEoPayload, Report } from './types'
|
||||
|
||||
const CORRECTION_TIMEOUT_MS = 30_000
|
||||
|
||||
/** Soumet une production écrite pour correction. Endpoint : `POST /corrections/ee`. */
|
||||
export function correctEe(payload: CorrectEePayload): Promise<Report> {
|
||||
return apiFetch<Report>('/corrections/ee', {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
timeoutMs: CORRECTION_TIMEOUT_MS,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Soumet une production orale pour correction. Endpoint : `POST /corrections/eo`.
|
||||
* audio_url : URL pré-signée après upload Supabase Storage (implémenté Sprint 4).
|
||||
*/
|
||||
export function correctEo(payload: CorrectEoPayload): Promise<Report> {
|
||||
return apiFetch<Report>('/corrections/eo', {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
timeoutMs: CORRECTION_TIMEOUT_MS,
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue