Skip to content

Add a Google Drive template with file content and uploads - #327

Merged
tnkuehne merged 6 commits into
feat/outlook-templatefrom
feat/google-drive-template
Nov 23, 2026
Merged

tnkuehne merged 6 commits into
feat/outlook-templatefrom
feat/google-drive-template

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Google Drive is the file store of most Google Workspace organizations, and no template covers it yet. Unlike Calendar and Sheets, Drive is about file content: downloading, exporting Docs as text or PDF, and uploading. The discovery generator offered only JSON methods, so it needs media support first.

What changes

Google Drive template (templates/google-drive)

  • Methods: 60 typed methods with field selections: files and folders, shared drives, permissions, comments and replies, revisions, approvals, access proposals, changes and labels.
  • Not offered: the replaced team drive methods, client-side encryption tokens, and the user's installed Drive apps, which need their own scope.
  • Content:
    • filesGetContent and revisionsGetContent return a file's content with its contentType: as text for text media types (text/*, JSON, XML), as base64 otherwise, so results stay JSON for apps and MCP.
    • filesExport returns an exported Google Docs, Sheets or Slides file, for example as text/plain or application/pdf.
    • filesCreateWithContent and filesUpdateWithContent upload metadata and content together.
    • Content up to 8 MiB; larger files give too_large.
  • Approvals: each user's approval level decides when a method asks.
    • permissionsCreate is send: it emails the people it shares with unless sendNotificationEmail is false. Starting an approval is send too.
    • Changing, moving, deleting, emptying the trash, and changing comments, revisions and shared drives ask at the default level.
    • Creating and copying files, folders and shared drives, and adding comments, run at once.
    • filesDownload starts a download through a POST and never asks.
    • Replies count as updates, because they can resolve or reopen a comment. Comments on an approval are send.
  • Scope: https://www.googleapis.com/auth/drive. Google classifies it as restricted, like Gmail's scopes. An account connected with fewer scopes gets permission_required.
  • OAuth: the organization's own Google OAuth client only.
  • Icon: a plain folder icon, not Google's logo.
  • template.md describes setup, selections, file content and uploads, approvals, results and how to regenerate.

More discovery rules

  • nullableValues: lets map entries be null where Google documents null as removal. Drive uses it for File.properties and File.appProperties.
  • Media types: an upload's media type may not contain line breaks anywhere.
  • Reserved names: BinaryContent and UploadContent are reserved type names.

Discovery generator: file content

  • Downloads: a method that supports media download and returns metadata gets a second method, ...Content, which adds alt=media and returns BinaryContent. A method without other results, such as files.export, returns the content itself.
  • Uploads: a method with a multipart upload path gets ...WithContent. It sends the metadata (optional) and content: { mimeType, text } or { mimeType, base64 } as one multipart/related request to the upload path.
    • The media type may not contain line breaks, and base64 must be valid.
    • It asks like the method it extends.
  • Gmail: gains draftsCreate/Update/SendWithContent and messagesSend/Insert/ImportWithContent, which send raw MIME messages.
  • Shared content helpers: BinaryContent, UploadContent and the bounded content reader move from rest.ts into a shared content.ts runtime file, which discovery and OpenAPI templates both get.
  • Content results in all Google templates: their run.ts returns content results, bounded like JSON responses.

Connection page

New page, connected state, with the same approval form as the other templates.

1280 px 390 px

Testing

  • pnpm check
  • Generator: ...Content, content-only methods and ...WithContent with their runtime table entries.
  • Runtime: alt=media, the multipart body for base64 content, and rejected content: missing text or base64, line breaks in the media type, invalid base64.
  • Drive template against a mocked Google:
    • typed requests with fields URLs;
    • content and export reads;
    • a text upload running at once as one multipart request;
    • an invalid upload never sent;
    • sharing asking as send, and replacing content with base64 asking as an update;
    • deletion;
    • each approval level;
    • Google errors, rate limits and missing scopes;
    • oversized responses;
    • token refresh, outages and callback checks.
  • Type tests: the README examples compile; selections on content methods and uploads without content don't.
  • Regeneration: all eight templates reproduce their committed files. The Gmail, Calendar, Sheets, OneDrive, Outlook, managed OAuth and catalog tests pass.
  • Not tested against a live Google account.

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

The PR appears safe to merge; no new blocking issue was established.

Summary

Adds a Google Drive template with typed methods, file reads, exports, uploads, and per-user approvals.

  • Signed-in users can manage Drive files through typed app methods.
  • Generated Google methods can read file content and send uploads.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Typed API call] --> B[Check arguments and build request]
  B --> C{Approval required?}
  C -->|Yes| D[Ask the user]
  D -->|Declined| E[Return declined]
  D -->|Accepted| F[Load current user's Google token]
  C -->|No| F
  F --> G[Send Google request]
  G --> H{Response kind}
  H -->|JSON| I[Return selected fields]
  H -->|Content| J[Read up to 8 MiB]
  J --> K[Return text or base64]
Loading

Reviews (17) · Last reviewed commit: "Send upload text as UTF-8 only and other..." · Reviewed by Greptile

@tnkuehne
tnkuehne added this pull request to stack #320 November 23, 2026 01:08
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from 41a6d99 to 3bff403 Compare November 23, 2026 01:08
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 3c06f40 Nov 23 2026, 10:35 AM

Comment thread templates/google-drive/src/api.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from 3bff403 to 2d42791 Compare November 23, 2026 01:23
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from 2d42791 to d59d8b8 Compare November 23, 2026 01:33
Comment thread packages/template-generator/src/cli.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch 2 times, most recently from 246a9a5 to 995e16a Compare November 23, 2026 08:32
Comment thread templates/google-drive/src/run.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from 995e16a to c7a406c Compare November 23, 2026 09:16
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch 2 times, most recently from bcfe4a5 to 37bfec4 Compare November 23, 2026 09:33
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch 2 times, most recently from 17e1197 to ddf5eb5 Compare November 23, 2026 10:16
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from ddf5eb5 to c624f27 Compare November 23, 2026 10:30
The new template offers every method of the Google Drive API as a typed
method with field selections: files and folders, shared drives, sharing,
comments and replies, revisions, approvals and change tracking.

The discovery generator now offers file content: methods that read content
get a ...Content method that returns it, and exports return it directly.
Methods that accept uploads get a ...WithContent method that sends the
metadata and the content, as text or base64, in one multipart request. Gmail
gains such methods for sending and importing raw MIME messages. The content
helpers move into a runtime file that discovery and OpenAPI templates share.

Sharing with people, who are emailed by default, and starting an approval
count as send; changes ask for approval by each user's level.
A comment on an approval notifies its initiator and reviewers, so it counts
as send and asks at the default level.
…en media types

A reply can resolve or reopen its comment, so it counts as an update.
Discovery rules can let map entries be null where Google documents null as
removal, as Drive does for file properties. Upload media types may not
contain line breaks anywhere, and a schema named like an import of the
generated file stops generation.
@tnkuehne
tnkuehne force-pushed the feat/google-drive-template branch from c624f27 to 3c06f40 Compare November 23, 2026 10:34
@tnkuehne
tnkuehne merged commit 08a1a9c into main Nov 23, 2026
15 of 16 checks passed
@tnkuehne
tnkuehne deleted the feat/google-drive-template branch November 23, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant