firebase-functions 3.20.0 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/lib/apps.js +1 -1
  2. package/lib/bin/firebase-functions.js +22 -1
  3. package/lib/cloud-functions.d.ts +56 -35
  4. package/lib/cloud-functions.js +12 -12
  5. package/lib/common/encoding.js +21 -1
  6. package/lib/common/providers/https.d.ts +37 -17
  7. package/lib/common/providers/https.js +11 -6
  8. package/lib/common/providers/identity.d.ts +11 -1
  9. package/lib/common/providers/identity.js +55 -207
  10. package/lib/common/providers/tasks.d.ts +9 -0
  11. package/lib/common/providers/tasks.js +12 -3
  12. package/lib/function-builder.d.ts +2 -2
  13. package/lib/function-builder.js +1 -1
  14. package/lib/handler-builder.js +3 -3
  15. package/lib/index.js +6 -2
  16. package/lib/logger/common.js +21 -0
  17. package/lib/logger/compat.js +22 -1
  18. package/lib/logger/index.d.ts +14 -6
  19. package/lib/logger/index.js +33 -6
  20. package/lib/providers/analytics.js +1 -1
  21. package/lib/providers/auth.d.ts +44 -10
  22. package/lib/providers/auth.js +80 -14
  23. package/lib/providers/database.js +11 -11
  24. package/lib/providers/firestore.js +7 -7
  25. package/lib/providers/https.js +7 -7
  26. package/lib/providers/pubsub.d.ts +6 -6
  27. package/lib/providers/pubsub.js +8 -8
  28. package/lib/providers/remoteConfig.js +1 -1
  29. package/lib/providers/storage.js +2 -2
  30. package/lib/providers/tasks.d.ts +30 -15
  31. package/lib/providers/tasks.js +19 -12
  32. package/lib/providers/testLab.js +1 -1
  33. package/lib/runtime/loader.js +9 -7
  34. package/lib/runtime/manifest.d.ts +5 -0
  35. package/lib/setup.js +3 -3
  36. package/lib/v2/core.d.ts +24 -20
  37. package/lib/v2/index.d.ts +11 -3
  38. package/lib/v2/index.js +12 -3
  39. package/lib/v2/options.d.ts +25 -35
  40. package/lib/v2/options.js +28 -88
  41. package/lib/v2/params/index.d.ts +4 -1
  42. package/lib/v2/params/index.js +25 -1
  43. package/lib/v2/params/types.js +21 -0
  44. package/lib/v2/providers/alerts/alerts.d.ts +107 -8
  45. package/lib/v2/providers/alerts/alerts.js +23 -7
  46. package/lib/v2/providers/alerts/appDistribution.d.ts +112 -12
  47. package/lib/v2/providers/alerts/appDistribution.js +29 -2
  48. package/lib/v2/providers/alerts/billing.d.ts +39 -12
  49. package/lib/v2/providers/alerts/billing.js +38 -1
  50. package/lib/v2/providers/alerts/crashlytics.d.ts +255 -47
  51. package/lib/v2/providers/alerts/crashlytics.js +63 -2
  52. package/lib/v2/providers/alerts/index.d.ts +6 -0
  53. package/lib/v2/providers/alerts/index.js +32 -1
  54. package/lib/v2/providers/eventarc.d.ts +116 -0
  55. package/lib/v2/providers/eventarc.js +69 -0
  56. package/lib/v2/providers/https.d.ts +128 -4
  57. package/lib/v2/providers/https.js +18 -14
  58. package/lib/v2/providers/identity.d.ts +126 -0
  59. package/lib/v2/providers/identity.js +104 -0
  60. package/lib/v2/providers/pubsub.d.ts +125 -8
  61. package/lib/v2/providers/pubsub.js +60 -7
  62. package/lib/v2/providers/storage.d.ts +209 -17
  63. package/lib/v2/providers/storage.js +57 -13
  64. package/lib/v2/providers/tasks.d.ts +107 -7
  65. package/lib/v2/providers/tasks.js +11 -8
  66. package/package.json +22 -3
@@ -1,4 +1,25 @@
1
1
  "use strict";
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2017 Firebase
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ // SOFTWARE.
2
23
  Object.defineProperty(exports, "__esModule", { value: true });
3
24
  exports.error = exports.warn = exports.info = exports.log = exports.debug = exports.write = void 0;
4
25
  const util_1 = require("util");
@@ -37,7 +58,8 @@ function removeCircular(obj, refs = []) {
37
58
  }
38
59
  /**
39
60
  * Writes a `LogEntry` to `stdout`/`stderr` (depending on severity).
40
- * @param entry The `LogEntry` including severity, message, and any additional structured metadata.
61
+ * @param entry - The `LogEntry` including severity, message, and any additional structured metadata.
62
+ * @public
41
63
  */
42
64
  function write(entry) {
43
65
  if (common_1.SUPPORTS_STRUCTURED_LOGS) {
@@ -62,7 +84,8 @@ exports.write = write;
62
84
  /**
63
85
  * Writes a `DEBUG` severity log. If the last argument provided is a plain object,
64
86
  * it is added to the `jsonPayload` in the Cloud Logging entry.
65
- * @param args Arguments, concatenated into the log message with space separators.
87
+ * @param args - Arguments, concatenated into the log message with space separators.
88
+ * @public
66
89
  */
67
90
  function debug(...args) {
68
91
  write(entryFromArgs('DEBUG', args));
@@ -71,7 +94,8 @@ exports.debug = debug;
71
94
  /**
72
95
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
73
96
  * it is added to the `jsonPayload` in the Cloud Logging entry.
74
- * @param args Arguments, concatenated into the log message with space separators.
97
+ * @param args - Arguments, concatenated into the log message with space separators.
98
+ * @public
75
99
  */
76
100
  function log(...args) {
77
101
  write(entryFromArgs('INFO', args));
@@ -80,7 +104,8 @@ exports.log = log;
80
104
  /**
81
105
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
82
106
  * it is added to the `jsonPayload` in the Cloud Logging entry.
83
- * @param args Arguments, concatenated into the log message with space separators.
107
+ * @param args - Arguments, concatenated into the log message with space separators.
108
+ * @public
84
109
  */
85
110
  function info(...args) {
86
111
  write(entryFromArgs('INFO', args));
@@ -89,7 +114,8 @@ exports.info = info;
89
114
  /**
90
115
  * Writes a `WARNING` severity log. If the last argument provided is a plain object,
91
116
  * it is added to the `jsonPayload` in the Cloud Logging entry.
92
- * @param args Arguments, concatenated into the log message with space separators.
117
+ * @param args - Arguments, concatenated into the log message with space separators.
118
+ * @public
93
119
  */
94
120
  function warn(...args) {
95
121
  write(entryFromArgs('WARNING', args));
@@ -98,7 +124,8 @@ exports.warn = warn;
98
124
  /**
99
125
  * Writes an `ERROR` severity log. If the last argument provided is a plain object,
100
126
  * it is added to the `jsonPayload` in the Cloud Logging entry.
101
- * @param args Arguments, concatenated into the log message with space separators.
127
+ * @param args - Arguments, concatenated into the log message with space separators.
128
+ * @public
102
129
  */
103
130
  function error(...args) {
104
131
  write(entryFromArgs('ERROR', args));
@@ -73,7 +73,7 @@ class AnalyticsEventBuilder {
73
73
  const dataConstructor = (raw) => {
74
74
  return new AnalyticsEvent(raw.data);
75
75
  };
76
- return cloud_functions_1.makeCloudFunction({
76
+ return (0, cloud_functions_1.makeCloudFunction)({
77
77
  handler,
78
78
  provider: exports.provider,
79
79
  eventType: 'event.log',
@@ -1,27 +1,61 @@
1
- import { UserRecord, UserInfo, UserRecordMetadata, userRecordConstructor } from '../common/providers/identity';
2
- import { CloudFunction, EventContext } from '../cloud-functions';
1
+ import { BlockingFunction, CloudFunction, EventContext } from '../cloud-functions';
2
+ import { AuthEventContext, AuthUserRecord, BeforeCreateResponse, BeforeSignInResponse, HttpsError, UserInfo, UserRecord, userRecordConstructor, UserRecordMetadata } from '../common/providers/identity';
3
3
  import { DeploymentOptions } from '../function-configuration';
4
4
  export { UserRecord, UserInfo, UserRecordMetadata, userRecordConstructor };
5
+ export { HttpsError };
5
6
  /** @hidden */
6
7
  export declare const provider = "google.firebase.auth";
7
8
  /** @hidden */
8
9
  export declare const service = "firebaseauth.googleapis.com";
9
10
  /**
10
- * Handle events related to Firebase authentication users.
11
+ * Resource level options
12
+ * @public
11
13
  */
12
- export declare function user(): UserBuilder;
14
+ export interface UserOptions {
15
+ /** Options to set configuration at the resource level for blocking functions. */
16
+ blockingOptions?: {
17
+ /** Pass the ID Token credential to the function. */
18
+ idToken?: boolean;
19
+ /** Pass the Access Token credential to the function. */
20
+ accessToken?: boolean;
21
+ /** Pass the Refresh Token credential to the function. */
22
+ refreshToken?: boolean;
23
+ };
24
+ }
25
+ /**
26
+ * Handles events related to Firebase authentication users.
27
+ * @param userOptions - Resource level options
28
+ * @returns UserBuilder - Builder used to create Cloud Functions for Firebase Auth user lifecycle events
29
+ * @public
30
+ */
31
+ export declare function user(userOptions?: UserOptions): UserBuilder;
13
32
  /** @hidden */
14
- export declare function _userWithOptions(options: DeploymentOptions): UserBuilder;
15
- /** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
33
+ export declare function _userWithOptions(options: DeploymentOptions, userOptions: UserOptions): UserBuilder;
34
+ /**
35
+ * Builder used to create Cloud Functions for Firebase Auth user lifecycle events.
36
+ * @public
37
+ */
16
38
  export declare class UserBuilder {
17
39
  private triggerResource;
18
- private options?;
40
+ private options;
41
+ private userOptions?;
19
42
  private static dataConstructor;
20
43
  /** @hidden */
21
- constructor(triggerResource: () => string, options?: DeploymentOptions);
22
- /** Respond to the creation of a Firebase Auth user. */
44
+ constructor(triggerResource: () => string, options: DeploymentOptions, userOptions?: UserOptions);
45
+ /**
46
+ * Responds to the creation of a Firebase Auth user.
47
+ * @public
48
+ */
23
49
  onCreate(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
24
- /** Respond to the deletion of a Firebase Auth user. */
50
+ /**
51
+ * Responds to the deletion of a Firebase Auth user.
52
+ * @public
53
+ */
25
54
  onDelete(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
55
+ beforeCreate(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeCreateResponse | void | Promise<BeforeCreateResponse> | Promise<void>): BlockingFunction;
56
+ beforeSignIn(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeSignInResponse | void | Promise<BeforeSignInResponse> | Promise<void>): BlockingFunction;
57
+ /** @hidden */
26
58
  private onOperation;
59
+ /** @hidden */
60
+ private beforeOperation;
27
61
  }
@@ -21,52 +21,73 @@
21
21
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.UserBuilder = exports._userWithOptions = exports.user = exports.service = exports.provider = exports.userRecordConstructor = exports.UserRecordMetadata = void 0;
24
+ exports.UserBuilder = exports._userWithOptions = exports.user = exports.service = exports.provider = exports.HttpsError = exports.userRecordConstructor = exports.UserRecordMetadata = void 0;
25
+ const cloud_functions_1 = require("../cloud-functions");
25
26
  const identity_1 = require("../common/providers/identity");
26
- Object.defineProperty(exports, "UserRecordMetadata", { enumerable: true, get: function () { return identity_1.UserRecordMetadata; } });
27
+ Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return identity_1.HttpsError; } });
27
28
  Object.defineProperty(exports, "userRecordConstructor", { enumerable: true, get: function () { return identity_1.userRecordConstructor; } });
28
- const cloud_functions_1 = require("../cloud-functions");
29
+ Object.defineProperty(exports, "UserRecordMetadata", { enumerable: true, get: function () { return identity_1.UserRecordMetadata; } });
29
30
  /** @hidden */
30
31
  exports.provider = 'google.firebase.auth';
31
32
  /** @hidden */
32
33
  exports.service = 'firebaseauth.googleapis.com';
33
34
  /**
34
- * Handle events related to Firebase authentication users.
35
+ * Handles events related to Firebase authentication users.
36
+ * @param userOptions - Resource level options
37
+ * @returns UserBuilder - Builder used to create Cloud Functions for Firebase Auth user lifecycle events
38
+ * @public
35
39
  */
36
- function user() {
37
- return _userWithOptions({});
40
+ function user(userOptions) {
41
+ return _userWithOptions({}, userOptions || {});
38
42
  }
39
43
  exports.user = user;
40
44
  /** @hidden */
41
- function _userWithOptions(options) {
45
+ function _userWithOptions(options, userOptions) {
42
46
  return new UserBuilder(() => {
43
47
  if (!process.env.GCLOUD_PROJECT) {
44
48
  throw new Error('process.env.GCLOUD_PROJECT is not set.');
45
49
  }
46
50
  return 'projects/' + process.env.GCLOUD_PROJECT;
47
- }, options);
51
+ }, options, userOptions);
48
52
  }
49
53
  exports._userWithOptions = _userWithOptions;
50
- /** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
54
+ /**
55
+ * Builder used to create Cloud Functions for Firebase Auth user lifecycle events.
56
+ * @public
57
+ */
51
58
  class UserBuilder {
52
59
  /** @hidden */
53
- constructor(triggerResource, options) {
60
+ constructor(triggerResource, options, userOptions) {
54
61
  this.triggerResource = triggerResource;
55
62
  this.options = options;
63
+ this.userOptions = userOptions;
56
64
  }
57
65
  static dataConstructor(raw) {
58
- return identity_1.userRecordConstructor(raw.data);
66
+ return (0, identity_1.userRecordConstructor)(raw.data);
59
67
  }
60
- /** Respond to the creation of a Firebase Auth user. */
68
+ /**
69
+ * Responds to the creation of a Firebase Auth user.
70
+ * @public
71
+ */
61
72
  onCreate(handler) {
62
73
  return this.onOperation(handler, 'user.create');
63
74
  }
64
- /** Respond to the deletion of a Firebase Auth user. */
75
+ /**
76
+ * Responds to the deletion of a Firebase Auth user.
77
+ * @public
78
+ */
65
79
  onDelete(handler) {
66
80
  return this.onOperation(handler, 'user.delete');
67
81
  }
82
+ beforeCreate(handler) {
83
+ return this.beforeOperation(handler, 'beforeCreate');
84
+ }
85
+ beforeSignIn(handler) {
86
+ return this.beforeOperation(handler, 'beforeSignIn');
87
+ }
88
+ /** @hidden */
68
89
  onOperation(handler, eventType) {
69
- return cloud_functions_1.makeCloudFunction({
90
+ return (0, cloud_functions_1.makeCloudFunction)({
70
91
  handler,
71
92
  provider: exports.provider,
72
93
  eventType,
@@ -77,5 +98,50 @@ class UserBuilder {
77
98
  options: this.options,
78
99
  });
79
100
  }
101
+ /** @hidden */
102
+ beforeOperation(handler, eventType) {
103
+ var _a, _b, _c, _d, _e, _f;
104
+ const accessToken = ((_b = (_a = this.userOptions) === null || _a === void 0 ? void 0 : _a.blockingOptions) === null || _b === void 0 ? void 0 : _b.accessToken) || false;
105
+ const idToken = ((_d = (_c = this.userOptions) === null || _c === void 0 ? void 0 : _c.blockingOptions) === null || _d === void 0 ? void 0 : _d.idToken) || false;
106
+ const refreshToken = ((_f = (_e = this.userOptions) === null || _e === void 0 ? void 0 : _e.blockingOptions) === null || _f === void 0 ? void 0 : _f.refreshToken) || false;
107
+ // Create our own function that just calls the provided function so we know for sure that
108
+ // handler takes two arguments. This is something common/providers/identity depends on.
109
+ const wrappedHandler = (user, context) => handler(user, context);
110
+ const func = (0, identity_1.wrapHandler)(eventType, wrappedHandler);
111
+ const legacyEventType = `providers/cloud.auth/eventTypes/user.${eventType}`;
112
+ func.__trigger = {
113
+ labels: {},
114
+ ...(0, cloud_functions_1.optionsToTrigger)(this.options),
115
+ blockingTrigger: {
116
+ eventType: legacyEventType,
117
+ options: {
118
+ accessToken,
119
+ idToken,
120
+ refreshToken,
121
+ },
122
+ },
123
+ };
124
+ func.__endpoint = {
125
+ platform: 'gcfv1',
126
+ labels: {},
127
+ ...(0, cloud_functions_1.optionsToEndpoint)(this.options),
128
+ blockingTrigger: {
129
+ eventType: legacyEventType,
130
+ options: {
131
+ accessToken,
132
+ idToken,
133
+ refreshToken,
134
+ },
135
+ },
136
+ };
137
+ func.__requiredAPIs = [
138
+ {
139
+ api: 'identitytoolkit.googleapis.com',
140
+ reason: 'Needed for auth blocking functions',
141
+ },
142
+ ];
143
+ func.run = handler;
144
+ return func;
145
+ }
80
146
  }
81
147
  exports.UserBuilder = UserBuilder;
@@ -104,20 +104,20 @@ class InstanceBuilder {
104
104
  * @return Firebase Realtime Database reference builder interface.
105
105
  */
106
106
  ref(path) {
107
- const normalized = path_1.normalizePath(path);
108
- return new RefBuilder(apps_1.apps(), () => `projects/_/instances/${this.instance}/refs/${normalized}`, this.options);
107
+ const normalized = (0, path_1.normalizePath)(path);
108
+ return new RefBuilder((0, apps_1.apps)(), () => `projects/_/instances/${this.instance}/refs/${normalized}`, this.options);
109
109
  }
110
110
  }
111
111
  exports.InstanceBuilder = InstanceBuilder;
112
112
  /** @hidden */
113
113
  function _refWithOptions(path, options) {
114
114
  const resourceGetter = () => {
115
- const normalized = path_1.normalizePath(path);
116
- const databaseURL = config_1.firebaseConfig().databaseURL;
115
+ const normalized = (0, path_1.normalizePath)(path);
116
+ const databaseURL = (0, config_1.firebaseConfig)().databaseURL;
117
117
  if (!databaseURL) {
118
118
  throw new Error('Missing expected firebase config value databaseURL, ' +
119
119
  'config is actually' +
120
- JSON.stringify(config_1.firebaseConfig()) +
120
+ JSON.stringify((0, config_1.firebaseConfig)()) +
121
121
  '\n If you are unit testing, please set process.env.FIREBASE_CONFIG');
122
122
  }
123
123
  let instance;
@@ -136,7 +136,7 @@ function _refWithOptions(path, options) {
136
136
  }
137
137
  return `projects/_/instances/${instance}/refs/${normalized}`;
138
138
  };
139
- return new RefBuilder(apps_1.apps(), resourceGetter, options);
139
+ return new RefBuilder((0, apps_1.apps)(), resourceGetter, options);
140
140
  }
141
141
  exports._refWithOptions = _refWithOptions;
142
142
  /**
@@ -153,7 +153,7 @@ class RefBuilder {
153
153
  this.changeConstructor = (raw) => {
154
154
  const [dbInstance, path] = extractInstanceAndPath(raw.context.resource.name, raw.context.domain);
155
155
  const before = new DataSnapshot(raw.data.data, path, this.apps.admin, dbInstance);
156
- const after = new DataSnapshot(utils_1.applyChange(raw.data.data, raw.data.delta), path, this.apps.admin, dbInstance);
156
+ const after = new DataSnapshot((0, utils_1.applyChange)(raw.data.data, raw.data.delta), path, this.apps.admin, dbInstance);
157
157
  return {
158
158
  before,
159
159
  after,
@@ -214,7 +214,7 @@ class RefBuilder {
214
214
  return this.onOperation(handler, 'ref.delete', dataConstructor);
215
215
  }
216
216
  onOperation(handler, eventType, dataConstructor) {
217
- return cloud_functions_1.makeCloudFunction({
217
+ return (0, cloud_functions_1.makeCloudFunction)({
218
218
  handler,
219
219
  provider: exports.provider,
220
220
  service: exports.service,
@@ -311,7 +311,7 @@ class DataSnapshot {
311
311
  * However, accessing the key on the root URL of a Database will return `null`.
312
312
  */
313
313
  get key() {
314
- const last = _.last(path_1.pathParts(this._fullPath()));
314
+ const last = _.last((0, path_1.pathParts)(this._fullPath()));
315
315
  return !last || last === '' ? null : last;
316
316
  }
317
317
  /**
@@ -326,7 +326,7 @@ class DataSnapshot {
326
326
  * Array, string, number, boolean, or `null`).
327
327
  */
328
328
  val() {
329
- const parts = path_1.pathParts(this._childPath);
329
+ const parts = (0, path_1.pathParts)(this._childPath);
330
330
  const source = this._data;
331
331
  const node = _.cloneDeep(parts.length ? _.get(source, parts, null) : source);
332
332
  return this._checkAndConvertToArray(node);
@@ -494,7 +494,7 @@ class DataSnapshot {
494
494
  const dup = new DataSnapshot(this._data, undefined, this.app, this.instance);
495
495
  [dup._path, dup._childPath] = [this._path, this._childPath];
496
496
  if (childPath) {
497
- dup._childPath = path_1.joinPath(dup._childPath, childPath);
497
+ dup._childPath = (0, path_1.joinPath)(dup._childPath, childPath);
498
498
  }
499
499
  return dup;
500
500
  }
@@ -113,8 +113,8 @@ function _getValueProto(data, resource, valueFieldName) {
113
113
  }
114
114
  const proto = {
115
115
  fields: _.get(data, [valueFieldName, 'fields'], {}),
116
- createTime: encoder_1.dateToTimestampProto(_.get(data, [valueFieldName, 'createTime'])),
117
- updateTime: encoder_1.dateToTimestampProto(_.get(data, [valueFieldName, 'updateTime'])),
116
+ createTime: (0, encoder_1.dateToTimestampProto)(_.get(data, [valueFieldName, 'createTime'])),
117
+ updateTime: (0, encoder_1.dateToTimestampProto)(_.get(data, [valueFieldName, 'updateTime'])),
118
118
  name: _.get(data, [valueFieldName, 'name'], resource),
119
119
  };
120
120
  return proto;
@@ -123,7 +123,7 @@ function _getValueProto(data, resource, valueFieldName) {
123
123
  function snapshotConstructor(event) {
124
124
  var _a;
125
125
  if (!firestoreInstance) {
126
- firestoreInstance = firebase.firestore(apps_1.apps().admin);
126
+ firestoreInstance = firebase.firestore((0, apps_1.apps)().admin);
127
127
  }
128
128
  const valueProto = _getValueProto(event.data, event.context.resource.name, 'value');
129
129
  let timeString = (_a = _.get(event, 'data.value.readTime')) !== null && _a !== void 0 ? _a : _.get(event, 'data.value.updateTime');
@@ -131,7 +131,7 @@ function snapshotConstructor(event) {
131
131
  logger.warn('Snapshot has no readTime. Using now()');
132
132
  timeString = new Date().toISOString();
133
133
  }
134
- const readTime = encoder_1.dateToTimestampProto(timeString);
134
+ const readTime = (0, encoder_1.dateToTimestampProto)(timeString);
135
135
  return firestoreInstance.snapshot_(valueProto, readTime, 'json');
136
136
  }
137
137
  exports.snapshotConstructor = snapshotConstructor;
@@ -139,10 +139,10 @@ exports.snapshotConstructor = snapshotConstructor;
139
139
  // TODO remove this function when wire format changes to new format
140
140
  function beforeSnapshotConstructor(event) {
141
141
  if (!firestoreInstance) {
142
- firestoreInstance = firebase.firestore(apps_1.apps().admin);
142
+ firestoreInstance = firebase.firestore((0, apps_1.apps)().admin);
143
143
  }
144
144
  const oldValueProto = _getValueProto(event.data, event.context.resource.name, 'oldValue');
145
- const oldReadTime = encoder_1.dateToTimestampProto(_.get(event, 'data.oldValue.readTime'));
145
+ const oldReadTime = (0, encoder_1.dateToTimestampProto)(_.get(event, 'data.oldValue.readTime'));
146
146
  return firestoreInstance.snapshot_(oldValueProto, oldReadTime, 'json');
147
147
  }
148
148
  exports.beforeSnapshotConstructor = beforeSnapshotConstructor;
@@ -173,7 +173,7 @@ class DocumentBuilder {
173
173
  return this.onOperation(handler, 'document.delete', beforeSnapshotConstructor);
174
174
  }
175
175
  onOperation(handler, eventType, dataConstructor) {
176
- return cloud_functions_1.makeCloudFunction({
176
+ return (0, cloud_functions_1.makeCloudFunction)({
177
177
  handler,
178
178
  provider: exports.provider,
179
179
  eventType,
@@ -50,17 +50,17 @@ function _onRequestWithOptions(handler, options) {
50
50
  return handler(req, res);
51
51
  };
52
52
  cloudFunction.__trigger = {
53
- ...cloud_functions_1.optionsToTrigger(options),
53
+ ...(0, cloud_functions_1.optionsToTrigger)(options),
54
54
  httpsTrigger: {},
55
55
  };
56
- encoding_1.convertIfPresent(cloudFunction.__trigger.httpsTrigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
56
+ (0, encoding_1.convertIfPresent)(cloudFunction.__trigger.httpsTrigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
57
57
  // TODO parse the options
58
58
  cloudFunction.__endpoint = {
59
59
  platform: 'gcfv1',
60
- ...cloud_functions_1.optionsToEndpoint(options),
60
+ ...(0, cloud_functions_1.optionsToEndpoint)(options),
61
61
  httpsTrigger: {},
62
62
  };
63
- encoding_1.convertIfPresent(cloudFunction.__endpoint.httpsTrigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
63
+ (0, encoding_1.convertIfPresent)(cloudFunction.__endpoint.httpsTrigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
64
64
  return cloudFunction;
65
65
  }
66
66
  exports._onRequestWithOptions = _onRequestWithOptions;
@@ -70,20 +70,20 @@ function _onCallWithOptions(handler, options) {
70
70
  // and the user could have only tried to listen to data. Wrap their handler
71
71
  // in another handler to avoid accidentally triggering the v2 API
72
72
  const fixedLen = (data, context) => handler(data, context);
73
- const func = https_1.onCallHandler({
73
+ const func = (0, https_1.onCallHandler)({
74
74
  allowInvalidAppCheckToken: options.allowInvalidAppCheckToken,
75
75
  cors: { origin: true, methods: 'POST' },
76
76
  }, fixedLen);
77
77
  func.__trigger = {
78
78
  labels: {},
79
- ...cloud_functions_1.optionsToTrigger(options),
79
+ ...(0, cloud_functions_1.optionsToTrigger)(options),
80
80
  httpsTrigger: {},
81
81
  };
82
82
  func.__trigger.labels['deployment-callable'] = 'true';
83
83
  func.__endpoint = {
84
84
  platform: 'gcfv1',
85
85
  labels: {},
86
- ...cloud_functions_1.optionsToEndpoint(options),
86
+ ...(0, cloud_functions_1.optionsToEndpoint)(options),
87
87
  callableTrigger: {},
88
88
  };
89
89
  func.run = handler;
@@ -8,8 +8,8 @@ export declare const service = "pubsub.googleapis.com";
8
8
  * Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
9
9
  * is sent to a specified topic.
10
10
  *
11
- * @param topic The Pub/Sub topic to watch for message events.
12
- * @return Pub/Sub topic builder interface.
11
+ * @param topic - The Pub/Sub topic to watch for message events.
12
+ * @returns Pub/Sub topic builder interface.
13
13
  */
14
14
  export declare function topic(topic: string): TopicBuilder;
15
15
  /** @hidden */
@@ -28,7 +28,7 @@ export declare class TopicBuilder {
28
28
  * Event handler that fires every time a Cloud Pub/Sub message is
29
29
  * published.
30
30
  *
31
- * @param handler Event handler that runs every time a Cloud Pub/Sub message
31
+ * @param handler - Event handler that runs every time a Cloud Pub/Sub message
32
32
  * is published.
33
33
  * @return A Cloud Function that you can export and deploy.
34
34
  */
@@ -37,7 +37,7 @@ export declare class TopicBuilder {
37
37
  /**
38
38
  * Registers a Cloud Function to run at specified times.
39
39
  *
40
- * @param schedule The schedule, in Unix Crontab or AppEngine syntax.
40
+ * @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
41
41
  * @return ScheduleBuilder interface.
42
42
  */
43
43
  export declare function schedule(schedule: string): ScheduleBuilder;
@@ -63,7 +63,7 @@ export declare class ScheduleBuilder {
63
63
  * Event handler for scheduled functions. Triggered whenever the associated
64
64
  * scheduler job sends a Pub/Sub message.
65
65
  *
66
- * @param handler Handler that fires whenever the associated
66
+ * @param handler - Handler that fires whenever the associated
67
67
  * scheduler job sends a Pub/Sub message.
68
68
  * @return A Cloud Function that you can export and deploy.
69
69
  */
@@ -72,7 +72,7 @@ export declare class ScheduleBuilder {
72
72
  /**
73
73
  * Interface representing a Google Cloud Pub/Sub message.
74
74
  *
75
- * @param data Payload of a Pub/Sub message.
75
+ * @param data - Payload of a Pub/Sub message.
76
76
  */
77
77
  export declare class Message {
78
78
  /**
@@ -31,8 +31,8 @@ exports.service = 'pubsub.googleapis.com';
31
31
  * Registers a Cloud Function triggered when a Google Cloud Pub/Sub message
32
32
  * is sent to a specified topic.
33
33
  *
34
- * @param topic The Pub/Sub topic to watch for message events.
35
- * @return Pub/Sub topic builder interface.
34
+ * @param topic - The Pub/Sub topic to watch for message events.
35
+ * @returns Pub/Sub topic builder interface.
36
36
  */
37
37
  function topic(topic) {
38
38
  return _topicWithOptions(topic, {});
@@ -66,12 +66,12 @@ class TopicBuilder {
66
66
  * Event handler that fires every time a Cloud Pub/Sub message is
67
67
  * published.
68
68
  *
69
- * @param handler Event handler that runs every time a Cloud Pub/Sub message
69
+ * @param handler - Event handler that runs every time a Cloud Pub/Sub message
70
70
  * is published.
71
71
  * @return A Cloud Function that you can export and deploy.
72
72
  */
73
73
  onPublish(handler) {
74
- return cloud_functions_1.makeCloudFunction({
74
+ return (0, cloud_functions_1.makeCloudFunction)({
75
75
  handler,
76
76
  provider: exports.provider,
77
77
  service: exports.service,
@@ -86,7 +86,7 @@ exports.TopicBuilder = TopicBuilder;
86
86
  /**
87
87
  * Registers a Cloud Function to run at specified times.
88
88
  *
89
- * @param schedule The schedule, in Unix Crontab or AppEngine syntax.
89
+ * @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
90
90
  * @return ScheduleBuilder interface.
91
91
  */
92
92
  function schedule(schedule) {
@@ -135,12 +135,12 @@ class ScheduleBuilder {
135
135
  * Event handler for scheduled functions. Triggered whenever the associated
136
136
  * scheduler job sends a Pub/Sub message.
137
137
  *
138
- * @param handler Handler that fires whenever the associated
138
+ * @param handler - Handler that fires whenever the associated
139
139
  * scheduler job sends a Pub/Sub message.
140
140
  * @return A Cloud Function that you can export and deploy.
141
141
  */
142
142
  onRun(handler) {
143
- const cloudFunction = cloud_functions_1.makeCloudFunction({
143
+ const cloudFunction = (0, cloud_functions_1.makeCloudFunction)({
144
144
  contextOnlyHandler: handler,
145
145
  provider: exports.provider,
146
146
  service: exports.service,
@@ -156,7 +156,7 @@ exports.ScheduleBuilder = ScheduleBuilder;
156
156
  /**
157
157
  * Interface representing a Google Cloud Pub/Sub message.
158
158
  *
159
- * @param data Payload of a Pub/Sub message.
159
+ * @param data - Payload of a Pub/Sub message.
160
160
  */
161
161
  class Message {
162
162
  constructor(data) {
@@ -65,7 +65,7 @@ class UpdateBuilder {
65
65
  * version metadata as an argument.
66
66
  */
67
67
  onUpdate(handler) {
68
- return cloud_functions_1.makeCloudFunction({
68
+ return (0, cloud_functions_1.makeCloudFunction)({
69
69
  handler,
70
70
  provider: exports.provider,
71
71
  service: exports.service,
@@ -53,7 +53,7 @@ exports.object = object;
53
53
  /** @hidden */
54
54
  function _bucketWithOptions(options, bucket) {
55
55
  const resourceGetter = () => {
56
- bucket = bucket || config_1.firebaseConfig().storageBucket;
56
+ bucket = bucket || (0, config_1.firebaseConfig)().storageBucket;
57
57
  if (!bucket) {
58
58
  throw new Error('Missing bucket name. If you are unit testing, please provide a bucket name' +
59
59
  ' through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.');
@@ -170,7 +170,7 @@ class ObjectBuilder {
170
170
  }
171
171
  /** @hidden */
172
172
  onOperation(handler, eventType) {
173
- return cloud_functions_1.makeCloudFunction({
173
+ return (0, cloud_functions_1.makeCloudFunction)({
174
174
  handler,
175
175
  provider: exports.provider,
176
176
  service: exports.service,