diff --git a/src/v2/providers/alerts/alerts.ts b/src/v2/providers/alerts/alerts.ts index df800fadb..4b260a851 100644 --- a/src/v2/providers/alerts/alerts.ts +++ b/src/v2/providers/alerts/alerts.ts @@ -4,6 +4,7 @@ import * as options from '../../options'; /** * The CloudEvent data emitted by Firebase Alerts. + * @typeParam T - the payload type that is expected for this alert. */ export interface FirebaseAlertData { /** Time that the event has created. */ @@ -16,6 +17,7 @@ export interface FirebaseAlertData { /** * A custom CloudEvent for Firebase Alerts (with custom extension attributes). + * @typeParam T - the data type for this alert that is wrapped in a `FirebaseAlertData` object. */ export interface AlertEvent extends CloudEvent> { /** The type of the alerts that got triggered. */ @@ -26,7 +28,7 @@ export interface AlertEvent extends CloudEvent> { */ appId?: string; - /** Data for an AlertEvent is a FirebaseAlertData with a given payload. */ + /** Data for an `AlertEvent` is a `FirebaseAlertData` object with a given payload. */ data: FirebaseAlertData; } @@ -50,14 +52,18 @@ export type AlertType = * Configuration for Firebase Alert functions. */ export interface FirebaseAlertOptions extends options.EventHandlerOptions { + /** Scope the handler to trigger on an alert type. */ alertType: AlertType; + /** Scope the function to trigger on a specific application. */ appId?: string; } /** * Declares a function that can handle Firebase Alerts from CloudEvents. + * @typeParam T - The data type of the `FirebaseAlertData` object the function receives. * @param alertTypeOrOpts the alert type or Firebase Alert function configuration. * @param handler a function that can handle the Firebase Alert inside a CloudEvent. + * @returns A function that you can export and deploy. */ export function onAlertPublished( alertTypeOrOpts: AlertType | FirebaseAlertOptions, @@ -76,8 +82,8 @@ export function onAlertPublished( } /** - * @internal * Helper function for getting the endpoint annotation used in alert handling functions. + * @internal */ export function getEndpointAnnotation( opts: options.EventHandlerOptions, @@ -109,8 +115,8 @@ export function getEndpointAnnotation( } /** - * @internal * Helper function to parse the function opts, alert type, and appId. + * @internal */ export function getOptsAndAlertTypeAndApp( alertTypeOrOpts: AlertType | FirebaseAlertOptions diff --git a/src/v2/providers/alerts/appDistribution.ts b/src/v2/providers/alerts/appDistribution.ts index e22f847c0..fc8ec18d2 100644 --- a/src/v2/providers/alerts/appDistribution.ts +++ b/src/v2/providers/alerts/appDistribution.ts @@ -4,7 +4,7 @@ import { FirebaseAlertData, getEndpointAnnotation } from './alerts'; /** * The internal payload object for adding a new tester device to app distribution. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface NewTesterDevicePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroNewTesterIosDevicePayload'; @@ -20,6 +20,7 @@ export interface NewTesterDevicePayload { /** * A custom CloudEvent for Firebase Alerts (with custom extension attributes). + * @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object. */ export interface AppDistributionEvent extends CloudEvent> { @@ -36,29 +37,53 @@ export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice'; * Configuration for app distribution functions. */ export interface AppDistributionOptions extends options.EventHandlerOptions { + /** Scope the function to trigger on a specific application. */ appId?: string; } /** * Declares a function that can handle adding a new tester iOS device. + * @param handler - Event handler which is run every time a new tester iOS device is added. + * @returns A function that you can export and deploy. */ export function onNewTesterIosDevicePublished( handler: ( event: AppDistributionEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle adding a new tester iOS device. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler which is run every time a new tester iOS device is added. + * @returns A function that you can export and deploy. + */ export function onNewTesterIosDevicePublished( appId: string, handler: ( event: AppDistributionEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle adding a new tester iOS device. + * @param opts - Options that can be set on the function. + * @param handler - Event handler which is run every time a new tester iOS device is added. + * @returns A function that you can export and deploy. + */ export function onNewTesterIosDevicePublished( opts: AppDistributionOptions, handler: ( event: AppDistributionEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle adding a new tester iOS device. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler which is run every time a new tester iOS device is added. + * @returns A function that you can export and deploy. + */ export function onNewTesterIosDevicePublished( appIdOrOptsOrHandler: | string @@ -90,8 +115,8 @@ export function onNewTesterIosDevicePublished( } /** - * @internal * Helper function to parse the function opts and appId. + * @internal */ export function getOptsAndApp( appIdOrOpts: string | AppDistributionOptions diff --git a/src/v2/providers/alerts/billing.ts b/src/v2/providers/alerts/billing.ts index 4439546a5..8990481cc 100644 --- a/src/v2/providers/alerts/billing.ts +++ b/src/v2/providers/alerts/billing.ts @@ -4,7 +4,7 @@ import * as options from '../../options'; /** * The internal payload object for billing plan updates. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface PlanUpdatePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanUpdatePayload'; @@ -18,7 +18,7 @@ export interface PlanUpdatePayload { /** * The internal payload object for billing plan automated updates. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface PlanAutomatedUpdatePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanAutomatedUpdatePayload'; @@ -30,6 +30,7 @@ export interface PlanAutomatedUpdatePayload { /** * A custom CloudEvent for billing Firebase Alerts (with custom extension attributes). + * @typeParam T - the data type for billing alerts that is wrapped in a `FirebaseAlertData` object. */ export interface BillingEvent extends CloudEvent> { /** The type of the alerts that got triggered. */ @@ -43,14 +44,30 @@ export const planAutomatedUpdateAlert = 'billing.planAutomatedUpdate'; /** * Declares a function that can handle a billing plan update event. + * @param handler - Event handler which is run every time a billing plan is updated. + * @returns A function that you can export and deploy. */ export function onPlanUpdatePublished( handler: (event: BillingEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a billing plan update event. + * @param opts - Options that can be set on the function. + * @param handler - Event handler which is run every time a billing plan is updated. + * @returns A function that you can export and deploy. + */ export function onPlanUpdatePublished( opts: options.EventHandlerOptions, handler: (event: BillingEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a billing plan update event. + * @param optsOrHandler - Options or an event-handling function. + * @param handler - Event handler which is run every time a billing plan is updated. + * @returns A function that you can export and deploy. + */ export function onPlanUpdatePublished( optsOrHandler: | options.EventHandlerOptions @@ -66,18 +83,34 @@ export function onPlanUpdatePublished( /** * Declares a function that can handle an automated billing plan update event. + * @param handler - Event handler which is run every time an automated billing plan update occurs. + * @returns A function that you can export and deploy. */ export function onPlanAutomatedUpdatePublished( handler: ( event: BillingEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle an automated billing plan update event. + * @param opts - Options that can be set on the function. + * @param handler - Event handler which is run every time an automated billing plan update occurs. + * @returns A function that you can export and deploy. + */ export function onPlanAutomatedUpdatePublished( opts: options.EventHandlerOptions, handler: ( event: BillingEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle an automated billing plan update event. + * @param optsOrHandler - Options or an event-handling function. + * @param handler - Event handler which is run every time an automated billing plan update occurs. + * @returns A function that you can export and deploy. + */ export function onPlanAutomatedUpdatePublished( optsOrHandler: | options.EventHandlerOptions diff --git a/src/v2/providers/alerts/crashlytics.ts b/src/v2/providers/alerts/crashlytics.ts index 1cbe13760..1efff4f28 100644 --- a/src/v2/providers/alerts/crashlytics.ts +++ b/src/v2/providers/alerts/crashlytics.ts @@ -2,21 +2,21 @@ import { FirebaseAlertData, getEndpointAnnotation } from '.'; import { CloudEvent, CloudFunction } from '../../core'; import * as options from '../../options'; -/** Generic crashlytics issue interface */ +/** Generic Crashlytics issue interface */ export interface Issue { - /** The ID of the crashlytics issue */ + /** The ID of the Crashlytics issue */ id: string; - /** The title of the crashlytics issue */ + /** The title of the Crashlytics issue */ title: string; - /** The subtitle of the crashlytics issue */ + /** The subtitle of the Crashlytics issue */ subtitle: string; - /** The application version of the crashlytics issue */ + /** The application version of the Crashlytics issue */ appVersion: string; } /** * The internal payload object for a new fatal issue. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface NewFatalIssuePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewFatalIssuePayload'; @@ -26,7 +26,7 @@ export interface NewFatalIssuePayload { /** * The internal payload object for a new non-fatal issue. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface NewNonfatalIssuePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewNonfatalIssuePayload'; @@ -36,7 +36,7 @@ export interface NewNonfatalIssuePayload { /** * The internal payload object for a regression alert. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface RegressionAlertPayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsRegressionAlertPayload'; @@ -51,7 +51,7 @@ export interface RegressionAlertPayload { resolveTime: string; } -/** Generic crashlytics trending issue interface */ +/** Generic Crashlytics trending issue interface */ export interface TrendingIssueDetails { /** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */ type: string; @@ -65,7 +65,7 @@ export interface TrendingIssueDetails { /** * The internal payload object for a stability digest. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface StabilityDigestPayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsStabilityDigestPayload'; @@ -80,7 +80,7 @@ export interface StabilityDigestPayload { /** * The internal payload object for a velocity alert. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface VelocityAlertPayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsVelocityAlertPayload'; @@ -107,7 +107,7 @@ export interface VelocityAlertPayload { /** * The internal payload object for a new Application Not Responding issue. - * Payload is wrapped inside a FirebaseAlertData object. + * Payload is wrapped inside a `FirebaseAlertData` object. */ export interface NewAnrIssuePayload { ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewAnrIssuePayload'; @@ -117,6 +117,7 @@ export interface NewAnrIssuePayload { /** * A custom CloudEvent for Firebase Alerts (with custom extension attributes). + * @typeParam T - the data type for Crashlytics alerts that is wrapped in a `FirebaseAlertData` object. */ export interface CrashlyticsEvent extends CloudEvent> { /** The type of the alerts that got triggered. */ @@ -139,26 +140,50 @@ export const velocityAlert = 'crashlytics.velocity'; export const newAnrIssueAlert = 'crashlytics.newAnrIssue'; /** - * Configuration for crashlytics functions. + * Configuration for Crashlytics functions. */ export interface CrashlyticsOptions extends options.EventHandlerOptions { + /** Scope the function to trigger on a specific application. */ appId?: string; } /** - * Declares a function that can handle a new fatal issue published to crashlytics. + * Declares a function that can handle a new fatal issue published to Crashlytics. + * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onNewFatalIssuePublished( handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new fatal issue published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewFatalIssuePublished( appId: string, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new fatal issue published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewFatalIssuePublished( opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new fatal issue published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewFatalIssuePublished( appIdOrOptsOrHandler: | string @@ -176,25 +201,48 @@ export function onNewFatalIssuePublished( } /** - * Declares a function that can handle aa new non-fatal issue published to crashlytics. + * Declares a function that can handle a new non-fatal issue published to Crashlytics. + * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onNewNonfatalIssuePublished( handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new non-fatal issue published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewNonfatalIssuePublished( appId: string, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new non-fatal issue published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewNonfatalIssuePublished( opts: CrashlyticsOptions, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new non-fatal issue published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewNonfatalIssuePublished( appIdOrOptsOrHandler: | string @@ -214,25 +262,50 @@ export function onNewNonfatalIssuePublished( } /** - * Declares a function that can handle a regression alert published to crashlytics. + * Declares a function that can handle a regression alert published to Crashlytics. + * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onRegressionAlertPublished( handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a regression alert published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onRegressionAlertPublished( appId: string, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a regression alert published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onRegressionAlertPublished( opts: CrashlyticsOptions, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a regression alert published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onRegressionAlertPublished( appIdOrOptsOrHandler: | string @@ -250,25 +323,50 @@ export function onRegressionAlertPublished( } /** - * Declares a function that can handle a stability digest published to crashlytics. + * Declares a function that can handle a stability digest published to Crashlytics. + * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onStabilityDigestPublished( handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a stability digest published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onStabilityDigestPublished( appId: string, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a stability digest published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onStabilityDigestPublished( opts: CrashlyticsOptions, handler: ( event: CrashlyticsEvent ) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a stability digest published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onStabilityDigestPublished( appIdOrOptsOrHandler: | string @@ -286,19 +384,42 @@ export function onStabilityDigestPublished( } /** - * Declares a function that can handle a velocity alert published to crashlytics. + * Declares a function that can handle a velocity alert published to Crashlytics. + * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onVelocityAlertPublished( handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a velocity alert published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onVelocityAlertPublished( appId: string, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a velocity alert published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onVelocityAlertPublished( opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a velocity alert published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onVelocityAlertPublished( appIdOrOptsOrHandler: | string @@ -316,19 +437,44 @@ export function onVelocityAlertPublished( } /** - * Declares a function that can handle a new Application Not Responding issue published to crashlytics. + * Declares a function that can handle a new Application Not Responding issue published to Crashlytics. + * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics. + * @returns A function that you can export and deploy. */ export function onNewAnrIssuePublished( handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new Application Not Responding issue published to Crashlytics. + * @param appId - A specific application the handler will trigger on. + * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onNewAnrIssuePublished( appId: string, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new Application Not Responding issue published to Crashlytics. + * @param opts - Options that can be set on the function. + * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics. + * @returns A function that you can export and deploy. + + */ export function onNewAnrIssuePublished( opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent) => any | Promise ): CloudFunction>; + +/** + * Declares a function that can handle a new Application Not Responding issue published to Crashlytics. + * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function. + * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics. + * @returns A function that you can export and deploy. + */ export function onNewAnrIssuePublished( appIdOrOptsOrHandler: | string @@ -374,8 +520,8 @@ export function onOperation( } /** - * @internal * Helper function to parse the function opts and appId. + * @internal */ export function getOptsAndApp( appIdOrOpts: string | CrashlyticsOptions