Skip to content

Specific interface for provider enhancement (2/3) #1022

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

Merged
merged 12 commits into from
Jan 27, 2022

Conversation

colerogers
Copy link
Contributor

@colerogers colerogers commented Jan 19, 2022

Change for the the specific billing interface. Exposes onPlanUpdatePublished & onAutomatedPlanUpdatePublished from the v2/alerts/billing namespace

Ex ~

import {
  onPlanUpdatePublished,
  onAutomatedPlanUpdatePublished
} from "firebase-functions/v2/alerts/billing";

// planUpdatePublished interface
export const func1 = onPlanUpdatePublished((event) => { … });
export const func2 = onPlanUpdatePublished({ region: "us-west1" }, (event) => { … });
// robotPlanUpdatePublished interface
export const func3 = onAutomatedPlanUpdatePublished((event) => { … });
export const func5 = onAutomatedPlanUpdatePublished({ region: "us-west1" }, (event) => { … });

@colerogers colerogers requested review from taeold and inlined January 19, 2022 23:06
handler: (event: BillingEvent<T>) => any | Promise<any>
): CloudFunction<FirebaseAlertData<T>> {
if (typeof optsOrHandler === 'function') {
handler = optsOrHandler as (event: BillingEvent<T>) => any | Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Woo (event: BillingEvent<T>) => any | Promise<any>; is used thrice! This meets the threshold for DRY for me:

type BillingEventHandler<T> = (event: BillingEvent<T>) => any | Promise<any>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that looks way better, thanks for the suggestion!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taeold Removed based on typing feedback below

@colerogers colerogers requested a review from taeold January 25, 2022 02:58
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.

🔥 Great stuff.

export const automatedPlanUpdateAlert = 'billing.automatedPlanUpdate';

/** @internal */
type BillingEventHandler<T> = (event: BillingEvent<T>) => any | Promise<any>;
Copy link
Member

Choose a reason for hiding this comment

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

This typedef makes code complete worse (it asks for a BillingEventHandler instead of a function signature)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh shoot, we should probably change it back for better usability then, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wanted to test out the automcomplete and see what shows, but I couldn't get to any of the billing handlers at all.

@colerogers Can you double check if this is working for you?

  1. npm run build:pack
  2. Install the generated tgz locally on your function
  3. Try to get import to work.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, I couldn't even get lib/v2/providers/billing.js to show up. what gives?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taeold I was able to get it to work, just pushed an update. Seems like we can't rely on the package.json export path alone, we need to also export from the root index.ts. I think there was a comment about exporting on one of the other PRs and I ended up changing it on all of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@inlined Removed BillingEventHandler type from the latest commit

@colerogers colerogers merged commit b51ec90 into colerogers.alerts Jan 27, 2022
@colerogers colerogers deleted the colerogers.billing branch January 27, 2022 23:04
colerogers added a commit that referenced this pull request Jan 28, 2022
* breaking out general interface

* cleaning up exports

* removing comments & references to specific interfaces

* format

* jsdoc comments

* address pr comments

* added param comment

* addressing comments

* Specific interface for provider enhancement (1/3) (#1021)

* adding in app distro changes

* removing comments & addings package refs

* jsdoc comments

* fix comments

* adding periods to doc strings

* fix wording

* adding import/export statement

* Specific interface for provider enhancement (2/3) (#1022)

* adding in billing changes

* removing comments & adding package refs

* jsdoc comments

* addressing pr comments

* change handler doc string

* changing to BillingEventHandler type

* remove BillingEventHandler type

* Specific interface for provider enhancement (3/3) (#1023)

* adding in crashlytics changes

* comments & adding package refs

* address comments and make doc strings better

* add opts.retry to event trigger
colerogers added a commit that referenced this pull request Jan 31, 2022
* breaking out general interface

* cleaning up exports

* removing comments & references to specific interfaces

* format

* jsdoc comments

* address pr comments

* added param comment

* addressing comments

* Specific interface for provider enhancement (1/3) (#1021)

* adding in app distro changes

* removing comments & addings package refs

* jsdoc comments

* fix comments

* adding periods to doc strings

* fix wording

* adding import/export statement

* Specific interface for provider enhancement (2/3) (#1022)

* adding in billing changes

* removing comments & adding package refs

* jsdoc comments

* addressing pr comments

* change handler doc string

* changing to BillingEventHandler type

* remove BillingEventHandler type

* Specific interface for provider enhancement (3/3) (#1023)

* adding in crashlytics changes

* comments & adding package refs

* address comments and make doc strings better

* add opts.retry to event trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants