refactor(api-client): publish only the shared contract from the root barrel
This commit is contained in:
parent
6533084a0d
commit
c3367bc611
7 changed files with 100 additions and 374 deletions
|
|
@ -1,24 +1,11 @@
|
|||
// D3RO Cloud STT client. User-facing transcription always passes through the
|
||||
// Supabase Edge gateway that owns authentication, quota and usage accounting.
|
||||
// Not part of the package's public surface (no root/sub-path export): the
|
||||
// shared contract is ./stt-contract. Kept only as the reference for its test.
|
||||
|
||||
export interface TranscribeAudioParams {
|
||||
audio: Blob | ArrayBuffer | Uint8Array | string
|
||||
language?: string
|
||||
supabaseUrl?: string
|
||||
anonKey?: string
|
||||
token?: string
|
||||
}
|
||||
import type { TranscribeAudioParams, TranscribeAudioResult } from './stt-contract'
|
||||
|
||||
export interface TranscribeAudioResult {
|
||||
text: string
|
||||
confidence: number
|
||||
language: string
|
||||
durationSeconds: number
|
||||
provider: string
|
||||
latencyMs: number
|
||||
modelId?: string
|
||||
cost?: number
|
||||
}
|
||||
export type { TranscribeAudioParams, TranscribeAudioResult }
|
||||
|
||||
function decodeBase64(value: string): Uint8Array {
|
||||
const normalized = value.replace(/^data:[^,]*,/, '').replace(/\s+/g, '')
|
||||
|
|
@ -83,8 +70,8 @@ function parseResult(value: unknown, latencyMs: number): TranscribeAudioResult {
|
|||
}
|
||||
|
||||
export async function transcribeAudio(params: TranscribeAudioParams): Promise<TranscribeAudioResult> {
|
||||
const supabaseUrl = params.supabaseUrl ?? process.env.NEXT_PUBLIC_SUPABASE_URL ?? ''
|
||||
const anonKey = params.anonKey ?? process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? ''
|
||||
const supabaseUrl = params.supabaseUrl ?? ''
|
||||
const anonKey = params.anonKey ?? ''
|
||||
const token = params.token ?? ''
|
||||
if (!supabaseUrl || !anonKey || !token) {
|
||||
throw new Error('STT gateway requires an authenticated Supabase session.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue