Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt

Use this file to discover all available pages before exploring further.

GDocsResource exposes Google Docs as .gdoc.json files. Reads return the document’s structured content; writes update the doc in place via the Google Docs API. Setup steps for OAuth credentials live at Google Workspace Credentials.

Node

pnpm add @struktoai/mirage-node
import { GDocsResource, MountMode, Workspace } from '@struktoai/mirage-node'

const docs = new GDocsResource({
  clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
  refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
})

const ws = new Workspace({ '/docs': docs }, { mode: MountMode.WRITE })
await ws.execute('cat /docs/owned/MyDoc.gdoc.json')

Browser

pnpm add @struktoai/mirage-browser
import { GDocsResource, MountMode, Workspace } from '@struktoai/mirage-browser'

const docs = new GDocsResource({
  clientId: GOOGLE_CLIENT_ID,
  clientSecret: GOOGLE_CLIENT_SECRET,
  refreshToken: localStorage.getItem('gdocs.refresh_token')!,
})

const ws = new Workspace({ '/docs': docs }, { mode: MountMode.WRITE })
A PKCE example lives at examples/typescript/browser/src/gdocs_pkce.ts.

Config

FieldDefaultNotes
clientIdrequiredGoogle OAuth client ID.
clientSecretrequiredGoogle OAuth client secret. Redacted in snapshots.
refreshTokenrequiredUser’s refresh token. Redacted in snapshots.
refreshFnbuilt-inOptional override for the access-token refresh callback.

Mount mode

read, partial write (text replacements via the Docs API). For the JSON shape and supported edits see the Python Google Docs docs.