Skip to content

Commit be7e529

Browse files
authored
Redefine fields in options so they get better docs (#1119)
* Redefine fields in options so they get better docs * PR feedback
1 parent d9536a9 commit be7e529

File tree

11 files changed

+863
-6
lines changed

11 files changed

+863
-6
lines changed

src/common/providers/identity.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ const CLAIMS_MAX_PAYLOAD_SIZE = 1000;
5252

5353
/**
5454
* Shorthand auth blocking events from GCIP.
55-
* @internal
55+
* @hidden
56+
* @alpha
5657
*/
5758
export type AuthBlockingEventType = 'beforeCreate' | 'beforeSignIn';
5859

src/v2/options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export interface GlobalOptions {
181181
invoker?: 'public' | 'private' | string | string[];
182182

183183
/*
184-
* Secrets to bind to a functions.
184+
* Secrets to bind to a function.
185185
*/
186186
secrets?: string[];
187187
}
@@ -212,6 +212,7 @@ export function getGlobalOptions(): GlobalOptions {
212212
* Additional fields that can be set on any event-handling Cloud Function.
213213
*/
214214
export interface EventHandlerOptions extends GlobalOptions {
215+
/** Whether failed executions should be delivered again. */
215216
retry?: boolean;
216217
}
217218

src/v2/providers/alerts/alerts.ts

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,127 @@ export type AlertType =
5454
export interface FirebaseAlertOptions extends options.EventHandlerOptions {
5555
/** Scope the handler to trigger on an alert type. */
5656
alertType: AlertType;
57+
5758
/** Scope the function to trigger on a specific application. */
5859
appId?: string;
60+
61+
/**
62+
* Region where functions should be deployed.
63+
*/
64+
region?: options.SupportedRegion | string;
65+
66+
/**
67+
* Amount of memory to allocate to a function.
68+
* A value of null restores the defaults of 256MB.
69+
*/
70+
memory?: options.MemoryOption | null;
71+
72+
/**
73+
* Timeout for the function in sections, possible values are 0 to 540.
74+
* HTTPS functions can specify a higher timeout.
75+
* A value of null restores the default of 60s
76+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
77+
* function depends on the type of function: Event handling functions have a
78+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
79+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
80+
* timeout of 1,800s (30 minutes)
81+
*/
82+
timeoutSeconds?: number | null;
83+
84+
/**
85+
* Min number of actual instances to be running at a given time.
86+
* Instances will be billed for memory allocation and 10% of CPU allocation
87+
* while idle.
88+
* A value of null restores the default min instances.
89+
*/
90+
minInstances?: number | null;
91+
92+
/**
93+
* Max number of instances to be running in parallel.
94+
* A value of null restores the default max instances.
95+
*/
96+
maxInstances?: number | null;
97+
98+
/**
99+
* Number of requests a function can serve at once.
100+
* Can only be applied to functions running on Cloud Functions v2.
101+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
102+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
103+
* The maximum value for concurrency is 1,000.
104+
*/
105+
concurrency?: number | null;
106+
107+
/**
108+
* Fractional number of CPUs to allocate to a function.
109+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
110+
* This is different from the defaults when using the gcloud utility and is different from
111+
* the fixed amount assigned in Google Cloud Functions generation 1.
112+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
113+
* to the value "gcf_gen1"
114+
*/
115+
cpu?: number | 'gcf_gen1';
116+
117+
/**
118+
* Connect cloud function to specified VPC connector.
119+
* A value of null removes the VPC connector
120+
*/
121+
vpcConnector?: string | null;
122+
123+
/**
124+
* Egress settings for VPC connector.
125+
* A value of null turns off VPC connector egress settings
126+
*/
127+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
128+
129+
/**
130+
* Specific service account for the function to run as.
131+
* A value of null restores the default service account.
132+
*/
133+
serviceAccount?: string | null;
134+
135+
/**
136+
* Ingress settings which control where this function can be called from.
137+
* A value of null turns off ingress settings.
138+
*/
139+
ingressSettings?: options.IngressSetting | null;
140+
141+
/**
142+
* User labels to set on the function.
143+
*/
144+
labels?: Record<string, string>;
145+
146+
/*
147+
* Secrets to bind to a function.
148+
*/
149+
secrets?: string[];
150+
151+
/** Whether failed executions should be delivered again. */
152+
retry?: boolean;
59153
}
60154

61155
/**
62156
* Declares a function that can handle Firebase Alerts from CloudEvents.
63-
* @typeParam T - The data type of the `FirebaseAlertData` object the function receives.
64-
* @param alertTypeOrOpts the alert type or Firebase Alert function configuration.
157+
* @typeParam T - the type of event.data.payload.
158+
* @param alertType - the alert type or Firebase Alert function configuration.
65159
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
66160
* @returns A function that you can export and deploy.
67161
*/
162+
export function onAlertPublished<T extends { ['@type']: string } = any>(
163+
alertType: AlertType,
164+
handler: (event: AlertEvent<T>) => any | Promise<any>
165+
): CloudFunction<AlertEvent<T>>;
166+
167+
/**
168+
* Declares a function that can handle Firebase Alerts from CloudEvents.
169+
* @typeParam T - the type of event.data.payload.
170+
* @param options - the alert type and other options for this cloud function.
171+
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
172+
*/
173+
export function onAlertPublished<T extends { ['@type']: string } = any>(
174+
options: FirebaseAlertOptions,
175+
handler: (event: AlertEvent<T>) => any | Promise<any>
176+
): CloudFunction<AlertEvent<T>>;
177+
68178
export function onAlertPublished<T extends { ['@type']: string } = any>(
69179
alertTypeOrOpts: AlertType | FirebaseAlertOptions,
70180
handler: (event: AlertEvent<T>) => any | Promise<any>

src/v2/providers/alerts/appDistribution.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,99 @@ export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice';
3939
export interface AppDistributionOptions extends options.EventHandlerOptions {
4040
/** Scope the function to trigger on a specific application. */
4141
appId?: string;
42+
43+
/**
44+
* Region where functions should be deployed.
45+
*/
46+
region?: options.SupportedRegion | string;
47+
48+
/**
49+
* Amount of memory to allocate to a function.
50+
* A value of null restores the defaults of 256MB.
51+
*/
52+
memory?: options.MemoryOption | null;
53+
54+
/**
55+
* Timeout for the function in sections, possible values are 0 to 540.
56+
* HTTPS functions can specify a higher timeout.
57+
* A value of null restores the default of 60s
58+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
59+
* function depends on the type of function: Event handling functions have a
60+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
61+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
62+
* timeout of 1,800s (30 minutes)
63+
*/
64+
timeoutSeconds?: number | null;
65+
66+
/**
67+
* Min number of actual instances to be running at a given time.
68+
* Instances will be billed for memory allocation and 10% of CPU allocation
69+
* while idle.
70+
* A value of null restores the default min instances.
71+
*/
72+
minInstances?: number | null;
73+
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 | null;
79+
80+
/**
81+
* Number of requests a function can serve at once.
82+
* Can only be applied to functions running on Cloud Functions v2.
83+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
84+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
85+
* The maximum value for concurrency is 1,000.
86+
*/
87+
concurrency?: number | null;
88+
89+
/**
90+
* Fractional number of CPUs to allocate to a function.
91+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
92+
* This is different from the defaults when using the gcloud utility and is different from
93+
* the fixed amount assigned in Google Cloud Functions generation 1.
94+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
95+
* to the value "gcf_gen1"
96+
*/
97+
cpu?: number | 'gcf_gen1';
98+
99+
/**
100+
* Connect cloud function to specified VPC connector.
101+
* A value of null removes the VPC connector
102+
*/
103+
vpcConnector?: string | null;
104+
105+
/**
106+
* Egress settings for VPC connector.
107+
* A value of null turns off VPC connector egress settings
108+
*/
109+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
110+
111+
/**
112+
* Specific service account for the function to run as.
113+
* A value of null restores the default service account.
114+
*/
115+
serviceAccount?: string | null;
116+
117+
/**
118+
* Ingress settings which control where this function can be called from.
119+
* A value of null turns off ingress settings.
120+
*/
121+
ingressSettings?: options.IngressSetting | null;
122+
123+
/**
124+
* User labels to set on the function.
125+
*/
126+
labels?: Record<string, string>;
127+
128+
/*
129+
* Secrets to bind to a function.
130+
*/
131+
secrets?: string[];
132+
133+
/** Whether failed executions should be delivered again. */
134+
retry?: boolean;
42135
}
43136

44137
/**

src/v2/providers/alerts/crashlytics.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,99 @@ export const newAnrIssueAlert = 'crashlytics.newAnrIssue';
145145
export interface CrashlyticsOptions extends options.EventHandlerOptions {
146146
/** Scope the function to trigger on a specific application. */
147147
appId?: string;
148+
149+
/**
150+
* Region where functions should be deployed.
151+
*/
152+
region?: options.SupportedRegion | string;
153+
154+
/**
155+
* Amount of memory to allocate to a function.
156+
* A value of null restores the defaults of 256MB.
157+
*/
158+
memory?: options.MemoryOption | null;
159+
160+
/**
161+
* Timeout for the function in sections, possible values are 0 to 540.
162+
* HTTPS functions can specify a higher timeout.
163+
* A value of null restores the default of 60s
164+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
165+
* function depends on the type of function: Event handling functions have a
166+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
167+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
168+
* timeout of 1,800s (30 minutes)
169+
*/
170+
timeoutSeconds?: number | null;
171+
172+
/**
173+
* Min number of actual instances to be running at a given time.
174+
* Instances will be billed for memory allocation and 10% of CPU allocation
175+
* while idle.
176+
* A value of null restores the default min instances.
177+
*/
178+
minInstances?: number | null;
179+
180+
/**
181+
* Max number of instances to be running in parallel.
182+
* A value of null restores the default max instances.
183+
*/
184+
maxInstances?: number | null;
185+
186+
/**
187+
* Number of requests a function can serve at once.
188+
* Can only be applied to functions running on Cloud Functions v2.
189+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
190+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
191+
* The maximum value for concurrency is 1,000.
192+
*/
193+
concurrency?: number | null;
194+
195+
/**
196+
* Fractional number of CPUs to allocate to a function.
197+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
198+
* This is different from the defaults when using the gcloud utility and is different from
199+
* the fixed amount assigned in Google Cloud Functions generation 1.
200+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
201+
* to the value "gcf_gen1"
202+
*/
203+
cpu?: number | 'gcf_gen1';
204+
205+
/**
206+
* Connect cloud function to specified VPC connector.
207+
* A value of null removes the VPC connector
208+
*/
209+
vpcConnector?: string | null;
210+
211+
/**
212+
* Egress settings for VPC connector.
213+
* A value of null turns off VPC connector egress settings
214+
*/
215+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
216+
217+
/**
218+
* Specific service account for the function to run as.
219+
* A value of null restores the default service account.
220+
*/
221+
serviceAccount?: string | null;
222+
223+
/**
224+
* Ingress settings which control where this function can be called from.
225+
* A value of null turns off ingress settings.
226+
*/
227+
ingressSettings?: options.IngressSetting | null;
228+
229+
/**
230+
* User labels to set on the function.
231+
*/
232+
labels?: Record<string, string>;
233+
234+
/*
235+
* Secrets to bind to a function.
236+
*/
237+
secrets?: string[];
238+
239+
/** Whether failed executions should be delivered again. */
240+
retry?: boolean;
148241
}
149242

150243
/**

0 commit comments

Comments
 (0)