Skip to content

Commit d9536a9

Browse files
authored
Update alerts namespace docs (#1111)
* updating docs * fixing comments
1 parent 2e97603 commit d9536a9

File tree

4 files changed

+237
-27
lines changed

4 files changed

+237
-27
lines changed

src/v2/providers/alerts/alerts.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as options from '../../options';
44

55
/**
66
* The CloudEvent data emitted by Firebase Alerts.
7+
* @typeParam T - the payload type that is expected for this alert.
78
*/
89
export interface FirebaseAlertData<T = any> {
910
/** Time that the event has created. */
@@ -16,6 +17,7 @@ export interface FirebaseAlertData<T = any> {
1617

1718
/**
1819
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
20+
* @typeParam T - the data type for this alert that is wrapped in a `FirebaseAlertData` object.
1921
*/
2022
export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
2123
/** The type of the alerts that got triggered. */
@@ -26,7 +28,7 @@ export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
2628
*/
2729
appId?: string;
2830

29-
/** Data for an AlertEvent is a FirebaseAlertData with a given payload. */
31+
/** Data for an `AlertEvent` is a `FirebaseAlertData` object with a given payload. */
3032
data: FirebaseAlertData<T>;
3133
}
3234

@@ -50,14 +52,18 @@ export type AlertType =
5052
* Configuration for Firebase Alert functions.
5153
*/
5254
export interface FirebaseAlertOptions extends options.EventHandlerOptions {
55+
/** Scope the handler to trigger on an alert type. */
5356
alertType: AlertType;
57+
/** Scope the function to trigger on a specific application. */
5458
appId?: string;
5559
}
5660

5761
/**
5862
* Declares a function that can handle Firebase Alerts from CloudEvents.
63+
* @typeParam T - The data type of the `FirebaseAlertData` object the function receives.
5964
* @param alertTypeOrOpts the alert type or Firebase Alert function configuration.
6065
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
66+
* @returns A function that you can export and deploy.
6167
*/
6268
export function onAlertPublished<T extends { ['@type']: string } = any>(
6369
alertTypeOrOpts: AlertType | FirebaseAlertOptions,
@@ -76,8 +82,8 @@ export function onAlertPublished<T extends { ['@type']: string } = any>(
7682
}
7783

7884
/**
79-
* @internal
8085
* Helper function for getting the endpoint annotation used in alert handling functions.
86+
* @internal
8187
*/
8288
export function getEndpointAnnotation(
8389
opts: options.EventHandlerOptions,
@@ -109,8 +115,8 @@ export function getEndpointAnnotation(
109115
}
110116

111117
/**
112-
* @internal
113118
* Helper function to parse the function opts, alert type, and appId.
119+
* @internal
114120
*/
115121
export function getOptsAndAlertTypeAndApp(
116122
alertTypeOrOpts: AlertType | FirebaseAlertOptions

src/v2/providers/alerts/appDistribution.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FirebaseAlertData, getEndpointAnnotation } from './alerts';
44

55
/**
66
* The internal payload object for adding a new tester device to app distribution.
7-
* Payload is wrapped inside a FirebaseAlertData object.
7+
* Payload is wrapped inside a `FirebaseAlertData` object.
88
*/
99
export interface NewTesterDevicePayload {
1010
['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroNewTesterIosDevicePayload';
@@ -20,6 +20,7 @@ export interface NewTesterDevicePayload {
2020

2121
/**
2222
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
23+
* @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object.
2324
*/
2425
export interface AppDistributionEvent<T>
2526
extends CloudEvent<FirebaseAlertData<T>> {
@@ -36,29 +37,53 @@ export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice';
3637
* Configuration for app distribution functions.
3738
*/
3839
export interface AppDistributionOptions extends options.EventHandlerOptions {
40+
/** Scope the function to trigger on a specific application. */
3941
appId?: string;
4042
}
4143

4244
/**
4345
* Declares a function that can handle adding a new tester iOS device.
46+
* @param handler - Event handler which is run every time a new tester iOS device is added.
47+
* @returns A function that you can export and deploy.
4448
*/
4549
export function onNewTesterIosDevicePublished(
4650
handler: (
4751
event: AppDistributionEvent<NewTesterDevicePayload>
4852
) => any | Promise<any>
4953
): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
54+
55+
/**
56+
* Declares a function that can handle adding a new tester iOS device.
57+
* @param appId - A specific application the handler will trigger on.
58+
* @param handler - Event handler which is run every time a new tester iOS device is added.
59+
* @returns A function that you can export and deploy.
60+
*/
5061
export function onNewTesterIosDevicePublished(
5162
appId: string,
5263
handler: (
5364
event: AppDistributionEvent<NewTesterDevicePayload>
5465
) => any | Promise<any>
5566
): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
67+
68+
/**
69+
* Declares a function that can handle adding a new tester iOS device.
70+
* @param opts - Options that can be set on the function.
71+
* @param handler - Event handler which is run every time a new tester iOS device is added.
72+
* @returns A function that you can export and deploy.
73+
*/
5674
export function onNewTesterIosDevicePublished(
5775
opts: AppDistributionOptions,
5876
handler: (
5977
event: AppDistributionEvent<NewTesterDevicePayload>
6078
) => any | Promise<any>
6179
): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
80+
81+
/**
82+
* Declares a function that can handle adding a new tester iOS device.
83+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
84+
* @param handler - Event handler which is run every time a new tester iOS device is added.
85+
* @returns A function that you can export and deploy.
86+
*/
6287
export function onNewTesterIosDevicePublished(
6388
appIdOrOptsOrHandler:
6489
| string
@@ -90,8 +115,8 @@ export function onNewTesterIosDevicePublished(
90115
}
91116

92117
/**
93-
* @internal
94118
* Helper function to parse the function opts and appId.
119+
* @internal
95120
*/
96121
export function getOptsAndApp(
97122
appIdOrOpts: string | AppDistributionOptions

src/v2/providers/alerts/billing.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as options from '../../options';
44

55
/**
66
* The internal payload object for billing plan updates.
7-
* Payload is wrapped inside a FirebaseAlertData object.
7+
* Payload is wrapped inside a `FirebaseAlertData` object.
88
*/
99
export interface PlanUpdatePayload {
1010
['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanUpdatePayload';
@@ -18,7 +18,7 @@ export interface PlanUpdatePayload {
1818

1919
/**
2020
* The internal payload object for billing plan automated updates.
21-
* Payload is wrapped inside a FirebaseAlertData object.
21+
* Payload is wrapped inside a `FirebaseAlertData` object.
2222
*/
2323
export interface PlanAutomatedUpdatePayload {
2424
['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanAutomatedUpdatePayload';
@@ -30,6 +30,7 @@ export interface PlanAutomatedUpdatePayload {
3030

3131
/**
3232
* A custom CloudEvent for billing Firebase Alerts (with custom extension attributes).
33+
* @typeParam T - the data type for billing alerts that is wrapped in a `FirebaseAlertData` object.
3334
*/
3435
export interface BillingEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
3536
/** The type of the alerts that got triggered. */
@@ -43,14 +44,30 @@ export const planAutomatedUpdateAlert = 'billing.planAutomatedUpdate';
4344

4445
/**
4546
* Declares a function that can handle a billing plan update event.
47+
* @param handler - Event handler which is run every time a billing plan is updated.
48+
* @returns A function that you can export and deploy.
4649
*/
4750
export function onPlanUpdatePublished(
4851
handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>
4952
): CloudFunction<BillingEvent<PlanUpdatePayload>>;
53+
54+
/**
55+
* Declares a function that can handle a billing plan update event.
56+
* @param opts - Options that can be set on the function.
57+
* @param handler - Event handler which is run every time a billing plan is updated.
58+
* @returns A function that you can export and deploy.
59+
*/
5060
export function onPlanUpdatePublished(
5161
opts: options.EventHandlerOptions,
5262
handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>
5363
): CloudFunction<BillingEvent<PlanUpdatePayload>>;
64+
65+
/**
66+
* Declares a function that can handle a billing plan update event.
67+
* @param optsOrHandler - Options or an event-handling function.
68+
* @param handler - Event handler which is run every time a billing plan is updated.
69+
* @returns A function that you can export and deploy.
70+
*/
5471
export function onPlanUpdatePublished(
5572
optsOrHandler:
5673
| options.EventHandlerOptions
@@ -66,18 +83,34 @@ export function onPlanUpdatePublished(
6683

6784
/**
6885
* Declares a function that can handle an automated billing plan update event.
86+
* @param handler - Event handler which is run every time an automated billing plan update occurs.
87+
* @returns A function that you can export and deploy.
6988
*/
7089
export function onPlanAutomatedUpdatePublished(
7190
handler: (
7291
event: BillingEvent<PlanAutomatedUpdatePayload>
7392
) => any | Promise<any>
7493
): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
94+
95+
/**
96+
* Declares a function that can handle an automated billing plan update event.
97+
* @param opts - Options that can be set on the function.
98+
* @param handler - Event handler which is run every time an automated billing plan update occurs.
99+
* @returns A function that you can export and deploy.
100+
*/
75101
export function onPlanAutomatedUpdatePublished(
76102
opts: options.EventHandlerOptions,
77103
handler: (
78104
event: BillingEvent<PlanAutomatedUpdatePayload>
79105
) => any | Promise<any>
80106
): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
107+
108+
/**
109+
* Declares a function that can handle an automated billing plan update event.
110+
* @param optsOrHandler - Options or an event-handling function.
111+
* @param handler - Event handler which is run every time an automated billing plan update occurs.
112+
* @returns A function that you can export and deploy.
113+
*/
81114
export function onPlanAutomatedUpdatePublished(
82115
optsOrHandler:
83116
| options.EventHandlerOptions

0 commit comments

Comments
 (0)