firebase-functions 7.2.0-rc.0 → 7.2.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.
@@ -9,7 +9,7 @@ function normalizePath(path) {
9
9
  if (!path) {
10
10
  return "";
11
11
  }
12
- return path.replace(/^\//, "").replace(/\/$/, "");
12
+ return path.replace(/^\//, "").replace(/\/$/, "").replace(/\/{2,}/g, "/");
13
13
  }
14
14
  /**
15
15
  * Normalizes a given path and splits it into an array of segments.
@@ -8,7 +8,7 @@ function normalizePath(path) {
8
8
  if (!path) {
9
9
  return "";
10
10
  }
11
- return path.replace(/^\//, "").replace(/\/$/, "");
11
+ return path.replace(/^\//, "").replace(/\/$/, "").replace(/\/{2,}/g, "/");
12
12
  }
13
13
  /**
14
14
  * Normalizes a given path and splits it into an array of segments.
@@ -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 };
@@ -29,7 +29,7 @@ var Expression = class {
29
29
  throw new Error("Not implemented");
30
30
  }
31
31
  /** Returns the expression's representation as a braced CEL expression. */
32
- toCEL() {
32
+ toCEL(_transform = (a) => a) {
33
33
  return `{{ ${this.toString()} }}`;
34
34
  }
35
35
  /** Returns the expression's representation as JSON. */
@@ -37,9 +37,75 @@ 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(transform$1 = (a) => a) {
58
+ const exprPlaceholders = [];
59
+ const PLACEHOLDER_PREFIX = "🤿🤿🤿🐙🐙🐙";
60
+ const PLACEHOLDER_SUFFIX = "🐙🐙🐙🤿🤿🤿";
61
+ const rawString = this.strings.reduce((result, str, i) => {
62
+ if (i >= this.values.length) {
63
+ return result + str;
64
+ }
65
+ const val = this.values[i];
66
+ let valStr;
67
+ if (val instanceof Expression) {
68
+ valStr = `${PLACEHOLDER_PREFIX}${exprPlaceholders.length}${PLACEHOLDER_SUFFIX}`;
69
+ exprPlaceholders.push(val.toCEL());
70
+ } else {
71
+ valStr = String(val);
72
+ }
73
+ return result + str + valStr;
74
+ }, "");
75
+ let transformed = transform$1(rawString);
76
+ for (let i = 0; i < exprPlaceholders.length; i++) {
77
+ const placeholder = `${PLACEHOLDER_PREFIX}${i}${PLACEHOLDER_SUFFIX}`;
78
+ transformed = transformed.split(placeholder).join(exprPlaceholders[i]);
79
+ }
80
+ return transformed;
81
+ }
82
+ };
83
+ /** @internal */
84
+ var TransformedStringExpression = class extends Expression {
85
+ constructor(source, transformer) {
86
+ super();
87
+ this.source = source;
88
+ this.transformer = transformer;
89
+ }
90
+ runtimeValue() {
91
+ return this.transformer(valueOf(this.source));
92
+ }
93
+ toCEL() {
94
+ return this.source instanceof Expression ? this.source.toCEL(this.transformer) : this.transformer(this.source);
95
+ }
96
+ };
40
97
  function valueOf(arg) {
41
98
  return arg instanceof Expression ? arg.runtimeValue() : arg;
42
99
  }
100
+ function celOf(arg) {
101
+ return arg instanceof Expression ? arg.toCEL() : arg;
102
+ }
103
+ /**
104
+ * Transforms a string or a string expression using a function.
105
+ */
106
+ function transform(source, transformer) {
107
+ return new TransformedStringExpression(source, transformer);
108
+ }
43
109
  /**
44
110
  * Returns how an entity (either an `Expression` or a literal value) should be represented in CEL.
45
111
  * - Expressions delegate to the `.toString()` method, which is used by the WireManifest
@@ -91,7 +157,7 @@ var CompareExpression = class extends Expression {
91
157
  }
92
158
  /** @internal */
93
159
  runtimeValue() {
94
- const left = this.lhs.runtimeValue();
160
+ const left = valueOf(this.lhs);
95
161
  const right = valueOf(this.rhs);
96
162
  switch (this.cmp) {
97
163
  case "==": return Array.isArray(left) ? this.arrayEquals(left, right) : left === right;
@@ -108,8 +174,7 @@ var CompareExpression = class extends Expression {
108
174
  return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
109
175
  }
110
176
  toString() {
111
- const rhsStr = refOf(this.rhs);
112
- return `${this.lhs} ${this.cmp} ${rhsStr}`;
177
+ return `${refOf(this.lhs)} ${this.cmp} ${refOf(this.rhs)}`;
113
178
  }
114
179
  /** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */
115
180
  thenElse(ifTrue, ifFalse) {
@@ -231,7 +296,8 @@ var SecretParam = class {
231
296
  static {
232
297
  this.type = "secret";
233
298
  }
234
- constructor(name) {
299
+ constructor(name, options = {}) {
300
+ this.options = options;
235
301
  this.name = name;
236
302
  }
237
303
  /** @internal */
@@ -246,7 +312,8 @@ var SecretParam = class {
246
312
  toSpec() {
247
313
  return {
248
314
  type: "secret",
249
- name: this.name
315
+ name: this.name,
316
+ ...this.options
250
317
  };
251
318
  }
252
319
  /** Returns the secret's value at runtime. Throws an error if accessed during deployment. */
@@ -268,7 +335,8 @@ var JsonSecretParam = class {
268
335
  static {
269
336
  this.type = "secret";
270
337
  }
271
- constructor(name) {
338
+ constructor(name, options = {}) {
339
+ this.options = options;
272
340
  this.name = name;
273
341
  }
274
342
  /** @internal */
@@ -288,6 +356,7 @@ var JsonSecretParam = class {
288
356
  return {
289
357
  type: "secret",
290
358
  name: this.name,
359
+ ...this.options,
291
360
  format: "json"
292
361
  };
293
362
  }
@@ -410,4 +479,4 @@ var ListParam = class extends Param {
410
479
  };
411
480
 
412
481
  //#endregion
413
- export { BUCKET_PICKER, BooleanParam, CompareExpression, Expression, FloatParam, IntParam, InternalExpression, JsonSecretParam, ListParam, Param, SecretParam, StringParam, TernaryExpression, multiSelect, select };
482
+ 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,10 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { CompareExpression, Expression, transform } 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";
6
+ import { normalizePath } from "../../common/utilities/path.mjs";
4
7
  import { createBeforeSnapshotFromJson, createSnapshotFromJson } from "../../common/providers/firestore.mjs";
5
- import { posix } from "path";
6
8
 
7
9
  //#region src/v1/providers/firestore.ts
8
10
  var firestore_exports = /* @__PURE__ */ __export({
@@ -74,13 +76,24 @@ var NamespaceBuilder = class {
74
76
  this.namespace = namespace$1;
75
77
  }
76
78
  document(path) {
77
- return new DocumentBuilder(() => {
79
+ const normalized = transform(path, normalizePath);
80
+ const triggerResource = () => {
78
81
  if (!process.env.GCLOUD_PROJECT) {
79
82
  throw new Error("process.env.GCLOUD_PROJECT is not set.");
80
83
  }
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);
84
+ let project = projectID;
85
+ if (process.env.GCLOUD_PROJECT && process.env.FUNCTIONS_CONTROL_API !== "true") {
86
+ project = process.env.GCLOUD_PROJECT;
87
+ }
88
+ let nsPart = "";
89
+ if (this.namespace instanceof Expression) {
90
+ nsPart = new CompareExpression("==", this.namespace, "").thenElse("", expr`@${this.namespace}`);
91
+ } else if (this.namespace) {
92
+ nsPart = `@${this.namespace}`;
93
+ }
94
+ return expr`projects/${project}/databases/${this.database}/documents${nsPart}/${normalized}`;
95
+ };
96
+ return new DocumentBuilder(triggerResource, this.options);
84
97
  }
85
98
  };
86
99
  function snapshotConstructor(event) {
@@ -93,6 +106,7 @@ function changeConstructor(raw) {
93
106
  return Change.fromObjects(beforeSnapshotConstructor(raw), snapshotConstructor(raw));
94
107
  }
95
108
  var DocumentBuilder = class {
109
+ /** @internal */
96
110
  constructor(triggerResource, options) {
97
111
  this.triggerResource = triggerResource;
98
112
  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
  }
@@ -0,0 +1,13 @@
1
+ import { __export } from "../_virtual/rolldown_runtime.mjs";
2
+ import { mutationExecutedEventType, onMutationExecuted } from "./providers/dataconnect/index.mjs";
3
+ import { graphql_exports } from "./providers/dataconnect/graphql.mjs";
4
+
5
+ //#region src/v2/dataconnect.doc.ts
6
+ var dataconnect_doc_exports = /* @__PURE__ */ __export({
7
+ graphql: () => graphql_exports,
8
+ mutationExecutedEventType: () => mutationExecutedEventType,
9
+ onMutationExecuted: () => onMutationExecuted
10
+ });
11
+
12
+ //#endregion
13
+ export { dataconnect_doc_exports, graphql_exports as graphql, mutationExecutedEventType, onMutationExecuted };
@@ -6,6 +6,7 @@ import { onInit } from "../common/onInit.mjs";
6
6
  import { config } from "../v1/config.mjs";
7
7
  import { setGlobalOptions } from "./options.mjs";
8
8
  import { pubsub_exports } from "./providers/pubsub.mjs";
9
+ import { dataconnect_doc_exports } from "./dataconnect.doc.mjs";
9
10
  import { alerts_exports } from "./providers/alerts/index.mjs";
10
11
  import { database_exports } from "./providers/database.mjs";
11
12
  import { eventarc_exports } from "./providers/eventarc.mjs";
@@ -17,8 +18,6 @@ import { tasks_exports } from "./providers/tasks.mjs";
17
18
  import { remoteConfig_exports } from "./providers/remoteConfig.mjs";
18
19
  import { testLab_exports } from "./providers/testLab.mjs";
19
20
  import { firestore_exports } from "./providers/firestore.mjs";
20
- import { dataconnect_exports } from "./providers/dataconnect/index.mjs";
21
21
  import { app } from "./index.mjs";
22
- import { graphql_exports } from "./providers/dataconnect/graphql.mjs";
23
22
 
24
- export { Change, alerts_exports as alerts, app, config, database_exports as database, dataconnect_exports as dataconnect, eventarc_exports as eventarc, firestore_exports as firestore, graphql_exports as graphql, https_exports as https, identity_exports as identity, logger, onInit, params_exports as params, pubsub_exports as pubsub, remoteConfig_exports as remoteConfig, scheduler_exports as scheduler, setGlobalOptions, storage_exports as storage, tasks_exports as tasks, testLab_exports as testLab, traceContext };
23
+ export { Change, alerts_exports as alerts, app, config, database_exports as database, dataconnect_doc_exports as dataconnect, eventarc_exports as eventarc, firestore_exports as firestore, https_exports as https, identity_exports as identity, logger, onInit, params_exports as params, pubsub_exports as pubsub, remoteConfig_exports as remoteConfig, scheduler_exports as scheduler, setGlobalOptions, storage_exports as storage, tasks_exports as tasks, testLab_exports as testLab, traceContext };
@@ -8,6 +8,7 @@ import { config } from "../v1/config.mjs";
8
8
  import { setGlobalOptions } from "./options.mjs";
9
9
  import { pubsub_exports } from "./providers/pubsub.mjs";
10
10
  import "./core.mjs";
11
+ import { dataconnect_exports } from "./providers/dataconnect/index.mjs";
11
12
  import { alerts_exports } from "./providers/alerts/index.mjs";
12
13
  import { database_exports } from "./providers/database.mjs";
13
14
  import { eventarc_exports } from "./providers/eventarc.mjs";
@@ -19,7 +20,6 @@ import { tasks_exports } from "./providers/tasks.mjs";
19
20
  import { remoteConfig_exports } from "./providers/remoteConfig.mjs";
20
21
  import { testLab_exports } from "./providers/testLab.mjs";
21
22
  import { firestore_exports } from "./providers/firestore.mjs";
22
- import { dataconnect_exports } from "./providers/dataconnect/index.mjs";
23
23
 
24
24
  //#region src/v2/index.ts
25
25
  const app = { setEmulatedAdminApp: setApp };
@@ -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', {