Repository navigation
Generate the Gmail template from Google's API description - #319
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 24a5c98 | Nov 23 2026, 10:17 AM |
tnkuehne
force-pushed
the
feat/gmail-template
branch
from
November 22, 2026 23:52
a5b3910 to
55836a5
Compare
tnkuehne
force-pushed
the
feat/gmail-template
branch
from
November 22, 2026 23:53
55836a5 to
20e20d6
Compare
The Gmail template wrapped a handful of hand-written methods. It now offers Gmail's whole API as typed methods, generated from Google's discovery document: pnpm --filter @platform/template-generator generate gmail. Each method takes its path and query parameters and a typed body, and returns only the fields its selection names; the selection becomes Google's fields parameter. Methods that only service accounts can call are not offered. Changes ask for approval like in the Linear template, with a new "send" category for messages and other actions that reach other people. Gmail connects with the organization's own OAuth client, and the template requests the scopes the offered methods need.
A change checks the connection status before it asks for approval. An account that granted fewer scopes was reported as connected there, so the user was asked first and the change then failed with permission_required.
Responses larger than 8 MiB return too_large instead of being read into memory, as the hand-written template did. Optional arguments passed as undefined are left out, and repeated parameters with choices take a list of them.
When a save's reply is lost, the level may have been stored anyway. The page now reads the stored level and shows it, and reports a failure only when the stored level differs from the chosen one.
When a save fails while the user has already chosen another level, the page keeps that choice and saves it next instead of showing the stored level.
tnkuehne
force-pushed
the
feat/gmail-template
branch
from
November 23, 2026 10:05
e3f354b to
dbc93a4
Compare
tnkuehne
added a commit
that referenced
this pull request
Nov 23, 2026
#324) ## Why Google Calendar is one of the most requested integrations, and none of the templates covers it yet. Google publishes a Discovery document for it, which the generator from #319 already reads. A calendar template therefore needs only its rules and the template code around the generated API. ## What changes **Google Calendar template** (`templates/google-calendar`) - **Methods:** all 38 methods of the Google Calendar API as typed methods with field selections: events and recurring instances, calendars, the calendar list, sharing (ACL), settings, colors, free/busy times, and push notification channels. None is left out. - **Approvals:** each user's approval level decides when a method asks, as in the other templates. - `eventsInsert` is `send`: it adds the event to its guests' calendars and, with `sendUpdates`, emails them. - Quick-add, imported private copies and new calendars are `create`. - Changing, moving, sharing, clearing and deleting are updates or deletions. - **Scope:** `https://www.googleapis.com/auth/calendar`, which covers every method. An account connected with fewer scopes gets `permission_required`. - **OAuth:** the organization's own Google OAuth client only (`GOOGLE_CLIENT_ID`/`GOOGLE_CLIENT_SECRET`), like Gmail. The scope is sensitive, so a managed client would need Google's verification. - **Results:** `calendar_error` carries Google's message, status and reasons. Rate limits, missing scopes, revoked tokens and responses over 8 MiB are handled as in Gmail. - **Icon:** a plain calendar icon, not Google's logo. - `template.md` describes setup, method names, selections, approvals, results and how to regenerate. **Generator** - **`read` rule:** discovery rules accept `read` for methods that only read through a POST, such as `freebusy.query`. Those methods never ask. **Catalog tests** - **Template list:** the catalog tests compare against the template directories in the repository instead of a fixed list of four, so adding a template doesn't change them. ## Connection page New page, connected state, with the same approval form as the other templates. | 1280 px | 390 px | | --- | --- | | <img src="https://gist.githubusercontent.com/tnkuehne/2e857c8b70cfc0a62168609f2702355e/raw/90e74caf0ea6221c430b0094bd0ff5df4120a8f7/calendar-after-1280.png" width="400"> | <img src="https://gist.githubusercontent.com/tnkuehne/2e857c8b70cfc0a62168609f2702355e/raw/90e74caf0ea6221c430b0094bd0ff5df4120a8f7/calendar-after-390.png" width="200"> | ## Testing - `pnpm check` - **Generator:** a test for the `read` rule. - **Calendar template against a mocked Google:** - typed requests with `fields` URLs and `undefined` arguments left out; - invitations asking as `send`; - quick-add running at once by default and asking at `all_changes`; - `freebusyQuery` never asking; - each approval level; - Google errors, rate limits and missing scopes; - oversized responses; - token refresh, outages and callback checks. - **Type tests:** the README example compiles; unknown fields, missing selections, a missing calendar and wrong choices don't. - **Catalog and template install tests:** pass with the new template. - Not tested against a live Google account. <!-- greptile_comment --> <!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=116075280&sig=ae468be2d6b8b06c9cb9abfa21e52632275c8828c174e4745950025fe3243aad"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F324&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier: apex" title="Review tier: apex" src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-apex.svg?v=3" height="12"></sup></h2> <!-- greptile-impact-verdict --> The PR appears safe to merge with the required query-argument checks from dependent PR #325. <details open><summary><h3>Summary</h3></summary> Adds a personal Google Calendar template with 38 typed methods, field selections and per-user approvals. - Apps can connect a user's Google account and call typed Calendar methods. - The generator can include read-only methods that use POST. </details> <details open><summary><h3>Diagram</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A["Calendar method"] --> B["Build request and field selection"] B --> C{"Changes data?"} C -- No --> F["Send with the user's Google token"] C -- Yes --> D{"Approval needed?"} D -- No --> F D -- Yes --> E["Ask the user"] E -- Accepted --> F E -- Declined --> G["Return declined"] F --> H["Return selected data or an error"] ``` </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (15) · Last reviewed commit: ["Add a Google Calendar template generated..."](615a3e6) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Gmail template offers a few hand-written methods: search messages, read them, download attachments. Anything else, like sending, drafts, labels or settings, needs a template change. Linear already exposes its whole API as typed methods with approvals. Gmail gets the same from Google's published discovery document, and so can later Google templates (Calendar, Drive, Sheets).
What changes
Generator
users.messages.getbecomesmessagesGet.body. Path parameters with a default, likeuserId: "me", are optional.src/schema.tslists each method's HTTP route and parameters, and the OAuth scopes that cover all offered methods.historyTypes?: ("messageAdded" | ...)[].scripts/operations.tsas a change or as not offered. New methods and stale rules stop the generator, like for GraphQL.select. The runtime turns it into Google'sfieldsparameter (id,payload(headers,parts(mimeType))), so Google returns only the selected fields. The selection types now handle REST schemas, where every field is optional.GET /approval-leveland shows it, because a lost reply may follow a successful save. It reports a failure only when the stored level differs from the chosen one.send: for actions that reach other people, like sending a message or an invitation. The default level asks before changes, deletions and sends. In Linear, invitations, invite resends and update reminders are nowsend.Gmail template
69 typed methods.
10 methods are not offered because only service accounts can call them: S/MIME, delegates, forwarding addresses and send-as changes.
Approvals work like in the Linear template: per-user level on the connection page, plus the approval question in the agent.
Scopes:
https://mail.google.com/andgmail.settings.basic, which cover every offered method. Both are restricted scopes. A connection that lacks one answerspermission_requiredwith a link to reconnect.Errors:
reconnectrate_limitedwithretryAfterinsufficientPermissionspermission_requiredgmail_errorwith Google's message, status and reasonsLarge responses: larger than 8 MiB, declared or counted while streaming, give
too_largewithmaximumBytes. Nothing is read into memory past the limit, as in the hand-written template.Arguments: optional arguments passed as
undefinedare left out, so defaults such asuserId: "me"apply.Missing scopes:
connectionStatusreportspermission_requiredfor an account with fewer scopes. Before, a change asked for approval first and then failed.OAuth: Gmail connects only with the organization's own OAuth client (
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET). The managed login and its test case intemplate-oauth.test.tsare removed.The hand-written message helpers (
messages.ts,bytes.ts) are removed. Apps decoderawand body data themselves.template.mddescribes method names, selections, approvals, results, scopes and how to regenerate.Connection page
Connected state, with the same approval form as Linear.
Not shown: the disconnected and setup-required states. They only change their description text.
Testing
pnpm checkfieldsexpressions, request building.fieldsURLs, approvals for send, delete and every level, error mapping, missing scopes.

Confidence Score: 5/5
The PR appears safe to merge; the forwarding approval gap is closed.Summary
Generates Gmail's typed API and adds shared request and approval code.
Reviews (6) · Last reviewed commit: "Ask before Gmail filters, which can forw..." · Reviewed by Greptile