firebase-functions 7.1.1 → 7.2.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.
@@ -1,5 +1,5 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.mjs";
2
- import { BUCKET_PICKER, BooleanParam, Expression, FloatParam, IntParam, InternalExpression, JsonSecretParam, ListParam, SecretParam, StringParam, multiSelect, select } from "./types.mjs";
2
+ import { BUCKET_PICKER, BooleanParam, Expression, FloatParam, IntParam, InternalExpression, InterpolationExpression, JsonSecretParam, ListParam, SecretParam, StringParam, multiSelect, select } from "./types.mjs";
3
3
 
4
4
  //#region src/params/index.ts
5
5
  var params_exports = /* @__PURE__ */ __export({
@@ -15,6 +15,7 @@ var params_exports = /* @__PURE__ */ __export({
15
15
  defineList: () => defineList,
16
16
  defineSecret: () => defineSecret,
17
17
  defineString: () => defineString,
18
+ expr: () => expr,
18
19
  gcloudProject: () => gcloudProject,
19
20
  multiSelect: () => multiSelect,
20
21
  projectID: () => projectID,
@@ -59,23 +60,23 @@ function clearParams() {
59
60
  * A built-in parameter that resolves to the default RTDB database URL associated
60
61
  * with the project, without prompting the deployer. Empty string if none exists.
61
62
  */
62
- const databaseURL = new InternalExpression("DATABASE_URL", (env) => JSON.parse(env.FIREBASE_CONFIG)?.databaseURL || "");
63
+ const databaseURL = new InternalExpression("DATABASE_URL", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.databaseURL || "");
63
64
  /**
64
65
  * A built-in parameter that resolves to the Cloud project ID associated with
65
66
  * the project, without prompting the deployer.
66
67
  */
67
- const projectID = new InternalExpression("PROJECT_ID", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
68
+ const projectID = new InternalExpression("PROJECT_ID", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.projectId || "");
68
69
  /**
69
70
  * A built-in parameter that resolves to the Cloud project ID, without prompting
70
71
  * the deployer.
71
72
  */
72
- const gcloudProject = new InternalExpression("GCLOUD_PROJECT", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
73
+ const gcloudProject = new InternalExpression("GCLOUD_PROJECT", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.projectId || "");
73
74
  /**
74
75
  * A builtin parameter that resolves to the Cloud storage bucket associated
75
76
  * with the function, without prompting the deployer. Empty string if not
76
77
  * defined.
77
78
  */
78
- const storageBucket = new InternalExpression("STORAGE_BUCKET", (env) => JSON.parse(env.FIREBASE_CONFIG)?.storageBucket || "");
79
+ const storageBucket = new InternalExpression("STORAGE_BUCKET", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.storageBucket || "");
79
80
  /**
80
81
  * Declares a secret param, that will persist values only in Cloud Secret Manager.
81
82
  * Secrets are stored internally as bytestrings. Use `ParamOptions.as` to provide type
@@ -84,8 +85,8 @@ const storageBucket = new InternalExpression("STORAGE_BUCKET", (env) => JSON.par
84
85
  * @param name The name of the environment variable to use to load the parameter.
85
86
  * @returns A parameter with a `string` return type for `.value`.
86
87
  */
87
- function defineSecret(name) {
88
- const param = new SecretParam(name);
88
+ function defineSecret(name, options = {}) {
89
+ const param = new SecretParam(name, options);
89
90
  registerParam(param);
90
91
  return param;
91
92
  }
@@ -101,8 +102,8 @@ function defineSecret(name) {
101
102
  * @returns A parameter whose `.value()` method returns the parsed JSON object.
102
103
  * ```
103
104
  */
104
- function defineJsonSecret(name) {
105
- const param = new JsonSecretParam(name);
105
+ function defineJsonSecret(name, options = {}) {
106
+ const param = new JsonSecretParam(name, options);
106
107
  registerParam(param);
107
108
  return param;
108
109
  }
@@ -168,6 +169,19 @@ function defineList(name, options = {}) {
168
169
  registerParam(param);
169
170
  return param;
170
171
  }
172
+ /**
173
+ * Creates an Expression representing a string, which can interpolate
174
+ * other Expressions into it using template literal syntax.
175
+ *
176
+ * @example
177
+ * ```
178
+ * const topicParam = defineString('TOPIC');
179
+ * const topicExpr = expr`projects/my-project/topics/${topicParam}`;
180
+ * ```
181
+ */
182
+ function expr(strings, ...values) {
183
+ return new InterpolationExpression(strings, values);
184
+ }
171
185
 
172
186
  //#endregion
173
- export { BUCKET_PICKER, Expression, clearParams, databaseURL, declaredParams, defineBoolean, defineFloat, defineInt, defineJsonSecret, defineList, defineSecret, defineString, gcloudProject, multiSelect, params_exports, projectID, select, storageBucket };
187
+ export { BUCKET_PICKER, Expression, clearParams, databaseURL, declaredParams, defineBoolean, defineFloat, defineInt, defineJsonSecret, defineList, defineSecret, defineString, expr, gcloudProject, multiSelect, params_exports, projectID, select, storageBucket };
@@ -37,9 +37,56 @@ var Expression = class {
37
37
  return this.toString();
38
38
  }
39
39
  };
40
+ /**
41
+ * An InterpolationExpression allows string fragments and Expressions to be
42
+ * joined natively into a new Expression block evaluating to a string string.
43
+ */
44
+ var InterpolationExpression = class extends Expression {
45
+ constructor(strings, values) {
46
+ super();
47
+ this.strings = strings;
48
+ this.values = values;
49
+ }
50
+ /** @internal */
51
+ runtimeValue() {
52
+ return this.strings.reduce((result, str, i) => {
53
+ const val = i < this.values.length ? String(valueOf(this.values[i])) : "";
54
+ return result + str + val;
55
+ }, "");
56
+ }
57
+ toCEL() {
58
+ return this.strings.reduce((result, str, i) => {
59
+ const val = i < this.values.length ? celOf(this.values[i]) : "";
60
+ return result + str + val;
61
+ }, "");
62
+ }
63
+ };
64
+ /** @internal */
65
+ var TransformedStringExpression = class extends Expression {
66
+ constructor(source, transformer) {
67
+ super();
68
+ this.source = source;
69
+ this.transformer = transformer;
70
+ }
71
+ runtimeValue() {
72
+ return this.transformer(valueOf(this.source));
73
+ }
74
+ toCEL() {
75
+ return this.source instanceof Expression ? this.source.toCEL() : this.transformer(this.source);
76
+ }
77
+ };
40
78
  function valueOf(arg) {
41
79
  return arg instanceof Expression ? arg.runtimeValue() : arg;
42
80
  }
81
+ function celOf(arg) {
82
+ return arg instanceof Expression ? arg.toCEL() : arg;
83
+ }
84
+ /**
85
+ * Transforms a string or a string expression using a function.
86
+ */
87
+ function transform(source, transformer) {
88
+ return new TransformedStringExpression(source, transformer);
89
+ }
43
90
  /**
44
91
  * Returns how an entity (either an `Expression` or a literal value) should be represented in CEL.
45
92
  * - Expressions delegate to the `.toString()` method, which is used by the WireManifest
@@ -91,7 +138,7 @@ var CompareExpression = class extends Expression {
91
138
  }
92
139
  /** @internal */
93
140
  runtimeValue() {
94
- const left = this.lhs.runtimeValue();
141
+ const left = valueOf(this.lhs);
95
142
  const right = valueOf(this.rhs);
96
143
  switch (this.cmp) {
97
144
  case "==": return Array.isArray(left) ? this.arrayEquals(left, right) : left === right;
@@ -108,8 +155,7 @@ var CompareExpression = class extends Expression {
108
155
  return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
109
156
  }
110
157
  toString() {
111
- const rhsStr = refOf(this.rhs);
112
- return `${this.lhs} ${this.cmp} ${rhsStr}`;
158
+ return `${refOf(this.lhs)} ${this.cmp} ${refOf(this.rhs)}`;
113
159
  }
114
160
  /** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */
115
161
  thenElse(ifTrue, ifFalse) {
@@ -231,7 +277,8 @@ var SecretParam = class {
231
277
  static {
232
278
  this.type = "secret";
233
279
  }
234
- constructor(name) {
280
+ constructor(name, options = {}) {
281
+ this.options = options;
235
282
  this.name = name;
236
283
  }
237
284
  /** @internal */
@@ -246,7 +293,8 @@ var SecretParam = class {
246
293
  toSpec() {
247
294
  return {
248
295
  type: "secret",
249
- name: this.name
296
+ name: this.name,
297
+ ...this.options
250
298
  };
251
299
  }
252
300
  /** Returns the secret's value at runtime. Throws an error if accessed during deployment. */
@@ -268,7 +316,8 @@ var JsonSecretParam = class {
268
316
  static {
269
317
  this.type = "secret";
270
318
  }
271
- constructor(name) {
319
+ constructor(name, options = {}) {
320
+ this.options = options;
272
321
  this.name = name;
273
322
  }
274
323
  /** @internal */
@@ -288,6 +337,7 @@ var JsonSecretParam = class {
288
337
  return {
289
338
  type: "secret",
290
339
  name: this.name,
340
+ ...this.options,
291
341
  format: "json"
292
342
  };
293
343
  }
@@ -410,4 +460,4 @@ var ListParam = class extends Param {
410
460
  };
411
461
 
412
462
  //#endregion
413
- export { BUCKET_PICKER, BooleanParam, CompareExpression, Expression, FloatParam, IntParam, InternalExpression, JsonSecretParam, ListParam, Param, SecretParam, StringParam, TernaryExpression, multiSelect, select };
463
+ export { BUCKET_PICKER, BooleanParam, CompareExpression, Expression, FloatParam, IntParam, InternalExpression, InterpolationExpression, JsonSecretParam, ListParam, Param, SecretParam, StringParam, TernaryExpression, TransformedStringExpression, celOf, multiSelect, select, transform, valueOf };
@@ -1,4 +1,5 @@
1
1
  import { warn } from "../logger/index.mjs";
2
+ import { Expression, celOf, valueOf } from "../params/types.mjs";
2
3
  import { RESET_VALUE, ResetValue } from "../common/options.mjs";
3
4
  import { initV1Endpoint, initV1ScheduleTrigger } from "../runtime/manifest.mjs";
4
5
  import { Change } from "../common/change.mjs";
@@ -55,10 +56,11 @@ function makeCloudFunction({ contextOnlyHandler, dataConstructor = (raw) => raw.
55
56
  if (triggerResource() == null) {
56
57
  return {};
57
58
  }
59
+ const tr = triggerResource();
58
60
  const trigger = {
59
61
  ...optionsToTrigger(options),
60
62
  eventTrigger: {
61
- resource: triggerResource(),
63
+ resource: celOf(tr),
62
64
  eventType: legacyEventType || provider + "." + eventType,
63
65
  service
64
66
  }
@@ -81,13 +83,16 @@ function makeCloudFunction({ contextOnlyHandler, dataConstructor = (raw) => raw.
81
83
  ...optionsToEndpoint(options)
82
84
  };
83
85
  if (options.schedule) {
84
- endpoint.scheduleTrigger = initV1ScheduleTrigger(options.schedule.schedule, options);
86
+ endpoint.scheduleTrigger = initV1ScheduleTrigger(celOf(options.schedule.schedule), options);
85
87
  copyIfPresent(endpoint.scheduleTrigger, options.schedule, "timeZone");
88
+ if (endpoint.scheduleTrigger.timeZone instanceof Expression) {
89
+ endpoint.scheduleTrigger.timeZone = endpoint.scheduleTrigger.timeZone.toCEL();
90
+ }
86
91
  copyIfPresent(endpoint.scheduleTrigger.retryConfig, options.schedule.retryConfig, "retryCount", "maxDoublings", "maxBackoffDuration", "maxRetryDuration", "minBackoffDuration");
87
92
  } else {
88
93
  endpoint.eventTrigger = {
89
94
  eventType: legacyEventType || provider + "." + eventType,
90
- eventFilters: { resource: triggerResource() },
95
+ eventFilters: { resource: celOf(triggerResource()) },
91
96
  retry: !!options.failurePolicy
92
97
  };
93
98
  }
@@ -110,7 +115,7 @@ function _makeParams(context, triggerResourceGetter) {
110
115
  if (!context.resource) {
111
116
  return {};
112
117
  }
113
- const triggerResource = triggerResourceGetter();
118
+ const triggerResource = valueOf(triggerResourceGetter());
114
119
  const wildcards = triggerResource.match(WILDCARD_REGEX);
115
120
  const params = {};
116
121
  const eventResourceParts = context?.resource?.name?.split?.("/");
@@ -1,4 +1,5 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { expr } from "../../params/index.mjs";
2
3
  import { makeCloudFunction } from "../cloud-functions.mjs";
3
4
 
4
5
  //#region src/v1/providers/analytics.ts
@@ -34,7 +35,7 @@ function _eventWithOptions(analyticsEventType, options) {
34
35
  if (!process.env.GCLOUD_PROJECT) {
35
36
  throw new Error("process.env.GCLOUD_PROJECT is not set.");
36
37
  }
37
- return "projects/" + process.env.GCLOUD_PROJECT + "/events/" + analyticsEventType;
38
+ return expr`projects/${process.env.GCLOUD_PROJECT}/events/${analyticsEventType}`;
38
39
  }, options);
39
40
  }
40
41
  /**
@@ -43,7 +44,7 @@ function _eventWithOptions(analyticsEventType, options) {
43
44
  * Access via `functions.analytics.event()`.
44
45
  */
45
46
  var AnalyticsEventBuilder = class {
46
- /** @hidden */
47
+ /** @internal */
47
48
  constructor(triggerResource, options) {
48
49
  this.triggerResource = triggerResource;
49
50
  this.options = options;
@@ -1,4 +1,6 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { transform } from "../../params/types.mjs";
3
+ import { expr } from "../../params/index.mjs";
2
4
  import { firebaseConfig } from "../../common/config.mjs";
3
5
  import { getApp } from "../../common/app.mjs";
4
6
  import { makeCloudFunction } from "../cloud-functions.mjs";
@@ -96,14 +98,14 @@ var InstanceBuilder = class {
96
98
  * @returns Firebase Realtime Database reference builder interface.
97
99
  */
98
100
  ref(path) {
99
- const normalized = normalizePath(path);
100
- return new RefBuilder(() => `projects/_/instances/${this.instance}/refs/${normalized}`, this.options);
101
+ const normalized = transform(path, normalizePath);
102
+ return new RefBuilder(() => expr`projects/_/instances/${this.instance}/refs/${normalized}`, this.options);
101
103
  }
102
104
  };
103
105
  /** @internal */
104
106
  function _refWithOptions(path, options) {
105
107
  const resourceGetter = () => {
106
- const normalized = normalizePath(path);
108
+ const normalized = transform(path, normalizePath);
107
109
  const databaseURL = firebaseConfig().databaseURL;
108
110
  if (!databaseURL) {
109
111
  throw new Error("Missing expected firebase config value databaseURL, " + "config is actually" + JSON.stringify(firebaseConfig()) + "\n If you are unit testing, please set process.env.FIREBASE_CONFIG");
@@ -121,7 +123,7 @@ function _refWithOptions(path, options) {
121
123
  if (!instance$1) {
122
124
  throw new Error("Invalid value for config firebase.databaseURL: " + databaseURL);
123
125
  }
124
- return `projects/_/instances/${instance$1}/refs/${normalized}`;
126
+ return expr`projects/_/instances/${instance$1}/refs/${normalized}`;
125
127
  };
126
128
  return new RefBuilder(resourceGetter, options);
127
129
  }
@@ -1,8 +1,9 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { CompareExpression, Expression } from "../../params/types.mjs";
3
+ import { expr, projectID } from "../../params/index.mjs";
2
4
  import { Change } from "../../common/change.mjs";
3
5
  import { makeCloudFunction } from "../cloud-functions.mjs";
4
6
  import { createBeforeSnapshotFromJson, createSnapshotFromJson } from "../../common/providers/firestore.mjs";
5
- import { posix } from "path";
6
7
 
7
8
  //#region src/v1/providers/firestore.ts
8
9
  var firestore_exports = /* @__PURE__ */ __export({
@@ -74,13 +75,23 @@ var NamespaceBuilder = class {
74
75
  this.namespace = namespace$1;
75
76
  }
76
77
  document(path) {
77
- return new DocumentBuilder(() => {
78
+ const triggerResource = () => {
78
79
  if (!process.env.GCLOUD_PROJECT) {
79
80
  throw new Error("process.env.GCLOUD_PROJECT is not set.");
80
81
  }
81
- const database$1 = posix.join("projects", process.env.GCLOUD_PROJECT, "databases", this.database);
82
- return posix.join(database$1, this.namespace ? `documents@${this.namespace}` : "documents", path);
83
- }, this.options);
82
+ let project = projectID;
83
+ if (process.env.GCLOUD_PROJECT && process.env.FUNCTIONS_CONTROL_API !== "true") {
84
+ project = process.env.GCLOUD_PROJECT;
85
+ }
86
+ let nsPart = "";
87
+ if (this.namespace instanceof Expression) {
88
+ nsPart = new CompareExpression("==", this.namespace, "").thenElse("", expr`@${this.namespace}`);
89
+ } else if (this.namespace) {
90
+ nsPart = `@${this.namespace}`;
91
+ }
92
+ return expr`projects/${project}/databases/${this.database}/documents${nsPart}/${path}`;
93
+ };
94
+ return new DocumentBuilder(triggerResource, this.options);
84
95
  }
85
96
  };
86
97
  function snapshotConstructor(event) {
@@ -93,6 +104,7 @@ function changeConstructor(raw) {
93
104
  return Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
94
105
  }
95
106
  var DocumentBuilder = class {
107
+ /** @internal */
96
108
  constructor(triggerResource, options) {
97
109
  this.triggerResource = triggerResource;
98
110
  this.options = options;
@@ -1,4 +1,6 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { Expression } from "../../params/types.mjs";
3
+ import { expr } from "../../params/index.mjs";
2
4
  import { makeCloudFunction } from "../cloud-functions.mjs";
3
5
 
4
6
  //#region src/v1/providers/pubsub.ts
@@ -29,15 +31,16 @@ function topic(topic$1) {
29
31
  }
30
32
  /** @internal */
31
33
  function _topicWithOptions(topic$1, options) {
32
- if (topic$1.indexOf("/") !== -1) {
34
+ if (typeof topic$1 === "string" && topic$1.indexOf("/") !== -1) {
33
35
  throw new Error("Topic name may not have a /");
34
36
  }
35
- return new TopicBuilder(() => {
37
+ const triggerResource = () => {
36
38
  if (!process.env.GCLOUD_PROJECT) {
37
39
  throw new Error("process.env.GCLOUD_PROJECT is not set.");
38
40
  }
39
- return `projects/${process.env.GCLOUD_PROJECT}/topics/${topic$1}`;
40
- }, options);
41
+ return expr`projects/${process.env.GCLOUD_PROJECT}/topics/${topic$1}`;
42
+ };
43
+ return new TopicBuilder(triggerResource, options);
41
44
  }
42
45
  /**
43
46
  * The Google Cloud Pub/Sub topic builder.
@@ -89,7 +92,7 @@ function _scheduleWithOptions(schedule$1, options) {
89
92
  };
90
93
  return new ScheduleBuilder(triggerResource, {
91
94
  ...options,
92
- schedule: { schedule: schedule$1 }
95
+ schedule: { schedule: schedule$1 instanceof Expression ? schedule$1.toCEL() : schedule$1 }
93
96
  });
94
97
  }
95
98
  /**
@@ -1,4 +1,5 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { expr } from "../../params/index.mjs";
2
3
  import { firebaseConfig } from "../../common/config.mjs";
3
4
  import { makeCloudFunction } from "../cloud-functions.mjs";
4
5
 
@@ -40,14 +41,14 @@ function object() {
40
41
  /** @internal */
41
42
  function _bucketWithOptions(options, bucket$1) {
42
43
  const resourceGetter = () => {
43
- bucket$1 = bucket$1 || firebaseConfig().storageBucket;
44
- if (!bucket$1) {
44
+ const bucketName = bucket$1 || firebaseConfig().storageBucket;
45
+ if (!bucketName) {
45
46
  throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" + " through `functions.storage.bucket(bucketName)`, or set process.env.FIREBASE_CONFIG.");
46
47
  }
47
- if (!/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket$1)) {
48
- throw new Error(`Invalid bucket name ${bucket$1}`);
48
+ if (typeof bucketName === "string" && !/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucketName)) {
49
+ throw new Error(`Invalid bucket name ${bucketName}`);
49
50
  }
50
- return `projects/_/buckets/${bucket$1}`;
51
+ return expr`projects/_/buckets/${bucketName}`;
51
52
  };
52
53
  return new BucketBuilder(resourceGetter, options);
53
54
  }
@@ -40,7 +40,15 @@ function getGlobalOptions() {
40
40
  */
41
41
  function optionsToTriggerAnnotations(opts) {
42
42
  const annotation = {};
43
- copyIfPresent(annotation, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "vpcConnector", "vpcConnectorEgressSettings", "secrets");
43
+ copyIfPresent(annotation, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "vpcConnector", "secrets");
44
+ const vpcEgress = opts.vpcEgress ?? opts.vpcConnectorEgressSettings;
45
+ if (vpcEgress !== undefined) {
46
+ if (vpcEgress === null || vpcEgress instanceof ResetValue) {
47
+ annotation.vpcConnectorEgressSettings = null;
48
+ } else {
49
+ annotation.vpcConnectorEgressSettings = vpcEgress;
50
+ }
51
+ }
44
52
  convertIfPresent(annotation, opts, "availableMemoryMb", "memory", (mem) => {
45
53
  return MemoryOptionToMB[mem];
46
54
  });
@@ -65,12 +73,33 @@ function optionsToEndpoint(opts) {
65
73
  const endpoint = {};
66
74
  copyIfPresent(endpoint, opts, "omit", "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
67
75
  convertIfPresent(endpoint, opts, "serviceAccountEmail", "serviceAccount");
68
- if (opts.vpcConnector !== undefined) {
69
- if (opts.vpcConnector === null || opts.vpcConnector instanceof ResetValue) {
76
+ if (opts.vpcEgress && opts.vpcConnectorEgressSettings) {
77
+ warn("vpcEgress and vpcConnectorEgressSettings are both set. Using vpcEgress");
78
+ }
79
+ const vpcEgress = opts.vpcEgress ?? opts.vpcConnectorEgressSettings;
80
+ const connector = opts.vpcConnector;
81
+ const networkInterface = opts.networkInterface;
82
+ if (connector !== undefined || vpcEgress !== undefined || networkInterface !== undefined) {
83
+ const resetConnector = connector === null || connector instanceof ResetValue;
84
+ const hasConnector = !!connector;
85
+ const resetNetwork = networkInterface === null || networkInterface instanceof ResetValue;
86
+ const hasNetwork = !!networkInterface && !resetNetwork;
87
+ if (hasNetwork) {
88
+ if (!networkInterface.network && !networkInterface.subnetwork) {
89
+ throw new Error("At least one of network or subnetwork must be specified in networkInterface.");
90
+ }
91
+ }
92
+ if (hasNetwork && hasConnector) {
93
+ throw new Error("Cannot set both vpcConnector and networkInterface");
94
+ } else if (resetConnector && !hasNetwork || resetNetwork && !hasConnector) {
70
95
  endpoint.vpc = RESET_VALUE;
71
96
  } else {
72
- const vpc = { connector: opts.vpcConnector };
73
- convertIfPresent(vpc, opts, "egressSettings", "vpcConnectorEgressSettings");
97
+ const vpc = {};
98
+ convertIfPresent(vpc, opts, "connector", "vpcConnector");
99
+ if (vpcEgress !== undefined) {
100
+ vpc.egressSettings = vpcEgress;
101
+ }
102
+ convertIfPresent(vpc, opts, "networkInterfaces", "networkInterface", (a) => [a]);
74
103
  endpoint.vpc = vpc;
75
104
  }
76
105
  }
@@ -106,9 +106,13 @@ function makeDatabaseEvent(event, data, instance, params) {
106
106
  ...event,
107
107
  firebaseDatabaseHost: event.firebasedatabasehost,
108
108
  data: snapshot,
109
- params
109
+ params,
110
+ authType: event.authtype || "unknown",
111
+ authId: event.authid
110
112
  };
111
113
  delete databaseEvent.firebasedatabasehost;
114
+ delete databaseEvent.authtype;
115
+ delete databaseEvent.authid;
112
116
  return databaseEvent;
113
117
  }
114
118
  /** @hidden */
@@ -122,9 +126,13 @@ function makeChangedDatabaseEvent(event, instance, params) {
122
126
  before,
123
127
  after
124
128
  },
125
- params
129
+ params,
130
+ authType: event.authtype || "unknown",
131
+ authId: event.authid
126
132
  };
127
133
  delete databaseEvent.firebasedatabasehost;
134
+ delete databaseEvent.authtype;
135
+ delete databaseEvent.authid;
128
136
  return databaseEvent;
129
137
  }
130
138
  /** @internal */
@@ -2,11 +2,11 @@
2
2
  * @hidden
3
3
  * @alpha
4
4
  */
5
- import { BooleanParam, Expression, IntParam, Param, ParamOptions, SecretParam, JsonSecretParam, StringParam, ListParam } from "./types";
5
+ import { BooleanParam, Expression, IntParam, Param, ParamOptions, SecretParam, JsonSecretParam, StringParam, ListParam, SecretParamOptions } from "./types";
6
6
  export { BUCKET_PICKER, select, multiSelect } from "./types";
7
7
  export type { TextInput, SelectInput, SelectOptions, MultiSelectInput, Param, SecretParam, JsonSecretParam, StringParam, BooleanParam, IntParam, ListParam, } from "./types";
8
8
  export { Expression };
9
- export type { ParamOptions };
9
+ export type { ParamOptions, SecretParamOptions };
10
10
  type SecretOrExpr = Param<any> | SecretParam | JsonSecretParam<any>;
11
11
  export declare const declaredParams: SecretOrExpr[];
12
12
  /**
@@ -38,7 +38,7 @@ export declare const storageBucket: Param<string>;
38
38
  * @param name The name of the environment variable to use to load the parameter.
39
39
  * @returns A parameter with a `string` return type for `.value`.
40
40
  */
41
- export declare function defineSecret(name: string): SecretParam;
41
+ export declare function defineSecret(name: string, options?: SecretParamOptions): SecretParam;
42
42
  /**
43
43
  * Declares a secret parameter that retrieves a structured JSON object in Cloud Secret Manager.
44
44
  * This is useful for managing groups of related configuration values, such as all settings
@@ -51,7 +51,7 @@ export declare function defineSecret(name: string): SecretParam;
51
51
  * @returns A parameter whose `.value()` method returns the parsed JSON object.
52
52
  * ```
53
53
  */
54
- export declare function defineJsonSecret<T = any>(name: string): JsonSecretParam<T>;
54
+ export declare function defineJsonSecret<T = any>(name: string, options?: SecretParamOptions): JsonSecretParam<T>;
55
55
  /**
56
56
  * Declare a string parameter.
57
57
  *
@@ -84,3 +84,14 @@ export declare function defineInt(name: string, options?: ParamOptions<number>):
84
84
  * @returns A parameter with a `string[]` return type for `.value`.
85
85
  */
86
86
  export declare function defineList(name: string, options?: ParamOptions<string[]>): ListParam;
87
+ /**
88
+ * Creates an Expression representing a string, which can interpolate
89
+ * other Expressions into it using template literal syntax.
90
+ *
91
+ * @example
92
+ * ```
93
+ * const topicParam = defineString('TOPIC');
94
+ * const topicExpr = expr`projects/my-project/topics/${topicParam}`;
95
+ * ```
96
+ */
97
+ export declare function expr(strings: TemplateStringsArray, ...values: (string | Expression<string>)[]): Expression<string>;
@@ -15,6 +15,7 @@ var params_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
15
15
  defineList: () => defineList,
16
16
  defineSecret: () => defineSecret,
17
17
  defineString: () => defineString,
18
+ expr: () => expr,
18
19
  gcloudProject: () => gcloudProject,
19
20
  multiSelect: () => require_params_types.multiSelect,
20
21
  projectID: () => projectID,
@@ -59,23 +60,23 @@ function clearParams() {
59
60
  * A built-in parameter that resolves to the default RTDB database URL associated
60
61
  * with the project, without prompting the deployer. Empty string if none exists.
61
62
  */
62
- const databaseURL = new require_params_types.InternalExpression("DATABASE_URL", (env) => JSON.parse(env.FIREBASE_CONFIG)?.databaseURL || "");
63
+ const databaseURL = new require_params_types.InternalExpression("DATABASE_URL", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.databaseURL || "");
63
64
  /**
64
65
  * A built-in parameter that resolves to the Cloud project ID associated with
65
66
  * the project, without prompting the deployer.
66
67
  */
67
- const projectID = new require_params_types.InternalExpression("PROJECT_ID", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
68
+ const projectID = new require_params_types.InternalExpression("PROJECT_ID", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.projectId || "");
68
69
  /**
69
70
  * A built-in parameter that resolves to the Cloud project ID, without prompting
70
71
  * the deployer.
71
72
  */
72
- const gcloudProject = new require_params_types.InternalExpression("GCLOUD_PROJECT", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
73
+ const gcloudProject = new require_params_types.InternalExpression("GCLOUD_PROJECT", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.projectId || "");
73
74
  /**
74
75
  * A builtin parameter that resolves to the Cloud storage bucket associated
75
76
  * with the function, without prompting the deployer. Empty string if not
76
77
  * defined.
77
78
  */
78
- const storageBucket = new require_params_types.InternalExpression("STORAGE_BUCKET", (env) => JSON.parse(env.FIREBASE_CONFIG)?.storageBucket || "");
79
+ const storageBucket = new require_params_types.InternalExpression("STORAGE_BUCKET", (env) => JSON.parse(env.FIREBASE_CONFIG || "{}")?.storageBucket || "");
79
80
  /**
80
81
  * Declares a secret param, that will persist values only in Cloud Secret Manager.
81
82
  * Secrets are stored internally as bytestrings. Use `ParamOptions.as` to provide type
@@ -84,8 +85,8 @@ const storageBucket = new require_params_types.InternalExpression("STORAGE_BUCKE
84
85
  * @param name The name of the environment variable to use to load the parameter.
85
86
  * @returns A parameter with a `string` return type for `.value`.
86
87
  */
87
- function defineSecret(name) {
88
- const param = new require_params_types.SecretParam(name);
88
+ function defineSecret(name, options = {}) {
89
+ const param = new require_params_types.SecretParam(name, options);
89
90
  registerParam(param);
90
91
  return param;
91
92
  }
@@ -101,8 +102,8 @@ function defineSecret(name) {
101
102
  * @returns A parameter whose `.value()` method returns the parsed JSON object.
102
103
  * ```
103
104
  */
104
- function defineJsonSecret(name) {
105
- const param = new require_params_types.JsonSecretParam(name);
105
+ function defineJsonSecret(name, options = {}) {
106
+ const param = new require_params_types.JsonSecretParam(name, options);
106
107
  registerParam(param);
107
108
  return param;
108
109
  }
@@ -168,6 +169,19 @@ function defineList(name, options = {}) {
168
169
  registerParam(param);
169
170
  return param;
170
171
  }
172
+ /**
173
+ * Creates an Expression representing a string, which can interpolate
174
+ * other Expressions into it using template literal syntax.
175
+ *
176
+ * @example
177
+ * ```
178
+ * const topicParam = defineString('TOPIC');
179
+ * const topicExpr = expr`projects/my-project/topics/${topicParam}`;
180
+ * ```
181
+ */
182
+ function expr(strings, ...values) {
183
+ return new require_params_types.InterpolationExpression(strings, values);
184
+ }
171
185
 
172
186
  //#endregion
173
187
  exports.BUCKET_PICKER = require_params_types.BUCKET_PICKER;
@@ -182,6 +196,7 @@ exports.defineJsonSecret = defineJsonSecret;
182
196
  exports.defineList = defineList;
183
197
  exports.defineSecret = defineSecret;
184
198
  exports.defineString = defineString;
199
+ exports.expr = expr;
185
200
  exports.gcloudProject = gcloudProject;
186
201
  exports.multiSelect = require_params_types.multiSelect;
187
202
  Object.defineProperty(exports, 'params_exports', {