|
21 | 21 | // SOFTWARE.
|
22 | 22 |
|
23 | 23 | import { Request, Response } from 'express';
|
24 |
| -import * as _ from 'lodash'; |
25 | 24 | import { warn } from '../logger';
|
26 | 25 | import {
|
27 | 26 | DEFAULT_FAILURE_POLICY,
|
@@ -202,95 +201,6 @@ export interface EventContext<Params = Record<string, string>> {
|
202 | 201 | timestamp: string;
|
203 | 202 | }
|
204 | 203 |
|
205 |
| -/** |
206 |
| - * The Functions interface for events that change state, such as |
207 |
| - * Realtime Database or Cloud Firestore `onWrite` and `onUpdate`. |
208 |
| - * |
209 |
| - * For more information about the format used to construct `Change` objects, see |
210 |
| - * [`cloud-functions.ChangeJson`](/docs/reference/functions/cloud_functions_.changejson). |
211 |
| - * |
212 |
| - */ |
213 |
| -export class Change<T> { |
214 |
| - constructor(public before: T, public after: T) {} |
215 |
| -} |
216 |
| - |
217 |
| -/** |
218 |
| - * `ChangeJson` is the JSON format used to construct a Change object. |
219 |
| - */ |
220 |
| -export interface ChangeJson { |
221 |
| - /** |
222 |
| - * Key-value pairs representing state of data after the change. |
223 |
| - */ |
224 |
| - after?: any; |
225 |
| - /** |
226 |
| - * Key-value pairs representing state of data before the change. If |
227 |
| - * `fieldMask` is set, then only fields that changed are present in `before`. |
228 |
| - */ |
229 |
| - before?: any; |
230 |
| - /** |
231 |
| - * @hidden |
232 |
| - * Comma-separated string that represents names of fields that changed. |
233 |
| - */ |
234 |
| - fieldMask?: string; |
235 |
| -} |
236 |
| - |
237 |
| -export namespace Change { |
238 |
| - /** @hidden */ |
239 |
| - function reinterpretCast<T>(x: any) { |
240 |
| - return x as T; |
241 |
| - } |
242 |
| - |
243 |
| - /** |
244 |
| - * @hidden |
245 |
| - * Factory method for creating a Change from a `before` object and an `after` |
246 |
| - * object. |
247 |
| - */ |
248 |
| - export function fromObjects<T>(before: T, after: T) { |
249 |
| - return new Change(before, after); |
250 |
| - } |
251 |
| - |
252 |
| - /** |
253 |
| - * @hidden |
254 |
| - * Factory method for creating a Change from a JSON and an optional customizer |
255 |
| - * function to be applied to both the `before` and the `after` fields. |
256 |
| - */ |
257 |
| - export function fromJSON<T>( |
258 |
| - json: ChangeJson, |
259 |
| - customizer: (x: any) => T = reinterpretCast |
260 |
| - ): Change<T> { |
261 |
| - let before = { ...json.before }; |
262 |
| - if (json.fieldMask) { |
263 |
| - before = applyFieldMask(before, json.after, json.fieldMask); |
264 |
| - } |
265 |
| - |
266 |
| - return Change.fromObjects( |
267 |
| - customizer(before || {}), |
268 |
| - customizer(json.after || {}) |
269 |
| - ); |
270 |
| - } |
271 |
| - |
272 |
| - /** @hidden */ |
273 |
| - export function applyFieldMask( |
274 |
| - sparseBefore: any, |
275 |
| - after: any, |
276 |
| - fieldMask: string |
277 |
| - ) { |
278 |
| - const before = { ...after }; |
279 |
| - const masks = fieldMask.split(','); |
280 |
| - |
281 |
| - masks.forEach((mask) => { |
282 |
| - const val = _.get(sparseBefore, mask); |
283 |
| - if (typeof val === 'undefined') { |
284 |
| - _.unset(before, mask); |
285 |
| - } else { |
286 |
| - _.set(before, mask, val); |
287 |
| - } |
288 |
| - }); |
289 |
| - |
290 |
| - return before; |
291 |
| - } |
292 |
| -} |
293 |
| - |
294 | 204 | /**
|
295 | 205 | * Resource is a standard format for defining a resource
|
296 | 206 | * (google.rpc.context.AttributeContext.Resource). In Cloud Functions, it is the
|
|
0 commit comments