1 | import { ResetValue } from "../../../common/options";
|
2 | import { CloudEvent, CloudFunction } from "../../core";
|
3 | import { Expression } from "../../../params";
|
4 | import * as options from "../../options";
|
5 | import { SecretParam } from "../../../params/types";
|
6 | /**
|
7 | * The CloudEvent data emitted by Firebase Alerts.
|
8 | * @typeParam T - the payload type that is expected for this alert.
|
9 | */
|
10 | export interface FirebaseAlertData<T = any> {
|
11 | /** Time that the event has created. */
|
12 | createTime: string;
|
13 | /** Time that the event has ended. Optional, only present for ongoing alerts. */
|
14 | endTime: string;
|
15 | /** Payload of the event, which includes the details of the specific alert. */
|
16 | payload: T;
|
17 | }
|
18 | /**
|
19 | * 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.
|
21 | */
|
22 | export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
23 | /** The type of the alerts that got triggered. */
|
24 | alertType: string;
|
25 | /**
|
26 | * The Firebase App ID that’s associated with the alert. This is optional,
|
27 | * and only present when the alert is targeting at a specific Firebase App.
|
28 | */
|
29 | appId?: string;
|
30 | /** Data for an `AlertEvent` is a `FirebaseAlertData` object with a given payload. */
|
31 | data: FirebaseAlertData<T>;
|
32 | }
|
33 | /** The underlying alert type of the Firebase Alerts provider. */
|
34 | export type AlertType = "crashlytics.newFatalIssue" | "crashlytics.newNonfatalIssue" | "crashlytics.regression" | "crashlytics.stabilityDigest" | "crashlytics.velocity" | "crashlytics.newAnrIssue" | "billing.planUpdate" | "billing.planAutomatedUpdate" | "appDistribution.newTesterIosDevice" | "appDistribution.inAppFeedback" | "performance.threshold" | string;
|
35 | /**
|
36 | * Configuration for Firebase Alert functions.
|
37 | */
|
38 | export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
39 | /** Scope the handler to trigger on an alert type. */
|
40 | alertType: AlertType;
|
41 | /** Scope the function to trigger on a specific application. */
|
42 | appId?: string;
|
43 | /**
|
44 | * If true, do not deploy or emulate this function.
|
45 | */
|
46 | omit?: boolean | Expression<boolean>;
|
47 | /**
|
48 | * Region where functions should be deployed.
|
49 | */
|
50 | region?: options.SupportedRegion | string | Expression<string> | ResetValue;
|
51 | /**
|
52 | * Amount of memory to allocate to a function.
|
53 | * A value of null restores the defaults of 256MB.
|
54 | */
|
55 | memory?: options.MemoryOption | Expression<number> | ResetValue;
|
56 | /**
|
57 | * Timeout for the function in seconds, possible values are 0 to 540.
|
58 | * HTTPS functions can specify a higher timeout.
|
59 | * A value of null restores the default of 60s
|
60 | * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
61 | * function depends on the type of function: Event handling functions have a
|
62 | * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
63 | * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
64 | * timeout of 1,800s (30 minutes)
|
65 | */
|
66 | timeoutSeconds?: number | Expression<number> | ResetValue;
|
67 | /**
|
68 | * Min number of actual instances to be running at a given time.
|
69 | * Instances will be billed for memory allocation and 10% of CPU allocation
|
70 | * while idle.
|
71 | * A value of null restores the default min instances.
|
72 | */
|
73 | minInstances?: number | Expression<number> | ResetValue;
|
74 | /**
|
75 | * Max number of instances to be running in parallel.
|
76 | * A value of null restores the default max instances.
|
77 | */
|
78 | maxInstances?: number | Expression<number> | ResetValue;
|
79 | /**
|
80 | * Number of requests a function can serve at once.
|
81 | * Can only be applied to functions running on Cloud Functions v2.
|
82 | * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
83 | * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
84 | * The maximum value for concurrency is 1,000.
|
85 | */
|
86 | concurrency?: number | Expression<number> | ResetValue;
|
87 | /**
|
88 | * Fractional number of CPUs to allocate to a function.
|
89 | * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
90 | * This is different from the defaults when using the gcloud utility and is different from
|
91 | * the fixed amount assigned in Google Cloud Functions generation 1.
|
92 | * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
93 | * to the value "gcf_gen1"
|
94 | */
|
95 | cpu?: number | "gcf_gen1";
|
96 | /**
|
97 | * Connect cloud function to specified VPC connector.
|
98 | * A value of null removes the VPC connector
|
99 | */
|
100 | vpcConnector?: string | Expression<string> | ResetValue;
|
101 | /**
|
102 | * Egress settings for VPC connector.
|
103 | * A value of null turns off VPC connector egress settings
|
104 | */
|
105 | vpcConnectorEgressSettings?: options.VpcEgressSetting | ResetValue;
|
106 | /**
|
107 | * Specific service account for the function to run as.
|
108 | * A value of null restores the default service account.
|
109 | */
|
110 | serviceAccount?: string | Expression<string> | ResetValue;
|
111 | /**
|
112 | * Ingress settings which control where this function can be called from.
|
113 | * A value of null turns off ingress settings.
|
114 | */
|
115 | ingressSettings?: options.IngressSetting | ResetValue;
|
116 | /**
|
117 | * User labels to set on the function.
|
118 | */
|
119 | labels?: Record<string, string>;
|
120 | secrets?: (string | SecretParam)[];
|
121 | /** Whether failed executions should be delivered again. */
|
122 | retry?: boolean | Expression<boolean> | ResetValue;
|
123 | }
|
124 | /**
|
125 | * Declares a function that can handle Firebase Alerts from CloudEvents.
|
126 | * @typeParam T - the type of event.data.payload.
|
127 | * @param alertType - the alert type or Firebase Alert function configuration.
|
128 | * @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
129 | * @returns A function that you can export and deploy.
|
130 | */
|
131 | export declare function onAlertPublished<T extends {
|
132 | ["@type"]: string;
|
133 | } = any>(alertType: AlertType, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|
134 | /**
|
135 | * Declares a function that can handle Firebase Alerts from CloudEvents.
|
136 | * @typeParam T - the type of event.data.payload.
|
137 | * @param options - the alert type and other options for this cloud function.
|
138 | * @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
139 | */
|
140 | export declare function onAlertPublished<T extends {
|
141 | ["@type"]: string;
|
142 | } = any>(options: FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|
143 |
|
\ | No newline at end of file |