Skip to content

Conversation

@lisajian
Copy link

@lisajian lisajian commented Aug 28, 2025

Description

Adds basic FDC function trigger for onMutationExecuted

Includes unit tests. Also fixes a typo on an existing file

npm test passes locally

Internal tracking bug: b/436623435

Code sample

Examples of how to use this

import { onMutationExecuted } from "firebase-functions/v2/dataconnect";

exports.myfunction = onMutationExecuted(
  {
    service: "service-id",
    connector: "connector-id",
    operation: "mutation-name",
  },
  (event) => { 
    // event.params.service == "service-id" 
    // event.params.connector == "connector-id"
    // event.params.operation == "mutation-name"

    // event.data contains [MutationEventData](https://docs.google.com/document/d/1sCYuBzjhirVTy9Xo2gflGVcKcZyhau9MhkVlbOvC4MI/edit?tab=t.0#bookmark=id.1k7sz3vu87vx)  
  }
);

// Use capture group on operation
exports.myfunctionwithcaptures = onMutationExecuted(
  {
    service: "service-id",
    connector: "connector-id",
    operation: "{operation}",
  },
  (event) => { /** do something */ }
);

// Use wildcard on connector
exports.myfunctionwithwildcards = onMutationExecuted(
  {
    service: "service-id",
    connector: "*",
    operation: "mutation-name",
  },
  (event) => { /** do something */ }
);

See go/fdc-eventarc-functions-sdk for more information

@lisajian lisajian requested a review from taeold August 28, 2025 18:42
@lisajian lisajian marked this pull request as ready for review August 28, 2025 18:42
@lisajian lisajian force-pushed the lj/fdc-support-pt1 branch from 13cbf42 to 52a95a3 Compare October 5, 2025 22:54
@taeold
Copy link
Contributor

taeold commented Oct 7, 2025

/gemini review

Copy link
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 support for Firebase Data Connect v2 with the onMutationExecuted trigger. The changes are well-structured, including the new provider, unit tests, and necessary package configuration updates. I've identified a few type safety issues in the new provider implementation concerning the handling of optional parameters, which could lead to runtime errors. I've provided suggestions to address these. Additionally, I've included a recommendation for a minor refactoring to enhance code clarity.

@lisajian lisajian changed the base branch from lj/fdc-support to next October 21, 2025 17:21
@@ -0,0 +1,447 @@
// The MIT License (MIT)
//
// Copyright (c) 2023 Firebase
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright (c) 2023 Firebase
// Copyright (c) 2025 Firebase

Comment on lines +262 to +264
service.hasWildcards()
? (eventFilterPathPatterns.service = service.getValue())
: (eventFilters.service = service.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit* find this ternary operator a bit odd. I usually expect ternarary operator to return a value. For assignments, I might jus stick to classic if-statements

Operation extends string = string
> extends EventHandlerOptions {
/** Firebase Data Connect service ID */
service?: Service;
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm a bit surprised that all these options are optional 🤔 should the all be required? what does not providing one mean? is it interpreted as wildcard or something else

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.

4 participants