Skip to content

Commit 5a94583

Browse files
authoredFeb 8, 2024··
Revisions to doc comments related to env. config. (#1520)
1 parent 26cd955 commit 5a94583

File tree

2 files changed

+61
-57
lines changed

2 files changed

+61
-57
lines changed
 

‎src/params/index.ts

+29-29
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type SecretOrExpr = Param<any> | SecretParam;
5454
export const declaredParams: SecretOrExpr[] = [];
5555

5656
/**
57-
* Use a helper to manage the list such that params are uniquely
57+
* Use a helper to manage the list such that parameters are uniquely
5858
* registered once only but order is preserved.
5959
* @internal
6060
*/
@@ -76,31 +76,31 @@ export function clearParams() {
7676
}
7777

7878
/**
79-
* A builtin param that resolves to the default RTDB database URL associated
79+
* A built-in parameter that resolves to the default RTDB database URL associated
8080
* with the project, without prompting the deployer. Empty string if none exists.
8181
*/
8282
export const databaseURL: Param<string> = new InternalExpression(
8383
"DATABASE_URL",
8484
(env: NodeJS.ProcessEnv) => JSON.parse(env.FIREBASE_CONFIG)?.databaseURL || ""
8585
);
8686
/**
87-
* A builtin param that resolves to the Cloud project ID associated with
87+
* A built-in parameter that resolves to the Cloud project ID associated with
8888
* the project, without prompting the deployer.
8989
*/
9090
export const projectID: Param<string> = new InternalExpression(
9191
"PROJECT_ID",
9292
(env: NodeJS.ProcessEnv) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || ""
9393
);
9494
/**
95-
* A builtin param that resolves to the Cloud project ID, without prompting
95+
* A built-in parameter that resolves to the Cloud project ID, without prompting
9696
* the deployer.
9797
*/
9898
export const gcloudProject: Param<string> = new InternalExpression(
9999
"GCLOUD_PROJECT",
100100
(env: NodeJS.ProcessEnv) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || ""
101101
);
102102
/**
103-
* A builtin param that resolves to the Cloud storage bucket associated
103+
* A builtin parameter that resolves to the Cloud storage bucket associated
104104
* with the function, without prompting the deployer. Empty string if not
105105
* defined.
106106
*/
@@ -111,12 +111,12 @@ export const storageBucket: Param<string> = new InternalExpression(
111111

112112
/**
113113
* Declares a secret param, that will persist values only in Cloud Secret Manager.
114-
* Secrets are stored interally as bytestrings. Use ParamOptions.`as` to provide type
114+
* Secrets are stored interally as bytestrings. Use `ParamOptions.as` to provide type
115115
* hinting during parameter resolution.
116116
*
117-
* @param name The name of the environment variable to use to load the param.
118-
* @param options Configuration options for the param.
119-
* @returns A Param with a `string` return type for `.value`.
117+
* @param name The name of the environment variable to use to load the parameter.
118+
* @param options Configuration options for the parameter.
119+
* @returns A parameter with a `string` return type for `.value`.
120120
*/
121121
export function defineSecret(name: string): SecretParam {
122122
const param = new SecretParam(name);
@@ -125,11 +125,11 @@ export function defineSecret(name: string): SecretParam {
125125
}
126126

127127
/**
128-
* Declare a string param.
128+
* Declare a string parameter.
129129
*
130-
* @param name The name of the environment variable to use to load the param.
131-
* @param options Configuration options for the param.
132-
* @returns A Param with a `string` return type for `.value`.
130+
* @param name The name of the environment variable to use to load the parameter.
131+
* @param options Configuration options for the parameter.
132+
* @returns A parameter with a `string` return type for `.value`.
133133
*/
134134
export function defineString(name: string, options: ParamOptions<string> = {}): StringParam {
135135
const param = new StringParam(name, options);
@@ -138,11 +138,11 @@ export function defineString(name: string, options: ParamOptions<string> = {}):
138138
}
139139

140140
/**
141-
* Declare a boolean param.
141+
* Declare a boolean parameter.
142142
*
143-
* @param name The name of the environment variable to use to load the param.
144-
* @param options Configuration options for the param.
145-
* @returns A Param with a `boolean` return type for `.value`.
143+
* @param name The name of the environment variable to use to load the parameter.
144+
* @param options Configuration options for the parameter.
145+
* @returns A parameter with a `boolean` return type for `.value`.
146146
*/
147147
export function defineBoolean(name: string, options: ParamOptions<boolean> = {}): BooleanParam {
148148
const param = new BooleanParam(name, options);
@@ -151,11 +151,11 @@ export function defineBoolean(name: string, options: ParamOptions<boolean> = {})
151151
}
152152

153153
/**
154-
* Declare an integer param.
154+
* Declare an integer parameter.
155155
*
156-
* @param name The name of the environment variable to use to load the param.
157-
* @param options Configuration options for the param.
158-
* @returns A Param with a `number` return type for `.value`.
156+
* @param name The name of the environment variable to use to load the parameter.
157+
* @param options Configuration options for the parameter.
158+
* @returns A parameter with a `number` return type for `.value`.
159159
*/
160160
export function defineInt(name: string, options: ParamOptions<number> = {}): IntParam {
161161
const param = new IntParam(name, options);
@@ -164,11 +164,11 @@ export function defineInt(name: string, options: ParamOptions<number> = {}): Int
164164
}
165165

166166
/**
167-
* Declare a float param.
167+
* Declare a float parameter.
168168
*
169-
* @param name The name of the environment variable to use to load the param.
170-
* @param options Configuration options for the param.
171-
* @returns A Param with a `number` return type for `.value`.
169+
* @param name The name of the environment variable to use to load the parameter.
170+
* @param options Configuration options for the parameter.
171+
* @returns A parameter with a `number` return type for `.value`.
172172
*
173173
* @internal
174174
*/
@@ -179,11 +179,11 @@ export function defineFloat(name: string, options: ParamOptions<number> = {}): F
179179
}
180180

181181
/**
182-
* Declare a list param.
182+
* Declare a list parameter.
183183
*
184-
* @param name The name of the environment variable to use to load the param.
185-
* @param options Configuration options for the param.
186-
* @returns A Param with a `string[]` return type for `.value`.
184+
* @param name The name of the environment variable to use to load the parameter.
185+
* @param options Configuration options for the parameter.
186+
* @returns A parameter with a `string[]` return type for `.value`.
187187
*/
188188
export function defineList(name: string, options: ParamOptions<string[]> = {}): ListParam {
189189
const param = new ListParam(name, options);

‎src/params/types.ts

+32-28
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as logger from "../logger";
2828
* an Expression<number> as the value of an option that normally accepts numbers.
2929
*/
3030
export abstract class Expression<T extends string | number | boolean | string[]> {
31-
/** Returns the Expression's runtime value, based on the CLI's resolution of params. */
31+
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
3232
value(): T {
3333
if (process.env.FUNCTIONS_CONTROL_API === "true") {
3434
logger.warn(
@@ -47,11 +47,12 @@ export abstract class Expression<T extends string | number | boolean | string[]>
4747
throw new Error("Not implemented");
4848
}
4949

50-
/** Returns the Expression's representation as a braced CEL expression. */
50+
/** Returns the expression's representation as a braced CEL expression. */
5151
toCEL(): string {
5252
return `{{ ${this.toString()} }}`;
5353
}
5454

55+
/** Returns the expression's representation as JSON. */
5556
toJSON(): string {
5657
return this.toString();
5758
}
@@ -61,8 +62,8 @@ function valueOf<T extends string | number | boolean | string[]>(arg: T | Expres
6162
return arg instanceof Expression ? arg.runtimeValue() : arg;
6263
}
6364
/**
64-
* Returns how an entity (either an Expression or a literal value) should be represented in CEL.
65-
* - Expressions delegate to the .toString() method, which is used by the WireManifest
65+
* Returns how an entity (either an `Expression` or a literal value) should be represented in CEL.
66+
* - Expressions delegate to the `.toString()` method, which is used by the WireManifest
6667
* - Strings have to be quoted explicitly
6768
* - Arrays are represented as []-delimited, parsable JSON
6869
* - Numbers and booleans are not quoted explicitly
@@ -159,7 +160,7 @@ export class CompareExpression<
159160
return `${this.lhs} ${this.cmp} ${rhsStr}`;
160161
}
161162

162-
/** Returns a TernaryExpression which can resolve to one of two values, based on the resolution of this comparison. */
163+
/** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */
163164
thenElse<retT extends string | number | boolean | string[]>(
164165
ifTrue: retT | Expression<retT>,
165166
ifFalse: retT | Expression<retT>
@@ -220,8 +221,8 @@ type ParamInput<T> =
220221
| (T extends string ? ResourceInput : never);
221222

222223
/**
223-
* Specifies that a Param's value should be determined by prompting the user
224-
* to type it in interactively at deploy-time. Input that does not match the
224+
* Specifies that a parameter's value should be determined by prompting the user
225+
* to type it in interactively at deploy time. Input that does not match the
225226
* provided validationRegex, if present, will be retried.
226227
*/
227228
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -243,7 +244,7 @@ export interface TextInput<T = unknown> {
243244
}
244245

245246
/**
246-
* Specifies that a Param's value should be determined by having the user
247+
* Specifies that a parameter's value should be determined by having the user
247248
* select from a list containing all the project's resources of a certain
248249
* type. Currently, only type:"storage.googleapis.com/Bucket" is supported.
249250
*/
@@ -253,15 +254,18 @@ export interface ResourceInput {
253254
};
254255
}
255256

257+
/**
258+
* Autogenerate a list of buckets in a project that a user can select from.
259+
*/
256260
export const BUCKET_PICKER: ResourceInput = {
257261
resource: {
258262
type: "storage.googleapis.com/Bucket",
259263
},
260264
};
261265

262266
/**
263-
* Specifies that a Param's value should be determined by having the user select
264-
* from a list of pre-canned options interactively at deploy-time.
267+
* Specifies that a parameter's value should be determined by having the user select
268+
* from a list of pre-canned options interactively at deploy time.
265269
*/
266270
export interface SelectInput<T = unknown> {
267271
select: {
@@ -270,9 +274,9 @@ export interface SelectInput<T = unknown> {
270274
}
271275

272276
/**
273-
* Specifies that a Param's value should be determined by having the user select
274-
* a subset from a list of pre-canned options interactively at deploy-time.
275-
* Will result in errors if used on Params of type other than string[].
277+
* Specifies that a parameter's value should be determined by having the user select
278+
* a subset from a list of pre-canned options interactively at deploy time.
279+
* Will result in errors if used on parameters of type other than `string[]`.
276280
*/
277281
export interface MultiSelectInput {
278282
multiSelect: {
@@ -281,27 +285,27 @@ export interface MultiSelectInput {
281285
}
282286

283287
/**
284-
* One of the options provided to a SelectInput, containing a value and
288+
* One of the options provided to a `SelectInput`, containing a value and
285289
* optionally a human-readable label to display in the selection interface.
286290
*/
287291
export interface SelectOptions<T = unknown> {
288292
label?: string;
289293
value: T;
290294
}
291295

292-
/** The wire representation of a Param when it's sent to the CLI. A superset of ParamOptions. */
296+
/** The wire representation of a parameter when it's sent to the CLI. A superset of `ParamOptions`. */
293297
export type ParamSpec<T extends string | number | boolean | string[]> = {
294298
/** The name of the parameter which will be stored in .env files. Use UPPERCASE. */
295299
name: string;
296300
/** An optional default value to be used while prompting for input. Can be a literal or another parametrized expression. */
297301
default?: T | Expression<T>;
298-
/** An optional human-readable string to be used as a replacement for the Param's name when prompting. */
302+
/** An optional human-readable string to be used as a replacement for the parameter's name when prompting. */
299303
label?: string;
300-
/** An optional long-form description of the Param to be displayed while prompting. */
304+
/** An optional long-form description of the parameter to be displayed while prompting. */
301305
description?: string;
302306
/** @internal */
303307
type: ParamValueType;
304-
/** The way in which the Firebase CLI will prompt for the value of this Param. Defaults to a TextInput. */
308+
/** The way in which the Firebase CLI will prompt for the value of this parameter. Defaults to a TextInput. */
305309
input?: ParamInput<T>;
306310
};
307311

@@ -322,7 +326,7 @@ export type WireParamSpec<T extends string | number | boolean | string[]> = {
322326
input?: ParamInput<T>;
323327
};
324328

325-
/** Configuration options which can be used to customize the prompting behavior of a Param. */
329+
/** Configuration options which can be used to customize the prompting behavior of a parameter. */
326330
export type ParamOptions<T extends string | number | boolean | string[]> = Omit<
327331
ParamSpec<T>,
328332
"name" | "type"
@@ -345,43 +349,43 @@ export abstract class Param<T extends string | number | boolean | string[]> exte
345349
throw new Error("Not implemented");
346350
}
347351

348-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
352+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
349353
cmp(cmp: "==" | "!=" | ">" | ">=" | "<" | "<=", rhs: T | Expression<T>) {
350354
return new CompareExpression<T>(cmp, this, rhs);
351355
}
352356

353-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
357+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
354358
equals(rhs: T | Expression<T>) {
355359
return this.cmp("==", rhs);
356360
}
357361

358-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
362+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
359363
notEquals(rhs: T | Expression<T>) {
360364
return this.cmp("!=", rhs);
361365
}
362366

363-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
367+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
364368
greaterThan(rhs: T | Expression<T>) {
365369
return this.cmp(">", rhs);
366370
}
367371

368-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
372+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
369373
greaterThanOrEqualTo(rhs: T | Expression<T>) {
370374
return this.cmp(">=", rhs);
371375
}
372376

373-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
377+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
374378
lessThan(rhs: T | Expression<T>) {
375379
return this.cmp("<", rhs);
376380
}
377381

378-
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
382+
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
379383
lessThanOrEqualTo(rhs: T | Expression<T>) {
380384
return this.cmp("<=", rhs);
381385
}
382386

383387
/**
384-
* Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression.
388+
* Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression.
385389
* @deprecated A typo. Use lessThanOrEqualTo instead.
386390
*/
387391
lessThanorEqualTo(rhs: T | Expression<T>) {
@@ -474,7 +478,7 @@ export class StringParam extends Param<string> {
474478
/**
475479
* A CEL expression which represents an internal Firebase variable. This class
476480
* cannot be instantiated by developers, but we provide several canned instances
477-
* of it to make available params that will never have to be defined at
481+
* of it to make available parameters that will never have to be defined at
478482
* deployment time, and can always be read from process.env.
479483
* @internal
480484
*/

0 commit comments

Comments
 (0)
Please sign in to comment.