Skip to content

feat(dataconnect): Introduce TransportManager and Transport Abstraction#9609

Merged
stephenarosaj merged 10 commits intopasta/mainfrom
pasta/fettucine
Mar 3, 2026
Merged

feat(dataconnect): Introduce TransportManager and Transport Abstraction#9609
stephenarosaj merged 10 commits intopasta/mainfrom
pasta/fettucine

Conversation

@stephenarosaj
Copy link
Copy Markdown
Contributor

@stephenarosaj stephenarosaj commented Feb 27, 2026

Overview

✨ This PR adds a TransportManager in between the concrete RESTTransport implementation and the query layer. It also abstracts common transport logic to a base DataConnectTransport class to share common logic across different transport types - now, REST transport only handles REST / fetch specific functionality.

Key Changes

  • Transport Manager: Created DataConnectTransportManager to act as the entry point for network operations. It currently routes all requests to the REST transport.
  • Transport Abstraction: Introduced DataConnectTransportClass, an abstract base class that encapsulates shared logic such as authentication management, emulator configuration, and URL construction.
  • RESTTransport Refactor: Refactored RESTTransport to extend DataConnectTransportClass, allowing REST Transport to focus only on REST-related functionality.
  • Interface Updates: Updated the DataConnectTransport interface to include invokeSubscribe and invokeUnsubscribe methods. These are unsupported in RESTTransport.
  • Code Quality: Standardized generic type naming (Data, Variables) and authentication property naming (authToken and onAuthTokenChange) for improved readability and consistency.

Testing

  • Added unit tests for DataConnectTransportManager to verify initialization and delegation logic. These will be updated / expanded later to test management of different transport implementations.
  • Verified that all existing unit tests pass with no regressions.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: 1b05f06

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

gemini-code-assist Bot commented Feb 27, 2026

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for a more flexible and extensible network transport layer within the Data Connect SDK. It establishes a clear separation of concerns by introducing a central manager for routing requests and an abstract base class to consolidate shared functionalities. This architectural change will facilitate the integration of diverse transport mechanisms in the future, while also improving code maintainability and consistency.

Highlights

  • Transport Manager Introduced: A new DataConnectTransportManager class has been created to serve as the central entry point for network operations, currently routing all requests to the REST transport but designed for future extensibility to other transport implementations.
  • Transport Abstraction Layer: An abstract base class, DataConnectTransportClass, has been introduced to encapsulate common logic such as authentication management, emulator configuration, and URL construction, reducing duplication across different transport types.
  • RESTTransport Refactored: The existing RESTTransport has been refactored to extend the new DataConnectTransportClass, inheriting shared logic and standardizing its behavior.
  • Subscription Interface Updates: The DataConnectTransport interface has been updated to include invokeSubscribe and invokeUnsubscribe methods, enabling the SDK to support subscription-based operations.
  • Code Quality Improvements: Generic type naming (Data, Variables) and authentication property naming (authToken) have been standardized for improved readability and consistency across the codebase.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/data-connect/src/network/DataConnectTransport.ts
    • Added new imports for error handling, SDK version, logging, and URL utilities.
    • Introduced SubscribeNotificationHook type for subscription notifications.
    • Updated the DataConnectTransport interface to include invokeSubscribe, invokeUnsubscribe, and onAuthTokenChanged methods, and standardized generic type names.
    • Added getGoogApiClientValue function for constructing the X-Goog-Api-Client header.
    • Introduced the abstract DataConnectTransportClass to centralize common transport logic like URL construction, authentication, and emulator management.
  • packages/data-connect/src/network/manager.ts
    • Added the DataConnectTransportManager class to act as a central dispatcher for transport operations.
    • Implemented delegation for invokeQuery, invokeMutation, invokeSubscribe, invokeUnsubscribe, useEmulator, and onAuthTokenChanged to the RESTTransport.
  • packages/data-connect/src/network/rest/RestTransport.ts
    • Refactored RESTTransport to extend DataConnectTransportClass, removing duplicated properties and methods related to host, port, authentication, and emulator configuration.
    • Implemented invokeSubscribe and invokeUnsubscribe to throw NOT_SUPPORTED errors, indicating that REST transport does not support subscriptions.
    • Updated onTokenChanged to onAuthTokenChanged to align with the new base class interface and assigned the token to _authToken.
    • Updated generic type parameters in invokeQuery and invokeMutation for consistency.
  • packages/data-connect/src/network/rest/fetch.ts
    • Updated generic type parameters in DataConnectFetchBody and dcFetch from T, U to Data, Variables for improved clarity and consistency.
  • packages/data-connect/test/unit/transportManager.test.ts
    • Added unit tests for DataConnectTransportManager to verify that it correctly delegates calls to the underlying RESTTransport for various operations like queries, mutations, subscriptions, emulator usage, and auth token changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a transport abstraction layer to support multiple transport implementations in the future. It refactors the existing RESTTransport to use a new DataConnectTransportClass base class, which encapsulates common logic. The changes are well-structured and improve the architecture for future extensions.

My review includes several suggestions to improve code clarity, correctness, and type safety. I've pointed out a logic issue in getWithAuth and proposed a cleaner implementation using async/await. I've also highlighted some unsafe type casts in RESTTransport that could hide potential bugs, and suggested refactoring opportunities for better readability in other areas. Additionally, there are minor suggestions for API consistency and documentation.

Comment thread packages/data-connect/src/network/DataConnectTransport.ts
Comment thread packages/data-connect/src/network/rest/RestTransport.ts Outdated
Comment thread packages/data-connect/src/network/rest/RestTransport.ts Outdated
Comment thread packages/data-connect/src/network/DataConnectTransport.ts Outdated
Comment thread packages/data-connect/src/network/DataConnectTransport.ts
Comment thread packages/data-connect/src/network/manager.ts
@firebase firebase deleted a comment from gemini-code-assist Bot Feb 27, 2026
@stephenarosaj stephenarosaj marked this pull request as ready for review March 2, 2026 23:12
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one minor comment

Comment thread packages/data-connect/src/network/DataConnectTransport.ts Outdated
@stephenarosaj stephenarosaj merged commit a75d956 into pasta/main Mar 3, 2026
29 checks passed
@stephenarosaj stephenarosaj deleted the pasta/fettucine branch March 3, 2026 22:21
@firebase firebase locked and limited conversation to collaborators Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants