Skip to content

Commit 21552ea

Browse files
committed
Deprecate null as configuration value in TS.
1 parent 1ccb55f commit 21552ea

File tree

12 files changed

+213
-205
lines changed

12 files changed

+213
-205
lines changed

src/common/providers/tasks.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,39 @@ import { DecodedIdToken } from "firebase-admin/auth";
2626
import * as logger from "../../logger";
2727
import * as https from "./https";
2828
import { Expression } from "../../params";
29+
import { ResetValue } from "../options";
2930

3031
/** How a task should be retried in the event of a non-2xx return. */
3132
export interface RetryConfig {
3233
/**
3334
* Maximum number of times a request should be attempted.
3435
* If left unspecified, will default to 3.
3536
*/
36-
maxAttempts?: number | Expression<number> | null;
37+
maxAttempts?: number | Expression<number> | ResetValue;
3738

3839
/**
3940
* Maximum amount of time for retrying failed task.
4041
* If left unspecified will retry indefinitely.
4142
*/
42-
maxRetrySeconds?: number | Expression<number> | null;
43+
maxRetrySeconds?: number | Expression<number> | ResetValue;
4344

4445
/**
4546
* The maximum amount of time to wait between attempts.
4647
* If left unspecified will default to 1hr.
4748
*/
48-
maxBackoffSeconds?: number | Expression<number> | null;
49+
maxBackoffSeconds?: number | Expression<number> | ResetValue;
4950

5051
/**
5152
* The maximum number of times to double the backoff between
5253
* retries. If left unspecified will default to 16.
5354
*/
54-
maxDoublings?: number | Expression<number> | null;
55+
maxDoublings?: number | Expression<number> | ResetValue;
5556

5657
/**
5758
* The minimum time to wait between attempts. If left unspecified
5859
* will default to 100ms.
5960
*/
60-
minBackoffSeconds?: number | Expression<number> | null;
61+
minBackoffSeconds?: number | Expression<number> | ResetValue;
6162
}
6263

6364
/** How congestion control should be applied to the function. */
@@ -66,13 +67,13 @@ export interface RateLimits {
6667
* The maximum number of requests that can be outstanding at a time.
6768
* If left unspecified, will default to 1000.
6869
*/
69-
maxConcurrentDispatches?: number | Expression<number> | null;
70+
maxConcurrentDispatches?: number | Expression<number> | ResetValue;
7071

7172
/**
7273
* The maximum number of requests that can be invoked per second.
7374
* If left unspecified, will default to 500.
7475
*/
75-
maxDispatchesPerSecond?: number | Expression<number> | null;
76+
maxDispatchesPerSecond?: number | Expression<number> | ResetValue;
7677
}
7778

7879
/** Metadata about the authorization used to invoke a function. */

src/v1/function-configuration.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,33 +82,33 @@ export interface ScheduleRetryConfig {
8282
*
8383
* @defaultValue 0 (infinite retry)
8484
*/
85-
retryCount?: number | Expression<number> | ResetValue | null;
85+
retryCount?: number | Expression<number> | ResetValue;
8686
/**
8787
* The time limit for retrying a failed job, measured from time when an execution was first attempted.
8888
*
8989
* If specified with {@link ScheduleRetryConfig.retryCount}, the job will be retried until both limits are reached.
9090
*
9191
* @defaultValue 0
9292
*/
93-
maxRetryDuration?: string | Expression<string> | ResetValue | null;
93+
maxRetryDuration?: string | Expression<string> | ResetValue;
9494
/**
9595
* The minimum amount of time to wait before retrying a job after it fails.
9696
*
9797
* @defaultValue 5 seconds
9898
*/
99-
minBackoffDuration?: string | Expression<string> | ResetValue | null;
99+
minBackoffDuration?: string | Expression<string> | ResetValue;
100100
/**
101101
* The maximum amount of time to wait before retrying a job after it fails.
102102
*
103103
* @defaultValue 1 hour
104104
*/
105-
maxBackoffDuration?: string | Expression<string> | ResetValue | null;
105+
maxBackoffDuration?: string | Expression<string> | ResetValue;
106106
/**
107107
* The max number of backoff doubling applied at each retry.
108108
*
109109
* @defaultValue 5
110110
*/
111-
maxDoublings?: number | Expression<number> | ResetValue | null;
111+
maxDoublings?: number | Expression<number> | ResetValue;
112112
}
113113

114114
/**
@@ -139,11 +139,11 @@ export interface Schedule {
139139
*
140140
* The value of this field must be a time zone name from the tz database.
141141
*/
142-
timeZone?: string | ResetValue | null;
142+
timeZone?: string | ResetValue;
143143
/**
144144
* Settings that determine the retry behavior.
145145
*/
146-
retryConfig?: ScheduleRetryConfig | ResetValue | null;
146+
retryConfig?: ScheduleRetryConfig | ResetValue;
147147
}
148148

149149
/**
@@ -173,32 +173,34 @@ export interface RuntimeOptions {
173173
* Failure policy of the function, with boolean `true` being equivalent to
174174
* providing an empty retry object.
175175
*/
176-
failurePolicy?: FailurePolicy | boolean | ResetValue | null;
176+
failurePolicy?: FailurePolicy | boolean | ResetValue;
177177
/**
178178
* Amount of memory to allocate to the function.
179179
*/
180-
memory?: typeof VALID_MEMORY_OPTIONS[number] | ResetValue | null;
180+
memory?: typeof VALID_MEMORY_OPTIONS[number] | ResetValue;
181181
/**
182182
* Timeout for the function in seconds, possible values are 0 to 540.
183183
*/
184-
timeoutSeconds?: number | ResetValue | null;
184+
timeoutSeconds?: number | ResetValue;
185185

186186
/**
187187
* Min number of actual instances to be running at a given time.
188+
*
189+
* @remarks
188190
* Instances will be billed for memory allocation and 10% of CPU allocation
189191
* while idle.
190192
*/
191-
minInstances?: number | ResetValue | null;
193+
minInstances?: number | ResetValue;
192194

193195
/**
194196
* Max number of actual instances allowed to be running in parallel.
195197
*/
196-
maxInstances?: number | ResetValue | null;
198+
maxInstances?: number | ResetValue;
197199

198200
/**
199201
* Connect cloud function to specified VPC connector.
200202
*/
201-
vpcConnector?: string | ResetValue | null;
203+
vpcConnector?: string | ResetValue;
202204

203205
/**
204206
* Egress settings for VPC connector.
@@ -208,7 +210,7 @@ export interface RuntimeOptions {
208210
/**
209211
* Specific service account for the function to run as.
210212
*/
211-
serviceAccount?: "default" | string | ResetValue | null;
213+
serviceAccount?: "default" | string | ResetValue;
212214

213215
/**
214216
* Ingress settings which control where this function can be called from.
@@ -232,6 +234,8 @@ export interface RuntimeOptions {
232234

233235
/**
234236
* Determines whether Firebase AppCheck is enforced.
237+
*
238+
* @remarks
235239
* When true, requests with invalid tokens autorespond with a 401
236240
* (Unauthorized) error.
237241
* When false, requests with invalid tokens set context.app to undefiend.

src/v2/options.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,53 +90,56 @@ export type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERN
9090
export interface GlobalOptions {
9191
/**
9292
* Region where functions should be deployed.
93-
* HTTP functions can override and specify more than one region.
9493
*/
9594
region?: SupportedRegion | string;
9695

9796
/**
9897
* Amount of memory to allocate to a function.
99-
* A value of null restores the defaults of 256MB.
10098
*/
101-
memory?: MemoryOption | Expression<number> | ResetValue | null;
99+
memory?: MemoryOption | Expression<number> | ResetValue;
102100

103101
/**
104102
* Timeout for the function in sections, possible values are 0 to 540.
105103
* HTTPS functions can specify a higher timeout.
106-
* A value of null restores the default of 60s
104+
*
105+
* @remarks
107106
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
108107
* function depends on the type of function: Event handling functions have a
109108
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
110109
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
111110
* timeout of 1,800s (30 minutes)
112111
*/
113-
timeoutSeconds?: number | Expression<number> | ResetValue | null;
112+
timeoutSeconds?: number | Expression<number> | ResetValue;
114113

