Skip to content

Destructuring API pt 1: foundation & pubsub#1837

Merged
inlined merged 7 commits intomasterfrom
inlined.destructuring.base
Mar 20, 2026
Merged

Destructuring API pt 1: foundation & pubsub#1837
inlined merged 7 commits intomasterfrom
inlined.destructuring.base

Conversation

@inlined
Copy link
Copy Markdown
Member

@inlined inlined commented Mar 19, 2026

Adds tools common to all the other subsequent PRs + pubsub since main already has those changes which are to be reverted. Part of the breakup of #1832

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 introduces foundational tools for handling V1 compatibility in CloudEvents, moving away from hardcoded, event-specific patching to a more flexible and generic getter-based approach. This change is the first step in a larger refactoring effort, providing a reusable mechanism to add compatibility properties dynamically and efficiently, ensuring that future compatibility needs can be met with a consistent pattern.

Highlights

  • Refactored V1 Compatibility Logic: The patchV1Compat function has been replaced with a more generic addV1Compat function, which allows for dynamic injection of V1 compatibility properties using getters.
  • Dynamic Getter-Based Property Injection: The new addV1Compat function accepts a map of getter functions, enabling lazy evaluation and flexible attachment of compatibility properties (like context and message) to CloudEvents.
  • Enhanced Idempotency and Memoization: The addV1Compat function ensures idempotency by marking already patched events with a Symbol, preventing re-binding of properties. It also memoizes getter results to avoid redundant computations.
  • Generic Compatibility Module: Specific Pub/Sub V1 compatibility types and logic have been removed from src/v2/compat.ts, making the module a more general-purpose tool for adding V1 compatibility to various event types.

🧠 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.

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.

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 generic addV1Compat utility to replace the provider-specific patchV1Compat function, which is a great step towards a more modular and reusable V1 compatibility layer. The implementation is clean and robust. My review includes one suggestion to enhance the test suite to more explicitly verify the memoization behavior, which is a key feature of the new utility.

@inlined inlined changed the title Destructuring API pt 1: basic tools Destructuring API pt 1: foundation & pubsub Mar 20, 2026
@inlined inlined force-pushed the inlined.destructuring.base branch from 91f7ebd to c963cae Compare March 20, 2026 00:50
@inlined
Copy link
Copy Markdown
Member Author

inlined commented Mar 20, 2026

/gemini review

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 refactors the V1 compatibility layer for CloudEvents. The patchV1Compat function has been generalized into addV1Compat, a utility that can add memoized getter properties to any object, removing provider-specific logic from compat.ts. The Pub/Sub specific V1 compatibility logic, including event data parsing and the construction of V1-compatible context and message objects, has been moved into the pubsub.ts module. Type definitions were updated to use a new generic V1Compat type, and new test cases were added to ensure backward compatibility for user functions expecting V1-compatible events.

@inlined inlined requested a review from shettyvarun268 March 20, 2026 03:22
Copy link
Copy Markdown
Contributor

@shettyvarun268 shettyvarun268 left a comment

Choose a reason for hiding this comment

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

LGTM

@inlined inlined added this pull request to the merge queue Mar 20, 2026
Merged via the queue into master with commit 01ed20c Mar 20, 2026
32 checks passed
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.

3 participants