* Fetches the structured content of a Google Doc via the Docs API and * extracts it as plain text.
(accessToken: string, documentId: string)
| 112 | * extracts it as plain text. |
| 113 | */ |
| 114 | async function fetchDocContent(accessToken: string, documentId: string): Promise<string> { |
| 115 | const url = `https://docs.googleapis.com/v1/documents/${documentId}?fields=body.content` |
| 116 | |
| 117 | const response = await fetchWithRetry(url, { |
| 118 | method: 'GET', |
| 119 | headers: { |
| 120 | Authorization: `Bearer ${accessToken}`, |
| 121 | Accept: 'application/json', |
| 122 | }, |
| 123 | }) |
| 124 | |
| 125 | if (!response.ok) { |
| 126 | throw new Error(`Failed to fetch Google Doc content ${documentId}: ${response.status}`) |
| 127 | } |
| 128 | |
| 129 | const doc = (await response.json()) as DocsDocument |
| 130 | return extractTextFromDocsBody(doc) |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Creates a lightweight stub from a Drive file entry. Content is deferred |
no test coverage detected