Skip to content

Commit f69669f

Browse files
authored
Merge branch 'master' into em-pubsub
2 parents 5ac4e82 + a2e58e7 commit f69669f

File tree

5 files changed

+69
-16
lines changed

5 files changed

+69
-16
lines changed

docgen/content-sources/toc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ toc:
1212
path: /docs/reference/functions/function_builder_.functionbuilder.html
1313
- title: 'Change'
1414
path: /docs/reference/functions/cloud_functions_.change.html
15+
- title: 'ChangeJson'
16+
path: /docs/reference/functions/cloud_functions_.changejson.html
1517

1618
- title: 'functions.config'
1719
path: /docs/reference/functions/config_.html

src/cloud-functions.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,19 @@ export interface EventContext {
143143
}
144144

145145
/**
146-
* Change describes a change of state - "before" represents the state prior to
147-
* the event, "after" represents the state after the event.
146+
* The Functions interface for events that change state, such as
147+
* Realtime Database or Cloud Firestore `onWrite` and `onUpdate`.
148+
*
149+
* For more information about the format used to construct `Change` objects, see
150+
* [`cloud-functions.ChangeJson`](/docs/reference/functions/cloud_functions_.changejson).
151+
*
148152
*/
149153
export class Change<T> {
150154
constructor(public before: T, public after: T) {}
151155
}
152156

153157
/**
154-
* ChangeJson is the JSON format used to construct a Change object.
158+
* `ChangeJson` is the JSON format used to construct a Change object.
155159
*/
156160
export interface ChangeJson {
157161
/**
@@ -164,17 +168,20 @@ export interface ChangeJson {
164168
*/
165169
before?: any;
166170
/**
167-
* Comma-separated string that represents names of field that changed.
171+
* @hidden
172+
* Comma-separated string that represents names of fields that changed.
168173
*/
169174
fieldMask?: string;
170175
}
171176

172177
export namespace Change {
178+
/** @hidden */
173179
function reinterpretCast<T>(x: any) {
174180
return x as T;
175181
}
176182

177183
/**
184+
* @hidden
178185
* Factory method for creating a Change from a `before` object and an `after`
179186
* object.
180187
*/
@@ -183,6 +190,7 @@ export namespace Change {
183190
}
184191

185192
/**
193+
* @hidden
186194
* Factory method for creating a Change from a JSON and an optional customizer
187195
* function to be applied to both the `before` and the `after` fields.
188196
*/

src/providers/https.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as _ from 'lodash';
2727
import { apps } from '../apps';
2828
import { HttpsFunction, optionsToTrigger, Runnable } from '../cloud-functions';
2929
import { DeploymentOptions } from '../function-configuration';
30+
import { assertNever } from '../utilities/assertions';
3031

3132
export interface Request extends express.Request {
3233
rawBody: Buffer;
@@ -231,7 +232,7 @@ export class HttpsError extends Error {
231232
return 500;
232233
// This should never happen as long as the type system is doing its job.
233234
default:
234-
throw new Error('Invalid error code: ' + this.code);
235+
assertNever(this.code);
235236
}
236237
}
237238

src/providers/remoteConfig.ts

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ export const provider = 'google.firebase.remoteconfig';
3535
export const service = 'firebaseremoteconfig.googleapis.com';
3636

3737
/**
38-
* Handle all updates (including rollbacks) that affect a Remote Config project.
39-
* @param handler A function that takes the updated Remote Config template
40-
* version metadata as an argument.
38+
* Registers a function that triggers on Firebase Remote Config template
39+
* update events.
40+
*
41+
* @param handler A function that takes the updated Remote Config
42+
* template version metadata as an argument.
43+
*
44+
* @return A Cloud Function that you can export and deploy.
4145
*/
4246
export function onUpdate(
4347
handler: (
@@ -97,8 +101,8 @@ export class UpdateBuilder {
97101
}
98102

99103
/**
100-
* Interface representing a Remote Config template version metadata object that
101-
* was emitted when the project was updated.
104+
* An interface representing a Remote Config template version metadata object
105+
* emitted when a project is updated.
102106
*/
103107
export interface TemplateVersion {
104108
/** The version number of the updated Remote Config template. */
@@ -107,27 +111,49 @@ export interface TemplateVersion {
107111
/** When the template was updated in format (ISO8601 timestamp). */
108112
updateTime: string;
109113

110-
/** Metadata about the account that performed the update. */
114+
/**
115+
* Metadata about the account that performed the update, of
116+
* type [`RemoteConfigUser`](/docs/reference/remote-config/rest/v1/Version#remoteconfiguser).
117+
*/
111118
updateUser: RemoteConfigUser;
112119

113-
/** A description associated with the particular Remote Config template. */
120+
/** A description associated with this Remote Config template version. */
114121
description: string;
115122

116-
/** The origin of the caller. */
123+
/**
124+
* The origin of the caller - either the Firebase console or the Remote Config
125+
* REST API. See [`RemoteConfigUpdateOrigin`](/docs/reference/remote-config/rest/v1/Version#remoteconfigupdateorigin)
126+
* for valid values.
127+
*/
117128
updateOrigin: string;
118129

119-
/** The type of update action that was performed. */
130+
/**
131+
* The type of update action that was performed, whether forced,
132+
* incremental, or a rollback operation. See
133+
* [`RemoteConfigUpdateType`](/docs/reference/remote-config/rest/v1/Version#remoteconfigupdatetype)
134+
* for valid values.
135+
*/
120136
updateType: string;
121137

122138
/**
123-
* The version number of the Remote Config template that was rolled back to,
124-
* if the update was a rollback.
139+
* The version number of the Remote Config template that this update rolled back to.
140+
* Only applies if this update was a rollback.
125141
*/
126142
rollbackSource?: number;
127143
}
128144

145+
/**
146+
* An interface representing metadata for a Remote Config account
147+
* that performed the update. Contains the same fields as
148+
* [`RemoteConfigUser`](/docs/reference/remote-config/rest/v1/Version#remoteconfiguser).
149+
*/
129150
export interface RemoteConfigUser {
151+
/** Name of the Remote Config account that performed the update. */
130152
name?: string;
153+
154+
/** Email address of the Remote Config account that performed the update. */
131155
email: string;
156+
157+
/** Image URL of the Remote Config account that performed the update. */
132158
imageUrl?: string;
133159
}

src/utilities/assertions.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @file Provides common assertion helpers which can be used to improve
3+
* strictness of both type checking and runtime.
4+
*/
5+
6+
/**
7+
* Checks that the given value is of type `never` — the type that’s left after
8+
* all other cases have been removed.
9+
*
10+
* @param x A value of type `never`.
11+
*/
12+
export function assertNever(x: never): never {
13+
throw new Error(
14+
`Unhandled discriminated union member: ${JSON.stringify(x)}.`
15+
);
16+
}

0 commit comments

Comments
 (0)