MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchDocContent

Function fetchDocContent

apps/sim/connectors/google-docs/google-docs.ts:114–131  ·  view source on GitHub ↗

* Fetches the structured content of a Google Doc via the Docs API and * extracts it as plain text.

(accessToken: string, documentId: string)

Source from the content-addressed store, hash-verified

112 * extracts it as plain text.
113 */
114async 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

Callers 1

google-docs.tsFile · 0.85

Calls 2

fetchWithRetryFunction · 0.90
extractTextFromDocsBodyFunction · 0.85

Tested by

no test coverage detected