firebase-functions 3.15.2 → 3.15.6

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.
package/lib/apps.js CHANGED
@@ -103,7 +103,7 @@ exports.apps = apps;
103
103
  this._emulatedAdminApp = app;
104
104
  }
105
105
  get firebaseArgs() {
106
- return _.assign({}, config_1.firebaseConfig(), {
106
+ return _.assign({}, (0, config_1.firebaseConfig)(), {
107
107
  credential: firebase.credential.applicationDefault(),
108
108
  });
109
109
  }
@@ -185,7 +185,9 @@ export interface TriggerAnnotated {
185
185
  service: string;
186
186
  };
187
187
  failurePolicy?: FailurePolicy;
188
- httpsTrigger?: {};
188
+ httpsTrigger?: {
189
+ invoker?: string[];
190
+ };
189
191
  labels?: {
190
192
  [key: string]: string;
191
193
  };
@@ -196,7 +198,6 @@ export interface TriggerAnnotated {
196
198
  vpcConnectorEgressSettings?: string;
197
199
  serviceAccountEmail?: string;
198
200
  ingressSettings?: string;
199
- invoker?: string[];
200
201
  };
201
202
  }
202
203
  /**
@@ -135,7 +135,7 @@ function makeCloudFunction({ after = () => { }, before = () => { }, contextOnlyH
135
135
  promise = handler(dataOrChange, context);
136
136
  }
137
137
  if (typeof promise === 'undefined') {
138
- logger_1.warn('Function returned undefined, expected Promise or value');
138
+ (0, logger_1.warn)('Function returned undefined, expected Promise or value');
139
139
  }
140
140
  return Promise.resolve(promise)
141
141
  .then((result) => {
@@ -216,8 +216,8 @@ function _detectAuthType(event) {
216
216
  /** @hidden */
217
217
  function optionsToTrigger(options) {
218
218
  const trigger = {};
219
- encoding_1.copyIfPresent(trigger, options, 'regions', 'schedule', 'minInstances', 'maxInstances', 'ingressSettings', 'vpcConnectorEgressSettings', 'vpcConnector', 'labels');
220
- encoding_1.convertIfPresent(trigger, options, 'failurePolicy', 'failurePolicy', (policy) => {
219
+ (0, encoding_1.copyIfPresent)(trigger, options, 'regions', 'schedule', 'minInstances', 'maxInstances', 'ingressSettings', 'vpcConnectorEgressSettings', 'vpcConnector', 'labels');
220
+ (0, encoding_1.convertIfPresent)(trigger, options, 'failurePolicy', 'failurePolicy', (policy) => {
221
221
  if (policy === false) {
222
222
  return undefined;
223
223
  }
@@ -228,8 +228,8 @@ function optionsToTrigger(options) {
228
228
  return policy;
229
229
  }
230
230
  });
231
- encoding_1.convertIfPresent(trigger, options, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
232
- encoding_1.convertIfPresent(trigger, options, 'availableMemoryMb', 'memory', (mem) => {
231
+ (0, encoding_1.convertIfPresent)(trigger, options, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
232
+ (0, encoding_1.convertIfPresent)(trigger, options, 'availableMemoryMb', 'memory', (mem) => {
233
233
  const memoryLookup = {
234
234
  '128MB': 128,
235
235
  '256MB': 256,
@@ -241,8 +241,7 @@ function optionsToTrigger(options) {
241
241
  };
242
242
  return memoryLookup[mem];
243
243
  });
244
- encoding_1.convertIfPresent(trigger, options, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
245
- encoding_1.convertIfPresent(trigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
244
+ (0, encoding_1.convertIfPresent)(trigger, options, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
246
245
  return trigger;
247
246
  }
248
247
  exports.optionsToTrigger = optionsToTrigger;
@@ -52,9 +52,15 @@ function convertInvoker(invoker) {
52
52
  if (typeof invoker === 'string') {
53
53
  invoker = [invoker];
54
54
  }
55
+ if (invoker.length === 0) {
56
+ throw new Error('Invalid option for invoker: Must be a non-empty array.');
57
+ }
58
+ if (invoker.find((inv) => inv.length === 0)) {
59
+ throw new Error('Invalid option for invoker: Must be a non-empty string.');
60
+ }
55
61
  if (invoker.length > 1 &&
56
62
  invoker.find((inv) => inv === 'public' || inv === 'private')) {
57
- throw new Error("Invalid option for invoker. Cannot have 'public' or 'private' in an array of service accounts");
63
+ throw new Error("Invalid option for invoker: Cannot have 'public' or 'private' in an array of service accounts.");
58
64
  }
59
65
  return invoker;
60
66
  }
@@ -224,10 +224,10 @@ async function checkTokens(req, ctx) {
224
224
  if (appCheck) {
225
225
  verifications.app = 'INVALID';
226
226
  try {
227
- if (!apps_1.apps().admin.appCheck) {
227
+ if (!(0, apps_1.apps)().admin.appCheck) {
228
228
  throw new Error('Cannot validate AppCheck token. Please update Firebase Admin SDK to >= v9.8.0');
229
229
  }
230
- const appCheckToken = await apps_1.apps()
230
+ const appCheckToken = await (0, apps_1.apps)()
231
231
  .admin.appCheck()
232
232
  .verifyToken(appCheck);
233
233
  ctx.app = {
@@ -247,7 +247,7 @@ async function checkTokens(req, ctx) {
247
247
  if (match) {
248
248
  const idToken = match[1];
249
249
  try {
250
- const authToken = await apps_1.apps()
250
+ const authToken = await (0, apps_1.apps)()
251
251
  .admin.auth()
252
252
  .verifyIdToken(idToken);
253
253
  verifications.auth = 'VALID';
@@ -68,7 +68,6 @@ export interface RuntimeOptions {
68
68
  * Min number of actual instances to be running at a given time.
69
69
  * Instances will be billed for memory allocation and 10% of CPU allocation
70
70
  * while idle.
71
- * @hidden
72
71
  */
73
72
  minInstances?: number;
74
73
  /**
@@ -111,12 +111,12 @@ class HandlerBuilder {
111
111
  get instance() {
112
112
  return {
113
113
  get ref() {
114
- return new database.RefBuilder(apps_1.apps(), () => null, {});
114
+ return new database.RefBuilder((0, apps_1.apps)(), () => null, {});
115
115
  },
116
116
  };
117
117
  },
118
118
  get ref() {
119
- return new database.RefBuilder(apps_1.apps(), () => null, {});
119
+ return new database.RefBuilder((0, apps_1.apps)(), () => null, {});
120
120
  },
121
121
  };
122
122
  }
package/lib/index.js CHANGED
@@ -64,4 +64,4 @@ __exportStar(require("./cloud-functions"), exports);
64
64
  __exportStar(require("./config"), exports);
65
65
  __exportStar(require("./function-builder"), exports);
66
66
  __exportStar(require("./function-configuration"), exports);
67
- setup_1.setup();
67
+ (0, setup_1.setup)();
@@ -6,7 +6,7 @@ const common_1 = require("./common");
6
6
  function patchedConsole(severity) {
7
7
  return function (data, ...args) {
8
8
  if (common_1.SUPPORTS_STRUCTURED_LOGS) {
9
- common_1.UNPATCHED_CONSOLE[common_1.CONSOLE_SEVERITY[severity]](JSON.stringify({ severity, message: util_1.format(data, ...args) }));
9
+ common_1.UNPATCHED_CONSOLE[common_1.CONSOLE_SEVERITY[severity]](JSON.stringify({ severity, message: (0, util_1.format)(data, ...args) }));
10
10
  return;
11
11
  }
12
12
  common_1.UNPATCHED_CONSOLE[common_1.CONSOLE_SEVERITY[severity]](data, ...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',
@@ -78,7 +78,7 @@ class UserBuilder {
78
78
  return this.onOperation(handler, 'user.delete');
79
79
  }
80
80
  onOperation(handler, eventType) {
81
- return cloud_functions_1.makeCloudFunction({
81
+ return (0, cloud_functions_1.makeCloudFunction)({
82
82
  handler,
83
83
  provider: exports.provider,
84
84
  eventType,
@@ -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,
@@ -310,7 +310,7 @@ class DataSnapshot {
310
310
  * However, accessing the key on the root URL of a Database will return `null`.
311
311
  */
312
312
  get key() {
313
- const last = _.last(path_1.pathParts(this._fullPath()));
313
+ const last = _.last((0, path_1.pathParts)(this._fullPath()));
314
314
  return !last || last === '' ? null : last;
315
315
  }
316
316
  /**
@@ -325,7 +325,7 @@ class DataSnapshot {
325
325
  * Array, string, number, boolean, or `null`).
326
326
  */
327
327
  val() {
328
- const parts = path_1.pathParts(this._childPath);
328
+ const parts = (0, path_1.pathParts)(this._childPath);
329
329
  const source = this._data;
330
330
  const node = _.cloneDeep(parts.length ? _.get(source, parts, null) : source);
331
331
  return this._checkAndConvertToArray(node);
@@ -493,7 +493,7 @@ class DataSnapshot {
493
493
  const dup = new DataSnapshot(this._data, undefined, this.app, this.instance);
494
494
  [dup._path, dup._childPath] = [this._path, this._childPath];
495
495
  if (childPath) {
496
- dup._childPath = path_1.joinPath(dup._childPath, childPath);
496
+ dup._childPath = (0, path_1.joinPath)(dup._childPath, childPath);
497
497
  }
498
498
  return dup;
499
499
  }
@@ -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,
@@ -1,11 +1,8 @@
1
1
  import * as express from 'express';
2
2
  import { HttpsFunction, Runnable } from '../cloud-functions';
3
- import * as common from '../common/providers/https';
3
+ import { CallableContext, FunctionsErrorCode, HttpsError, Request } from '../common/providers/https';
4
4
  import { DeploymentOptions } from '../function-configuration';
5
- export declare type Request = common.Request;
6
- export declare type CallableContext = common.CallableContext;
7
- export declare type FunctionsErrorCode = common.FunctionsErrorCode;
8
- export declare type HttpsError = common.HttpsError;
5
+ export { Request, CallableContext, FunctionsErrorCode, HttpsError };
9
6
  /**
10
7
  * Handle HTTP requests.
11
8
  * @param handler A function that takes a request and response object,
@@ -21,9 +21,11 @@
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._onCallWithOptions = exports._onRequestWithOptions = exports.onCall = exports.onRequest = void 0;
24
+ exports._onCallWithOptions = exports._onRequestWithOptions = exports.onCall = exports.onRequest = exports.HttpsError = void 0;
25
25
  const cloud_functions_1 = require("../cloud-functions");
26
- const common = require("../common/providers/https");
26
+ const encoding_1 = require("../common/encoding");
27
+ const https_1 = require("../common/providers/https");
28
+ Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
27
29
  /**
28
30
  * Handle HTTP requests.
29
31
  * @param handler A function that takes a request and response object,
@@ -48,19 +50,24 @@ function _onRequestWithOptions(handler, options) {
48
50
  return handler(req, res);
49
51
  };
50
52
  cloudFunction.__trigger = {
51
- ...cloud_functions_1.optionsToTrigger(options),
53
+ ...(0, cloud_functions_1.optionsToTrigger)(options),
52
54
  httpsTrigger: {},
53
55
  };
56
+ (0, encoding_1.convertIfPresent)(cloudFunction.__trigger.httpsTrigger, options, 'invoker', 'invoker', encoding_1.convertInvoker);
54
57
  // TODO parse the options
55
58
  return cloudFunction;
56
59
  }
57
60
  exports._onRequestWithOptions = _onRequestWithOptions;
58
61
  /** @hidden */
59
62
  function _onCallWithOptions(handler, options) {
60
- const func = common.onCallHandler({ origin: true, methods: 'POST' }, handler);
63
+ // onCallHandler sniffs the function length of the passed-in callback
64
+ // and the user could have only tried to listen to data. Wrap their handler
65
+ // in another handler to avoid accidentally triggering the v2 API
66
+ const fixedLen = (data, context) => handler(data, context);
67
+ const func = (0, https_1.onCallHandler)({ origin: true, methods: 'POST' }, fixedLen);
61
68
  func.__trigger = {
62
69
  labels: {},
63
- ...cloud_functions_1.optionsToTrigger(options),
70
+ ...(0, cloud_functions_1.optionsToTrigger)(options),
64
71
  httpsTrigger: {},
65
72
  };
66
73
  func.__trigger.labels['deployment-callable'] = 'true';
@@ -71,7 +71,7 @@ class TopicBuilder {
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,
@@ -140,7 +140,7 @@ class ScheduleBuilder {
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,
@@ -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,
@@ -57,7 +57,7 @@ class TestMatrixBuilder {
57
57
  const dataConstructor = (raw) => {
58
58
  return new TestMatrix(raw.data);
59
59
  };
60
- return cloud_functions_1.makeCloudFunction({
60
+ return (0, cloud_functions_1.makeCloudFunction)({
61
61
  provider: exports.PROVIDER,
62
62
  eventType: exports.TEST_MATRIX_COMPLETE_EVENT_TYPE,
63
63
  triggerResource: this.triggerResource,
package/lib/setup.js CHANGED
@@ -31,7 +31,7 @@ function setup() {
31
31
  // Until the Cloud Functions builder can publish FIREBASE_CONFIG, automatically provide it on import based on what
32
32
  // we can deduce.
33
33
  if (!process.env.FIREBASE_CONFIG) {
34
- const cfg = config_1.firebaseConfig();
34
+ const cfg = (0, config_1.firebaseConfig)();
35
35
  if (cfg) {
36
36
  process.env.FIREBASE_CONFIG = JSON.stringify(cfg);
37
37
  }
@@ -43,7 +43,7 @@ function setup() {
43
43
  // If FIREBASE_CONFIG is still not found, try using GCLOUD_PROJECT to estimate
44
44
  if (!process.env.FIREBASE_CONFIG) {
45
45
  if (process.env.GCLOUD_PROJECT) {
46
- logger_1.warn('Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail');
46
+ (0, logger_1.warn)('Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail');
47
47
  process.env.FIREBASE_CONFIG = JSON.stringify({
48
48
  databaseURL: process.env.DATABASE_URL ||
49
49
  `https://${process.env.GCLOUD_PROJECT}.firebaseio.com`,
@@ -53,7 +53,7 @@ function setup() {
53
53
  });
54
54
  }
55
55
  else {
56
- logger_1.warn('Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail');
56
+ (0, logger_1.warn)('Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail');
57
57
  }
58
58
  }
59
59
  }
package/lib/v2/options.js CHANGED
@@ -107,22 +107,21 @@ exports.getGlobalOptions = getGlobalOptions;
107
107
  */
108
108
  function optionsToTriggerAnnotations(opts) {
109
109
  const annotation = {};
110
- encoding_2.copyIfPresent(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
111
- encoding_2.convertIfPresent(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
110
+ (0, encoding_2.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
111
+ (0, encoding_2.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
112
112
  return MemoryOptionToMB[mem];
113
113
  });
114
- encoding_2.convertIfPresent(annotation, opts, 'regions', 'region', (region) => {
114
+ (0, encoding_2.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
115
115
  if (typeof region === 'string') {
116
116
  return [region];
117
117
  }
118
118
  return region;
119
119
  });
120
- encoding_2.convertIfPresent(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
121
- encoding_2.convertIfPresent(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
122
- encoding_2.convertIfPresent(annotation, opts, 'failurePolicy', 'retry', (retry) => {
120
+ (0, encoding_2.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
121
+ (0, encoding_2.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
122
+ (0, encoding_2.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
123
123
  return retry ? { retry: true } : null;
124
124
  });
125
- encoding_2.convertIfPresent(annotation, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
126
125
  return annotation;
127
126
  }
128
127
  exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
@@ -1,13 +1,10 @@
1
1
  import * as express from 'express';
2
- import * as common from '../../common/providers/https';
2
+ import { CallableRequest, FunctionsErrorCode, HttpsError, Request } from '../../common/providers/https';
3
3
  import * as options from '../options';
4
- export declare type Request = common.Request;
5
- export declare type CallableRequest<T = any> = common.CallableRequest<T>;
6
- export declare type FunctionsErrorCode = common.FunctionsErrorCode;
7
- export declare type HttpsError = common.HttpsError;
4
+ export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
8
5
  export interface HttpsOptions extends Omit<options.GlobalOptions, 'region'> {
9
6
  region?: options.SupportedRegion | string | Array<options.SupportedRegion | string>;
10
- cors?: string | boolean;
7
+ cors?: string | boolean | RegExp | (string | RegExp)[];
11
8
  }
12
9
  export declare type HttpsFunction = ((req: Request, res: express.Response) => void | Promise<void>) & {
13
10
  __trigger: unknown;
@@ -21,9 +21,11 @@
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.onCall = exports.onRequest = void 0;
24
+ exports.onCall = exports.onRequest = exports.HttpsError = void 0;
25
25
  const cors = require("cors");
26
- const common = require("../../common/providers/https");
26
+ const encoding_1 = require("../../common/encoding");
27
+ const https_1 = require("../../common/providers/https");
28
+ Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
27
29
  const options = require("../options");
28
30
  function onRequest(optsOrHandler, handler) {
29
31
  let opts;
@@ -51,7 +53,7 @@ function onRequest(optsOrHandler, handler) {
51
53
  // global options calls region a scalar and https allows it to be an array,
52
54
  // but optionsToTriggerAnnotations handles both cases.
53
55
  const specificOpts = options.optionsToTriggerAnnotations(opts);
54
- return {
56
+ const trigger = {
55
57
  // TODO(inlined): Remove "apiVersion" once the latest version of the CLI
56
58
  // has migrated to "platform".
57
59
  apiVersion: 2,
@@ -66,6 +68,8 @@ function onRequest(optsOrHandler, handler) {
66
68
  allowInsecure: false,
67
69
  },
68
70
  };
71
+ (0, encoding_1.convertIfPresent)(trigger.httpsTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
72
+ return trigger;
69
73
  },
70
74
  });
71
75
  return handler;
@@ -81,7 +85,10 @@ function onCall(optsOrHandler, handler) {
81
85
  opts = optsOrHandler;
82
86
  }
83
87
  const origin = 'cors' in opts ? opts.cors : true;
84
- const func = common.onCallHandler({ origin, methods: 'POST' }, handler);
88
+ // onCallHandler sniffs the function length to determine which API to present.
89
+ // fix the length to prevent api versions from being mismatched.
90
+ const fixedLen = (req) => handler(req);
91
+ const func = (0, https_1.onCallHandler)({ origin, methods: 'POST' }, fixedLen);
85
92
  Object.defineProperty(func, '__trigger', {
86
93
  get: () => {
87
94
  const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-functions",
3
- "version": "3.15.2",
3
+ "version": "3.15.6",
4
4
  "description": "Firebase SDK for Cloud Functions",
5
5
  "keywords": [
6
6
  "firebase",
@@ -25,12 +25,29 @@
25
25
  "types": "lib/index.d.ts",
26
26
  "exports": {
27
27
  ".": "./lib/index.js",
28
- "./lib/providers/https": "./lib/v1/providers/https.js",
29
- "./v1": "./lib/v1/index.js",
30
- "./logger": "./lib/logger/index.js",
31
28
  "./logger/compat": "./lib/logger/compat.js",
32
- "./lib/logger": "./lib/logger/index.js",
33
29
  "./lib/logger/compat": "./lib/logger/compat.js",
30
+ "./logger": "./lib/logger/index.js",
31
+ "./lib/logger": "./lib/logger/index.js",
32
+ "./lib/providers/auth": "./lib/providers/auth.js",
33
+ "./lib/providers/analytics": "./lib/providers/analytics.js",
34
+ "./lib/providers/database": "./lib/providers/database.js",
35
+ "./lib/providers/firestore": "./lib/providers/firestore.js",
36
+ "./lib/providers/https": "./lib/providers/https.js",
37
+ "./lib/providers/pubsub": "./lib/providers/pubsub.js",
38
+ "./lib/providers/remoteConfig": "./lib/providers/remoteConfig.js",
39
+ "./lib/providers/storage": "./lib/providers/storage.js",
40
+ "./lib/providers/testLab": "./lib/providers/testLab.js",
41
+ "./v1": "./lib/index.js",
42
+ "./v1/analytics": "./lib/providers/analytics.js",
43
+ "./v1/auth": "./lib/providers/auth.js",
44
+ "./v1/database": "./lib/providers/database.js",
45
+ "./v1/firestore": "./lib/providers/firestore.js",
46
+ "./v1/https": "./lib/providers/https.js",
47
+ "./v1/pubsub": "./lib/providers/pubsub.js",
48
+ "./v1/remoteConfig": "./lib/providers/remoteConfig.js",
49
+ "./v1/storage": "./lib/providers/storage.js",
50
+ "./v1/testLab": "./lib/providers/testLab.js",
34
51
  "./v2": "./lib/v2/index.js",
35
52
  "./v2/core": "./lib/v2/core.js",
36
53
  "./v2/options": "./lib/v2/options.js",
@@ -47,7 +64,34 @@
47
64
  "lib/logger/compat"
48
65
  ],
49
66
  "v1": [
50
- "lib/v1"
67
+ "lib"
68
+ ],
69
+ "v1/analytics": [
70
+ "lib/providers/analytics"
71
+ ],
72
+ "v1/auth": [
73
+ "lib/providers/auth"
74
+ ],
75
+ "v1/database": [
76
+ "lib/providers/database"
77
+ ],
78
+ "v1/firestore": [
79
+ "lib/providers/firestore"
80
+ ],
81
+ "v1/https": [
82
+ "lib/providers/https"
83
+ ],
84
+ "v1/pubsub": [
85
+ "lib/providers/pubsub"
86
+ ],
87
+ "v1/remoteConfig": [
88
+ "lib/providers/remoteConfig"
89
+ ],
90
+ "v1/storage": [
91
+ "lib/providers/storage"
92
+ ],
93
+ "v1/testLab": [
94
+ "lib/providers/testLab"
51
95
  ],
52
96
  "v2": [
53
97
  "lib/v2"