Google Meet: add a client for Google's event subscriptions

Merged
EH
2d ago
+552-33

Context

Follows https://github.com/twentyhq/twenty/pull/30598 in the Google Meet app series started in https://github.com/twentyhq/twenty/pull/30587.

The app will learn about new transcripts from Google instead of polling: each connected user gets a Google Workspace Events subscription that publishes Meet events to a Pub/Sub topic, which pushes them to a Twenty server route. The polling approach in https://github.com/twentyhq/twenty/pull/30599 was closed in favour of this. This PR is the first of the push series and only adds the client for the subscriptions API. Nothing calls it yet.

What this PR does

  • Adds createGoogleMeetEventSubscriptionOrThrow, renewGoogleMeetEventSubscriptionOrThrow and deleteGoogleMeetEventSubscription, which call workspaceevents.googleapis.com/v1/subscriptions. Create targets one Google user and the transcript.v2.fileGenerated event, renew asks for the longest lifetime Google allows (7 days), delete tolerates a subscription Google no longer has.
  • Create and renew return a long-running operation. waitForGoogleWorkspaceEventsOperationOrThrow polls it (up to 5 times, 1 second apart) when Google returns it unfinished, and readGoogleMeetEventSubscriptionOrThrow unwraps the subscription or reports the operation's error.
  • Lets fetchGoogleMeetJson send a method and a JSON body, so the new calls reuse the existing error handling. Retries stay limited to requests that are safe to repeat: a POST is sent once, so a create that succeeded behind a 5xx is not sent again.
  • Moves the URL building and its path guard into buildGoogleApiUrlOrThrow, shared by the Meet API and the events API.

Checks

  • yarn lint, yarn typecheck, yarn test:unit (78 tests) and twenty app build pass locally.
  • Not run: integration tests (they need a running server, CI runs them), and no call was made against the real Google API. The first real call comes when the app subscribes on connect, later in the series.