firebase-functions 4.0.2 → 4.1.0

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.
@@ -135,6 +135,11 @@ export declare abstract class Param<T extends string | number | boolean | string
135
135
  /** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
136
136
  lessThan(rhs: T | Expression<T>): CompareExpression<T>;
137
137
  /** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
138
+ lessThanOrEqualTo(rhs: T | Expression<T>): CompareExpression<T>;
139
+ /**
140
+ * Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression.
141
+ * @deprecated A typo. Use lessThanOrEqualTo instead.
142
+ */
138
143
  lessThanorEqualTo(rhs: T | Expression<T>): CompareExpression<T>;
139
144
  toString(): string;
140
145
  }
@@ -164,9 +164,16 @@ class Param extends Expression {
164
164
  return this.cmp("<", rhs);
165
165
  }
166
166
  /** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */
167
- lessThanorEqualTo(rhs) {
167
+ lessThanOrEqualTo(rhs) {
168
168
  return this.cmp("<=", rhs);
169
169
  }
170
+ /**
171
+ * Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression.
172
+ * @deprecated A typo. Use lessThanOrEqualTo instead.
173
+ */
174
+ lessThanorEqualTo(rhs) {
175
+ return this.lessThanOrEqualTo(rhs);
176
+ }
170
177
  toString() {
171
178
  return `params.${this.name}`;
172
179
  }
@@ -9,6 +9,7 @@ import { WireParamSpec } from "../params/types";
9
9
  export interface ManifestEndpoint {
10
10
  entryPoint?: string;
11
11
  region?: string[];
12
+ omit?: boolean | Expression<boolean>;
12
13
  platform?: string;
13
14
  availableMemoryMb?: number | Expression<number> | ResetValue;
14
15
  maxInstances?: number | Expression<number> | ResetValue;
@@ -101,17 +101,17 @@ const RESETTABLE_RATE_LIMITS_OPTIONS = {
101
101
  * @internal
102
102
  */
103
103
  function initTaskQueueTrigger(...opts) {
104
- let taskQueueTrigger = {};
104
+ const taskQueueTrigger = {
105
+ retryConfig: {},
106
+ rateLimits: {},
107
+ };
105
108
  if (opts.every((opt) => !(opt === null || opt === void 0 ? void 0 : opt.preserveExternalChanges))) {
106
- const retryConfig = {};
107
109
  for (const key of Object.keys(RESETTABLE_RETRY_CONFIG_OPTIONS)) {
108
- retryConfig[key] = options_1.RESET_VALUE;
110
+ taskQueueTrigger.retryConfig[key] = options_1.RESET_VALUE;
109
111
  }
110
- const rateLimits = {};
111
112
  for (const key of Object.keys(RESETTABLE_RATE_LIMITS_OPTIONS)) {
112
- rateLimits[key] = options_1.RESET_VALUE;
113
+ taskQueueTrigger.rateLimits[key] = options_1.RESET_VALUE;
113
114
  }
114
- taskQueueTrigger = { retryConfig, rateLimits };
115
115
  }
116
116
  return taskQueueTrigger;
117
117
  }
@@ -131,13 +131,15 @@ const RESETTABLE_V2_SCHEDULE_OPTIONS = {
131
131
  maxBackoffSeconds: null,
132
132
  };
133
133
  function initScheduleTrigger(resetOptions, schedule, ...opts) {
134
- let scheduleTrigger = { schedule };
134
+ let scheduleTrigger = {
135
+ schedule,
136
+ retryConfig: {},
137
+ };
135
138
  if (opts.every((opt) => !(opt === null || opt === void 0 ? void 0 : opt.preserveExternalChanges))) {
136
- const retryConfig = {};
137
139
  for (const key of Object.keys(resetOptions)) {
138
- retryConfig[key] = options_1.RESET_VALUE;
140
+ scheduleTrigger.retryConfig[key] = options_1.RESET_VALUE;
139
141
  }
140
- scheduleTrigger = { ...scheduleTrigger, timeZone: options_1.RESET_VALUE, retryConfig };
142
+ scheduleTrigger = { ...scheduleTrigger, timeZone: options_1.RESET_VALUE };
141
143
  }
142
144
  return scheduleTrigger;
143
145
  }
@@ -224,7 +224,7 @@ function optionsToTrigger(options) {
224
224
  exports.optionsToTrigger = optionsToTrigger;
225
225
  function optionsToEndpoint(options) {
226
226
  const endpoint = {};
227
- (0, encoding_1.copyIfPresent)(endpoint, options, "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds");
227
+ (0, encoding_1.copyIfPresent)(endpoint, options, "omit", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds");
228
228
  (0, encoding_1.convertIfPresent)(endpoint, options, "region", "regions");
229
229
  (0, encoding_1.convertIfPresent)(endpoint, options, "serviceAccountEmail", "serviceAccount", (sa) => sa);
230
230
  (0, encoding_1.convertIfPresent)(endpoint, options, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof types_1.SecretParam ? secret.name : secret })));
@@ -172,11 +172,25 @@ export interface RuntimeOptions {
172
172
  * When false, requests with invalid tokens set context.app to undefiend.
173
173
  */
174
174
  enforceAppCheck?: boolean;
175
+ /**
176
+ * Controls whether function configuration modified outside of function source is preserved. Defaults to false.
177
+ *
178
+ * @remarks
179
+ * When setting configuration available in the underlying platform that is not yet available in the Firebase Functions
180
+ * SDK, we highly recommend setting `preserveExternalChanges` to `true`. Otherwise, when the Firebase Functions SDK releases
181
+ * a new version of the SDK with support for the missing configuration, your function's manually configured setting
182
+ * may inadvertently be wiped out.
183
+ */
184
+ preserveExternalChanges?: boolean;
175
185
  }
176
186
  /**
177
187
  * Configuration options for a function that applies during function deployment.
178
188
  */
179
189
  export interface DeploymentOptions extends RuntimeOptions {
190
+ /**
191
+ * If true, do not deploy or emulate this function.
192
+ */
193
+ omit?: boolean | Expression<boolean>;
180
194
  /**
181
195
  * Regions where function should be deployed.
182
196
  */
@@ -185,14 +199,4 @@ export interface DeploymentOptions extends RuntimeOptions {
185
199
  * Schedule for the scheduled function.
186
200
  */
187
201
  schedule?: Schedule;
188
- /**
189
- * Controls whether function configuration modified outside of function source is preserved. Defaults to false.
190
- *
191
- * @remarks
192
- * When setting configuration available in the underlying platform that is not yet available in the Firebase Functions
193
- * SDK, we highly recommend setting `preserveExternalChanges` to `true`. Otherwise, when the Firebase Functions SDK releases
194
- * a new version of the SDK with support for the missing configuration, your function's manually configured setting
195
- * may inadvertently be wiped out.
196
- */
197
- preserveExternalChanges?: boolean;
198
202
  }
@@ -41,6 +41,7 @@ class TaskQueueBuilder {
41
41
  * @returns A function you can export and deploy.
42
42
  */
43
43
  onDispatch(handler) {
44
+ var _a, _b;
44
45
  // onEnqueueHandler sniffs the function length of the passed-in callback
45
46
  // and the user could have only tried to listen to data. Wrap their handler
46
47
  // in another handler to avoid accidentally triggering the v2 API
@@ -59,8 +60,8 @@ class TaskQueueBuilder {
59
60
  ...(0, cloud_functions_1.optionsToEndpoint)(this.depOpts),
60
61
  taskQueueTrigger: (0, manifest_1.initTaskQueueTrigger)(this.depOpts),
61
62
  };
62
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "retryConfig");
63
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "rateLimits");
63
+ (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.retryConfig, ((_a = this.tqOpts) === null || _a === void 0 ? void 0 : _a.retryConfig) || {}, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
64
+ (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.rateLimits, ((_b = this.tqOpts) === null || _b === void 0 ? void 0 : _b.rateLimits) || {}, "maxConcurrentDispatches", "maxDispatchesPerSecond");
64
65
  (0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, this.tqOpts, "invoker", "invoker", encoding_1.convertInvoker);
65
66
  func.__requiredAPIs = [
66
67
  {
@@ -23,6 +23,10 @@ export declare type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLO
23
23
  * These options are common to HTTPS and Event handling functions.
24
24
  */
25
25
  export interface GlobalOptions {
26
+ /**
27
+ * If true, do not deploy or emulate this function.
28
+ */
29
+ omit?: boolean | Expression<boolean>;
26
30
  /**
27
31
  * Region where functions should be deployed.
28
32
  */
package/lib/v2/options.js CHANGED
@@ -95,7 +95,7 @@ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
95
95
  */
96
96
  function optionsToEndpoint(opts) {
97
97
  const endpoint = {};
98
- (0, encoding_1.copyIfPresent)(endpoint, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
98
+ (0, encoding_1.copyIfPresent)(endpoint, opts, "omit", "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
99
99
  (0, encoding_1.convertIfPresent)(endpoint, opts, "serviceAccountEmail", "serviceAccount");
100
100
  if (opts.vpcConnector !== undefined) {
101
101
  if (opts.vpcConnector === null || opts.vpcConnector instanceof options_1.ResetValue) {
@@ -40,6 +40,10 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
40
40
  alertType: AlertType;
41
41
  /** Scope the function to trigger on a specific application. */
42
42
  appId?: string;
43
+ /**
44
+ * If true, do not deploy or emulate this function.
45
+ */
46
+ omit?: boolean | Expression<boolean>;
43
47
  /**
44
48
  * Region where functions should be deployed.
45
49
  */
@@ -63,6 +63,10 @@ export interface AppDistributionEvent<T> extends CloudEvent<FirebaseAlertData<T>
63
63
  export interface AppDistributionOptions extends options.EventHandlerOptions {
64
64
  /** Scope the function to trigger on a specific application. */
65
65
  appId?: string;
66
+ /**
67
+ * If true, do not deploy or emulate this function.
68
+ */
69
+ omit?: boolean | Expression<boolean>;
66
70
  /**
67
71
  * Region where functions should be deployed.
68
72
  */
@@ -129,6 +129,10 @@ export interface CrashlyticsEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
129
129
  export interface CrashlyticsOptions extends options.EventHandlerOptions {
130
130
  /** Scope the function to trigger on a specific application. */
131
131
  appId?: string;
132
+ /**
133
+ * If true, do not deploy or emulate this function.
134
+ */
135
+ omit?: boolean | Expression<boolean>;
132
136
  /**
133
137
  * Region where functions should be deployed.
134
138
  */
@@ -51,6 +51,10 @@ export interface ReferenceOptions<Ref extends string = string> extends options.E
51
51
  * Note: The capture syntax cannot be used for 'instance'.
52
52
  */
53
53
  instance?: string;
54
+ /**
55
+ * If true, do not deploy or emulate this function.
56
+ */
57
+ omit?: boolean | Expression<boolean>;
54
58
  /**
55
59
  * Region where functions should be deployed.
56
60
  */
@@ -28,6 +28,10 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions {
28
28
  * Eventarc event exact match filter.
29
29
  */
30
30
  filters?: Record<string, string>;
31
+ /**
32
+ * If true, do not deploy or emulate this function.
33
+ */
34
+ omit?: boolean | Expression<boolean>;
31
35
  /**
32
36
  * Region where functions should be deployed.
33
37
  */
@@ -11,6 +11,10 @@ export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
11
11
  * Options that can be set on an onRequest HTTPS function.
12
12
  */
13
13
  export interface HttpsOptions extends Omit<GlobalOptions, "region"> {
14
+ /**
15
+ * If true, do not deploy or emulate this function.
16
+ */
17
+ omit?: boolean | Expression<boolean>;
14
18
  /** HTTP functions can override global options and can specify multiple regions to deploy to. */
15
19
  region?: SupportedRegion | string | Array<SupportedRegion | string>;
16
20
  /** If true, allows CORS on requests to this function.
@@ -26,6 +26,10 @@ export interface BlockingOptions {
26
26
  accessToken?: boolean;
27
27
  /** Pass the Refresh Token credential to the function. */
28
28
  refreshToken?: boolean;
29
+ /**
30
+ * If true, do not deploy or emulate this function.
31
+ */
32
+ omit?: boolean | Expression<boolean>;
29
33
  /**
30
34
  * Region where functions should be deployed.
31
35
  */
@@ -84,6 +84,10 @@ export interface MessagePublishedData<T = any> {
84
84
  export interface PubSubOptions extends options.EventHandlerOptions {
85
85
  /** The Pub/Sub topic to watch for message events */
86
86
  topic: string;
87
+ /**
88
+ * If true, do not deploy or emulate this function.
89
+ */
90
+ omit?: boolean | Expression<boolean>;
87
91
  /**
88
92
  * Region where functions should be deployed.
89
93
  */
@@ -38,11 +38,13 @@ function getOpts(args) {
38
38
  return {
39
39
  schedule: args.schedule,
40
40
  timeZone: args.timeZone,
41
- retryCount: args.retryCount,
42
- maxRetrySeconds: args.maxRetrySeconds,
43
- minBackoffSeconds: args.minBackoffSeconds,
44
- maxBackoffSeconds: args.maxBackoffSeconds,
45
- maxDoublings: args.maxDoublings,
41
+ retryConfig: {
42
+ retryCount: args.retryCount,
43
+ maxRetrySeconds: args.maxRetrySeconds,
44
+ minBackoffSeconds: args.minBackoffSeconds,
45
+ maxBackoffSeconds: args.maxBackoffSeconds,
46
+ maxDoublings: args.maxDoublings,
47
+ },
46
48
  opts: args,
47
49
  };
48
50
  }
@@ -87,7 +89,7 @@ function onSchedule(args, handler) {
87
89
  scheduleTrigger: (0, manifest_1.initV2ScheduleTrigger)(separatedOpts.schedule, globalOpts, separatedOpts.opts),
88
90
  };
89
91
  (0, encoding_1.copyIfPresent)(ep.scheduleTrigger, separatedOpts, "timeZone");
90
- (0, encoding_1.copyIfPresent)(ep.scheduleTrigger.retryConfig, separatedOpts, "retryCount", "maxRetrySeconds", "minBackoffSeconds", "maxBackoffSeconds", "maxDoublings");
92
+ (0, encoding_1.copyIfPresent)(ep.scheduleTrigger.retryConfig, separatedOpts.retryConfig, "retryCount", "maxRetrySeconds", "minBackoffSeconds", "maxBackoffSeconds", "maxDoublings");
91
93
  func.__endpoint = ep;
92
94
  func.__requiredAPIs = [
93
95
  {
@@ -160,6 +160,10 @@ export interface StorageEvent extends CloudEvent<StorageObjectData> {
160
160
  export interface StorageOptions extends options.EventHandlerOptions {
161
161
  /** The name of the bucket containing this object. */
162
162
  bucket?: string;
163
+ /**
164
+ * If true, do not deploy or emulate this function.
165
+ */
166
+ omit?: boolean | Expression<boolean>;
163
167
  /**
164
168
  * Region where functions should be deployed.
165
169
  */
@@ -19,6 +19,10 @@ export interface TaskQueueOptions extends options.EventHandlerOptions {
19
19
  * will have permissions.
20
20
  */
21
21
  invoker?: "private" | string | string[];
22
+ /**
23
+ * If true, do not deploy or emulate this function.
24
+ */
25
+ omit?: boolean | Expression<boolean>;
22
26
  /**
23
27
  * Region where functions should be deployed.
24
28
  */
@@ -80,8 +80,8 @@ function onTaskDispatched(optsOrHandler, handler) {
80
80
  },
81
81
  taskQueueTrigger: (0, manifest_1.initTaskQueueTrigger)(options.getGlobalOptions(), opts),
82
82
  };
83
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, opts, "retryConfig");
84
- (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, opts, "rateLimits");
83
+ (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.retryConfig, opts.retryConfig, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
84
+ (0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.rateLimits, opts.rateLimits, "maxConcurrentDispatches", "maxDispatchesPerSecond");
85
85
  (0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
86
86
  func.__requiredAPIs = [
87
87
  {
@@ -22,6 +22,7 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.onTestMatrixCompleted = exports.eventType = void 0;
25
+ const manifest_1 = require("../../runtime/manifest");
25
26
  const options_1 = require("../options");
26
27
  const trace_1 = require("../trace");
27
28
  /** @internal */
@@ -46,6 +47,7 @@ function onTestMatrixCompleted(optsOrHandler, handler) {
46
47
  };
47
48
  func.run = handler;
48
49
  const ep = {
50
+ ...(0, manifest_1.initV2Endpoint)((0, options_1.getGlobalOptions)(), optsOrHandler),
49
51
  platform: "gcfv2",
50
52
  ...baseOpts,
51
53
  ...specificOpts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-functions",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "Firebase SDK for Cloud Functions",
5
5
  "keywords": [
6
6
  "firebase",