Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Params as inputs in eventTrigger #168

Merged
merged 4 commits into from
Sep 8, 2022
Merged

Conversation

TheIronDev
Copy link
Contributor

The api of the manifest changed in firebase-functions@3.23. Some inputs have been updated to be T | Expression<T>.

Description

The api of the manifest changed in firebase-functions@3.23. Some inputs have been updated to be T | Expression<T>.

Code sample

  • Updated an RTDB test to include StringParam

The api of the manifest changed in firebase-functions@3.23. Some inputs
have been updated to be `T | Expression<T>`.
Copy link
Contributor

@taeold taeold left a comment

Choose a reason for hiding this comment

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

Curious to hear from @Berlioz

@@ -47,7 +47,7 @@
"@types/mocha": "^5.2.7",
"chai": "^4.2.0",
"firebase-admin": "^10.1.0",
"firebase-functions": "^3.22.0",
"firebase-functions": "^3.23.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update the peer-depdency? It looks like our package won't work unless you are using firebase-functions 3.23 or above now since we explicitly try to import the Expression type in v2/params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're extremely right!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That probably means we need to do a minor or major bump then... WDYT?

@@ -1,4 +1,5 @@
import { CloudEvent, CloudFunction } from 'firebase-functions/v2';
import { Expression } from 'firebase-functions/v2/params';
Copy link
Contributor

@taeold taeold Sep 6, 2022

Choose a reason for hiding this comment

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

Aside - we are planning to change the import path of Expression from v2/params to just /params.

I wonder if there are more "elegant' way to import the type to avoid having this problem 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When is the change going to occur? 🙃

Copy link
Contributor

Choose a reason for hiding this comment

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

v4 sdk!

if (typeof stringOrExpression === 'string') {
return stringOrExpression;
}
return stringOrExpression?.value();
Copy link
Contributor

@taeold taeold Sep 6, 2022

Choose a reason for hiding this comment

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

Probably double check with @Berlioz - but I thought it is very possible that this to return empty string.

I'm wondering if we should think more about supporting Params firebase-functions.

Params are a way to specify "value of this is going to be determined at deploy time" - so it is probably going to be undefined at test time unless there is some special override mechanism.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem I was working against was eventTrigger.eventFilters and eventTrigger.eventFilterPathPatterns were converted to type Record<string, string | Expression<string>> :|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests show a scenario where its populated at runtime too

@TheIronDev TheIronDev merged commit 6e31411 into master Sep 8, 2022
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.

None yet

3 participants