115114
/**
116115
* Min number of actual instances to be running at a given time.
116+
*
117+
* @remarks
117118
* Instances will be billed for memory allocation and 10% of CPU allocation
118119
* while idle.
119-
* A value of null restores the default min instances.
120120
*/
121-
minInstances?: number | Expression<number> | ResetValue | null;
121+
minInstances?: number | Expression<number> | ResetValue;
122122

123123
/**
124124
* Max number of instances to be running in parallel.
125-
* A value of null restores the default max instances.
126125
*/
127-
maxInstances?: number | Expression<number> | ResetValue | null;
126+
maxInstances?: number | Expression<number> | ResetValue;
128127

129128
/**
130129
* Number of requests a function can serve at once.
130+
*
131+
* @remarks
131132
* Can only be applied to functions running on Cloud Functions v2.
132133
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
133134
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
134135
* The maximum value for concurrency is 1,000.
135136
*/
136-
concurrency?: number | Expression<number> | ResetValue | null;
137+
concurrency?: number | Expression<number> | ResetValue;
137138

138139
/**
139140
* Fractional number of CPUs to allocate to a function.
141+
*
142+
* @remarks
140143
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
141144
* This is different from the defaults when using the gcloud utility and is different from
142145
* the fixed amount assigned in Google Cloud Functions generation 1.
@@ -147,43 +150,37 @@ export interface GlobalOptions {
147150

148151
/**
149152
* Connect cloud function to specified VPC connector.
150-
* A value of null removes the VPC connector
151153
*/
152-
vpcConnector?: string | ResetValue | null;
154+
vpcConnector?: string | ResetValue;
153155

154156
/**
155157
* Egress settings for VPC connector.
156-
* A value of null turns off VPC connector egress settings
157158
*/
158-
vpcConnectorEgressSettings?: VpcEgressSetting | ResetValue | null;
159+
vpcConnectorEgressSettings?: VpcEgressSetting | ResetValue;
159160

160161
/**
161162
* Specific service account for the function to run as.
162-
* A value of null restores the default service account.
163163
*/
164-
serviceAccount?: string | ResetValue | null;
164+
serviceAccount?: string | ResetValue;
165165

166166
/**
167167
* Ingress settings which control where this function can be called from.
168-
* A value of null turns off ingress settings.
169168
*/
170-
ingressSettings?: IngressSetting | ResetValue | null;
169+
ingressSettings?: IngressSetting | ResetValue;
171170

172171
/**
173172
* User labels to set on the function.
174173
*/
175174
labels?: Record<string, string>;
176175

177-
/**
178-
* Invoker to set access control on https functions.
179-
*/
180-
invoker?: "public" | "private" | string | string[];
181-
182176
/*
183177
* Secrets to bind to a function.
184178
*/
185179
secrets?: string[];
186180

181+
/** Whether failed executions should be delivered again. */
182+
retry?: boolean | Expression<boolean> | ResetValue;
183+
187184
/**
188185
* Determines whether Firebase AppCheck is enforced.
189186
* When true, requests with invalid tokens autorespond with a 401
@@ -225,14 +222,14 @@ export interface EventHandlerOptions extends Omit<GlobalOptions, "enforceAppChec
225222
eventFilterPathPatterns?: Record<string, string | Expression<string>>;
226223

227224
/** Whether failed executions should be delivered again. */
228-
retry?: boolean | Expression<boolean> | ResetValue | null;
225+
retry?: boolean | Expression<boolean> | ResetValue;
229226

230227
/** Region of the EventArc trigger. */
231228
// region?: string | Expression<string> | null;
232229
region?: string;
233230

234231
/** The service account that EventArc should use to invoke this function. Requires the P4SA to have ActAs permission on this service account. */
235-
serviceAccount?: string | ResetValue | null;
232+
serviceAccount?: string | ResetValue;
236233

237234
/** The name of the channel where the function receives events. */
238235
channel?: string;

0 commit comments

Comments
 (0)