Conversation
* Add destructuring support for tasks * Add destructuring support for tasks
* Add destructuring support for firestore * Add destructuring support for pubsub * Lint * Initial pass for new webhook (#1836) * Checkpoint. Need to ensure tests use real express and want to support Any decoding * Ready for review * Resore depency files * PR feedback * Rewriting error preambles * test memoization * Remove unnecessary casts or anys * Format * checkpoint * Fix typing
* Add destructuring support for storage * better typing and formatting
* Add destructuring support for scheduler * PR feedback * Format
* Add destructuring support for remoteConfig * Format
* Add destructuring support for database * DRY * Remove unnecessary anys * Format
Summary of ChangesHello, 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 significantly enhances the V1 compatibility layer within the v2 SDK by introducing a flexible and generic Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the V1 compatibility patching mechanism by introducing a generic addV1Compat utility function that attaches V1-compatible properties (like context, message, snapshot, change, object, version) to V2 CloudEvent objects using lazy-evaluated, memoized getters. This new function replaces the previous patchV1Compat and is applied across various event providers including Pub/Sub, Realtime Database, Firestore, Remote Config, Storage, and Tasks, along with corresponding test updates. Review comments suggest improving error handling in Pub/Sub by using more specific error types and including event IDs, extracting duplicated context creation logic in Firestore into a shared function, clarifying the complex return type of addV1Compat with a comment, and consistently using addV1Compat for context properties in the Scheduler and Tasks providers to prevent serialization issues.
| ): TaskQueueFunction<Args>; | ||
| export function onTaskDispatched<Args = any>( | ||
| optsOrHandler: TaskQueueOptions | ((request: Request<Args>) => void | Promise<void>), | ||
| handler?: (request: Request<Args>) => void | Promise<void> | ||
| optsOrHandler: TaskQueueOptions | ((request: any) => void | Promise<void>), |
There was a problem hiding this comment.
Adding the context property directly to the arg object might cause unexpected behavior if the user tries to serialize the object. It's better to use Object.defineProperty to define a getter for the context property, which will prevent it from being serialized.
Object.defineProperty(arg, "context", {
get: () => context,
});| export function addV1Compat<T extends CloudEvent<unknown>, U extends Record<string, () => any>>( | ||
| event: T, | ||
| getters: U | ||
| ): T & { [K in keyof U]: ReturnType<U[K]> } { |
There was a problem hiding this comment.
The return type T & { [K in keyof U]: ReturnType<U[K]> } is quite complex. Consider adding a comment to explain what this type represents, as it's not immediately obvious.
):
T & { [K in keyof U]: ReturnType<U[K]> } /* Returns a new type by merging the properties of T and the return types of all getters in U */ {| Object.defineProperty(event, "context", { | ||
| get: () => v1Context, | ||
| }); |
Accidentally forgot to set the base of the merge back to master after the inital PR