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

Function getStartPageToken

apps/sim/lib/webhooks/polling/google-drive.ts:214–245  ·  view source on GitHub ↗
(
  accessToken: string,
  config: GoogleDriveWebhookConfig,
  requestId: string,
  logger: Logger
)

Source from the content-addressed store, hash-verified

212}
213
214async function getStartPageToken(
215 accessToken: string,
216 config: GoogleDriveWebhookConfig,
217 requestId: string,
218 logger: Logger
219): Promise<string> {
220 const params = new URLSearchParams()
221 if (config.includeSharedDrives) {
222 params.set('supportsAllDrives', 'true')
223 }
224
225 const url = `${DRIVE_API_BASE}/changes/startPageToken?${params.toString()}`
226 const response = await fetch(url, {
227 headers: { Authorization: `Bearer ${accessToken}` },
228 })
229
230 if (!response.ok) {
231 const status = response.status
232 const errorData = await response.json().catch(() => ({}))
233 if (status === 429 || isDriveRateLimitError(status, errorData)) {
234 const err = new Error(`Drive API rate limit (${status}): ${JSON.stringify(errorData)}`)
235 err.name = 'DriveRateLimitError'
236 throw err
237 }
238 throw new Error(
239 `Failed to get Drive start page token: ${status} - ${JSON.stringify(errorData)}`
240 )
241 }
242
243 const data = await response.json()
244 return data.startPageToken as string
245}
246
247async function fetchChanges(
248 accessToken: string,

Callers 1

pollWebhookFunction · 0.85

Calls 3

isDriveRateLimitErrorFunction · 0.85
setMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected