Add Google Drive integration for browsing and importing files#3885
Add Google Drive integration for browsing and importing files#3885jbecke wants to merge 1 commit into
Conversation
Lets a Macro user connect their Google Drive account and import selected
folders/files into Macro as Projects and Documents (one-way import, no sync) —
matching the "import folders, but no sync; pick which folder trees" feedback.
Backend
- New `google_drive` crate (hexagonal domain/ports/service/outbound/inbound):
Drive v3 REST client, redis-cached access-token client (via
authentication_service), a `google_drive_links` Postgres repo, and an import
orchestration service that walks the selected tree via an explicit work-stack
(parents before children) over a `DriveImportSink` port.
- authentication_service: `/link/google-drive` init/finalize/status/delete
endpoints (reusing the shared Google OAuth callback) and an
`/internal/google_drive_access_token` endpoint.
- document_storage_service: `DriveImportSink` adapter that creates Projects +
Documents (reusing the existing presigned-upload + content pipeline) and
records each Drive->Macro mapping in `foreign_entity`; wires
`/google-drive/{files,import,connection}` under the authenticated router.
- authentication_service_client: `get_google_drive_access_token`.
- macro_db_client: `google_drive_links` migration.
- infra: `google_drive` FusionAuth IdP (Drive scopes, shared Google client).
Frontend (SolidJS)
- service-clients (auth + storage) and `@queries/drive` hooks for
connect/status/browse/import.
- "Google Drive" row in Account settings (Enable/Disable/Reconnect + Import),
an import dialog (folder navigator + multi-select), the OAuth callback route,
and a Drive icon.
Notes
- Google-native docs (Docs/Sheets/Slides) are exported to PDF for a robust v1
(they land directly in object storage); editable Office exports are a
follow-up.
- The new `google_drive_links` SQLx queries require `just prepare_db` against a
live Postgres to build offline (no DB was available in this environment, so
the DB-touching crates and the dss/auth-service builds were not compiled
here; the `google_drive` crate's non-DB surface, the auth client, and the
frontend type-check all pass).
https://claude.ai/code/session_01QwvJehxEZgSEH8RxA3Xecj
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I wonder if we could bridge in https://rclone.org/ or something similar some how, and have support for like every cloud provider at once |
Summary
Implements a complete Google Drive integration that allows Macro users to connect their Google Drive account via OAuth, browse their folder tree, and import selected files/folders into Macro as Projects and Documents.
Key Changes
Backend (Rust)
New
google_drivecrate with domain-driven architecture:Outbound adapters:
DriveApiClient: REST client for Google Drive API v3 with pagination supportAuthServiceAccessTokens: Resolves Drive access tokens via authentication_service with 30-minute redis cachingPgGoogleDriveLinkRepo: PostgreSQL persistence for user Drive connectionsInbound HTTP router (
google_drive_router):GET /files- List folder children for the picker UIPOST /import- Import selected Drive items into MacroGET /connection- Check if user has connected DriveImport sink (
GoogleDriveImportSink):foreign_entityrows for deduplication and traceabilityAuthentication service integration:
/link/google-driveendpoints for initiating and finalizing OAuth flowDatabase migration:
google_drive_linkstable to persist user Drive connectionsFrontend (TypeScript/SolidJS)
Google Drive import dialog (
GoogleDriveImportDialog):Query hooks (
@queries/drive):useGoogleDriveLinkStatusQuery- Check connection statususeInitGoogleDriveLink- Initiate OAuth flowuseFinalizeGoogleDriveLink- Complete OAuth flowuseDisconnectGoogleDrive- Disconnect DriveuseGoogleDriveFoldersQuery- Browse folder contentsuseImportFromGoogleDrive- Import selected itemsAccount settings integration:
GoogleDriveLinkCallback)Google Drive icon SVG for UI
Infrastructure
google_drivecrateImplementation Details
https://claude.ai/code/session_01QwvJehxEZgSEH8RxA3Xecj