* Fetches the speaker-attributed transcript segments for a recording. * Returns null on 404, or an empty array when the recording has no transcript yet.
( accessToken: string, id: string )
| 301 | * Returns null on 404, or an empty array when the recording has no transcript yet. |
| 302 | */ |
| 303 | async function fetchTranscript( |
| 304 | accessToken: string, |
| 305 | id: string |
| 306 | ): Promise<GrainTranscriptSegment[] | null> { |
| 307 | const response = await fetchWithRetry(`${GRAIN_API_BASE}/recordings/${id}/transcript`, { |
| 308 | method: 'GET', |
| 309 | headers: grainHeaders(accessToken), |
| 310 | }) |
| 311 | |
| 312 | if (!response.ok) { |
| 313 | if (response.status === 404) return null |
| 314 | throw new Error(`Failed to fetch Grain transcript: ${response.status}`) |
| 315 | } |
| 316 | |
| 317 | const data = await response.json() |
| 318 | return Array.isArray(data) ? (data as GrainTranscriptSegment[]) : [] |
| 319 | } |
| 320 | |
| 321 | export const grainConnector: ConnectorConfig = { |
| 322 | ...grainConnectorMeta, |
no test coverage detected