import { apiClient } from './client'; import type { VoiceAvailability, VoiceExtractionResult } from '@/types/voice'; export interface ExtractVoicePayload { /** Base64 audio, no data: prefix. */ audio: string; format: string; /** IANA zone — the server derives "today" from it for relative deadlines. */ timeZone: string; durationMs: number; /** Locale the clinician is speaking; the server uses it rather than the stored one. */ locale: string; } export const voiceApi = { availability: async (): Promise<{ success: boolean; data: VoiceAvailability }> => { const response = await apiClient.get('/voice/availability'); return response.data; }, extract: async ( payload: ExtractVoicePayload, signal?: AbortSignal, ): Promise<{ success: boolean; data: VoiceExtractionResult }> => { // The signal is forwarded so cancelling closes the connection, which aborts the // metered vendor call server-side rather than letting it settle unseen. const response = await apiClient.post('/voice/extract', payload, { signal }); return response.data; }, };