firebase-functions 6.5.0 → 7.0.0-rc.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.
Files changed (157) hide show
  1. package/lib/_virtual/rolldown_runtime.js +34 -0
  2. package/lib/bin/firebase-functions.js +78 -103
  3. package/lib/common/app.js +35 -55
  4. package/lib/common/change.js +54 -75
  5. package/lib/common/config.js +41 -41
  6. package/lib/common/debug.js +23 -47
  7. package/lib/common/encoding.js +59 -82
  8. package/lib/common/onInit.js +26 -28
  9. package/lib/common/options.js +22 -42
  10. package/lib/common/params.d.ts +6 -6
  11. package/lib/common/params.js +0 -23
  12. package/lib/common/providers/database.js +270 -300
  13. package/lib/common/providers/firestore.js +66 -92
  14. package/lib/common/providers/https.d.ts +0 -1
  15. package/lib/common/providers/https.js +537 -539
  16. package/lib/common/providers/identity.js +393 -444
  17. package/lib/common/providers/tasks.js +64 -98
  18. package/lib/common/timezone.js +544 -542
  19. package/lib/common/trace.d.ts +0 -1
  20. package/lib/common/trace.js +63 -55
  21. package/lib/common/utilities/assertions.d.ts +11 -0
  22. package/lib/common/utilities/assertions.js +18 -0
  23. package/lib/common/utilities/encoder.js +20 -37
  24. package/lib/common/utilities/path-pattern.js +106 -132
  25. package/lib/common/utilities/path.js +28 -27
  26. package/lib/common/utilities/utils.js +23 -45
  27. package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
  28. package/lib/esm/bin/firebase-functions.mjs +91 -0
  29. package/lib/esm/common/app.mjs +39 -0
  30. package/lib/esm/common/change.mjs +57 -0
  31. package/lib/esm/common/config.mjs +45 -0
  32. package/lib/esm/common/debug.mjs +28 -0
  33. package/lib/esm/common/encoding.mjs +69 -0
  34. package/lib/esm/common/onInit.mjs +33 -0
  35. package/lib/esm/common/options.mjs +22 -0
  36. package/lib/esm/common/params.mjs +1 -0
  37. package/lib/esm/common/providers/database.mjs +269 -0
  38. package/lib/esm/common/providers/firestore.mjs +78 -0
  39. package/lib/esm/common/providers/https.mjs +573 -0
  40. package/lib/esm/common/providers/identity.mjs +428 -0
  41. package/lib/esm/common/providers/tasks.mjs +67 -0
  42. package/lib/esm/common/timezone.mjs +544 -0
  43. package/lib/esm/common/trace.mjs +73 -0
  44. package/lib/esm/common/utilities/assertions.mjs +17 -0
  45. package/lib/esm/common/utilities/encoder.mjs +21 -0
  46. package/lib/esm/common/utilities/path-pattern.mjs +116 -0
  47. package/lib/esm/common/utilities/path.mjs +35 -0
  48. package/lib/esm/common/utilities/utils.mjs +29 -0
  49. package/lib/esm/function-configuration.mjs +1 -0
  50. package/lib/esm/logger/common.mjs +23 -0
  51. package/lib/esm/logger/compat.mjs +25 -0
  52. package/lib/esm/logger/index.mjs +131 -0
  53. package/lib/esm/params/index.mjs +160 -0
  54. package/lib/esm/params/types.mjs +400 -0
  55. package/lib/esm/runtime/loader.mjs +132 -0
  56. package/lib/esm/runtime/manifest.mjs +134 -0
  57. package/lib/esm/types/global.d.mjs +1 -0
  58. package/lib/esm/v1/cloud-functions.mjs +206 -0
  59. package/lib/esm/v1/config.mjs +14 -0
  60. package/lib/esm/v1/function-builder.mjs +252 -0
  61. package/lib/esm/v1/function-configuration.mjs +72 -0
  62. package/lib/esm/v1/index.mjs +27 -0
  63. package/lib/esm/v1/providers/analytics.mjs +212 -0
  64. package/lib/esm/v1/providers/auth.mjs +156 -0
  65. package/lib/esm/v1/providers/database.mjs +243 -0
  66. package/lib/esm/v1/providers/firestore.mjs +131 -0
  67. package/lib/esm/v1/providers/https.mjs +82 -0
  68. package/lib/esm/v1/providers/pubsub.mjs +175 -0
  69. package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
  70. package/lib/esm/v1/providers/storage.mjs +163 -0
  71. package/lib/esm/v1/providers/tasks.mjs +63 -0
  72. package/lib/esm/v1/providers/testLab.mjs +94 -0
  73. package/lib/esm/v2/core.mjs +4 -0
  74. package/lib/esm/v2/index.mjs +28 -0
  75. package/lib/esm/v2/options.mjs +102 -0
  76. package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
  77. package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
  78. package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
  79. package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
  80. package/lib/esm/v2/providers/alerts/index.mjs +22 -0
  81. package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
  82. package/lib/esm/v2/providers/database.mjs +197 -0
  83. package/lib/esm/v2/providers/dataconnect.mjs +130 -0
  84. package/lib/esm/v2/providers/eventarc.mjs +51 -0
  85. package/lib/esm/v2/providers/firestore.mjs +294 -0
  86. package/lib/esm/v2/providers/https.mjs +210 -0
  87. package/lib/esm/v2/providers/identity.mjs +103 -0
  88. package/lib/esm/v2/providers/pubsub.mjs +148 -0
  89. package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
  90. package/lib/esm/v2/providers/scheduler.mjs +84 -0
  91. package/lib/esm/v2/providers/storage.mjs +155 -0
  92. package/lib/esm/v2/providers/tasks.mjs +65 -0
  93. package/lib/esm/v2/providers/testLab.mjs +53 -0
  94. package/lib/esm/v2/trace.mjs +20 -0
  95. package/lib/function-configuration.d.ts +0 -0
  96. package/lib/function-configuration.js +0 -0
  97. package/lib/logger/common.js +21 -41
  98. package/lib/logger/compat.js +18 -33
  99. package/lib/logger/index.js +119 -130
  100. package/lib/params/index.d.ts +19 -4
  101. package/lib/params/index.js +153 -129
  102. package/lib/params/types.d.ts +17 -0
  103. package/lib/params/types.js +390 -382
  104. package/lib/runtime/loader.js +114 -148
  105. package/lib/runtime/manifest.js +106 -126
  106. package/lib/types/global.d.js +0 -0
  107. package/lib/v1/cloud-functions.d.ts +2 -2
  108. package/lib/v1/cloud-functions.js +193 -241
  109. package/lib/v1/config.d.ts +4 -7
  110. package/lib/v1/config.js +13 -75
  111. package/lib/v1/function-builder.js +239 -368
  112. package/lib/v1/function-configuration.js +70 -63
  113. package/lib/v1/index.js +118 -73
  114. package/lib/v1/providers/analytics.js +189 -210
  115. package/lib/v1/providers/auth.d.ts +2 -1
  116. package/lib/v1/providers/auth.js +159 -164
  117. package/lib/v1/providers/database.js +237 -242
  118. package/lib/v1/providers/firestore.js +131 -130
  119. package/lib/v1/providers/https.d.ts +2 -1
  120. package/lib/v1/providers/https.js +79 -86
  121. package/lib/v1/providers/pubsub.js +175 -172
  122. package/lib/v1/providers/remoteConfig.js +64 -68
  123. package/lib/v1/providers/storage.js +161 -163
  124. package/lib/v1/providers/tasks.d.ts +1 -1
  125. package/lib/v1/providers/tasks.js +65 -80
  126. package/lib/v1/providers/testLab.js +94 -94
  127. package/lib/v2/core.d.ts +1 -1
  128. package/lib/v2/core.js +5 -32
  129. package/lib/v2/index.d.ts +6 -3
  130. package/lib/v2/index.js +123 -75
  131. package/lib/v2/options.js +88 -114
  132. package/lib/v2/providers/alerts/alerts.js +76 -95
  133. package/lib/v2/providers/alerts/appDistribution.js +73 -78
  134. package/lib/v2/providers/alerts/billing.js +49 -53
  135. package/lib/v2/providers/alerts/crashlytics.js +110 -102
  136. package/lib/v2/providers/alerts/index.js +56 -53
  137. package/lib/v2/providers/alerts/performance.js +64 -74
  138. package/lib/v2/providers/database.js +177 -180
  139. package/lib/v2/providers/dataconnect.d.ts +95 -0
  140. package/lib/v2/providers/dataconnect.js +137 -0
  141. package/lib/v2/providers/eventarc.js +55 -77
  142. package/lib/v2/providers/firestore.js +262 -260
  143. package/lib/v2/providers/https.d.ts +3 -2
  144. package/lib/v2/providers/https.js +210 -247
  145. package/lib/v2/providers/identity.d.ts +2 -1
  146. package/lib/v2/providers/identity.js +96 -105
  147. package/lib/v2/providers/pubsub.js +149 -167
  148. package/lib/v2/providers/remoteConfig.js +54 -63
  149. package/lib/v2/providers/scheduler.js +84 -96
  150. package/lib/v2/providers/storage.js +147 -162
  151. package/lib/v2/providers/tasks.d.ts +1 -1
  152. package/lib/v2/providers/tasks.js +68 -95
  153. package/lib/v2/providers/testLab.js +55 -64
  154. package/lib/v2/trace.js +18 -19
  155. package/package.json +290 -226
  156. package/protos/compiledFirestore.mjs +3512 -0
  157. package/protos/update.sh +28 -7
@@ -1,406 +1,414 @@
1
- "use strict";
2
- // The MIT License (MIT)
3
- //
4
- // Copyright (c) 2021 Firebase
5
- //
6
- // Permission is hereby granted, free of charge, to any person obtaining a copy
7
- // of this software and associated documentation files (the "Software"), to deal
8
- // in the Software without restriction, including without limitation the rights
9
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- // copies of the Software, and to permit persons to whom the Software is
11
- // furnished to do so, subject to the following conditions:
12
- //
13
- // The above copyright notice and this permission notice shall be included in all
14
- // copies or substantial portions of the Software.
15
- //
16
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- // SOFTWARE.
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.InternalExpression = exports.StringParam = exports.SecretParam = exports.Param = exports.BUCKET_PICKER = exports.multiSelect = exports.select = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
25
- const logger = require("../logger");
26
- /*
27
- * A CEL expression which can be evaluated during function deployment, and
28
- * resolved to a value of the generic type parameter: i.e, you can pass
29
- * an Expression<number> as the value of an option that normally accepts numbers.
30
- */
31
- class Expression {
32
- /** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
33
- value() {
34
- if (process.env.FUNCTIONS_CONTROL_API === "true") {
35
- logger.warn(`${this.toString()}.value() invoked during function deployment, instead of during runtime.`);
36
- logger.warn(`This is usually a mistake. In configs, use Params directly without calling .value().`);
37
- logger.warn(`example: { memory: memoryParam } not { memory: memoryParam.value() }`);
38
- }
39
- return this.runtimeValue();
40
- }
41
- /** @internal */
42
- runtimeValue() {
43
- throw new Error("Not implemented");
44
- }
45
- /** Returns the expression's representation as a braced CEL expression. */
46
- toCEL() {
47
- return `{{ ${this.toString()} }}`;
48
- }
49
- /** Returns the expression's representation as JSON. */
50
- toJSON() {
51
- return this.toString();
52
- }
53
- }
54
- exports.Expression = Expression;
1
+ const require_logger_index = require('../logger/index.js');
2
+
3
+ //#region src/params/types.ts
4
+ var Expression = class {
5
+ /** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
6
+ value() {
7
+ if (process.env.FUNCTIONS_CONTROL_API === "true") {
8
+ require_logger_index.warn(`${this.toString()}.value() invoked during function deployment, instead of during runtime.`);
9
+ require_logger_index.warn(`This is usually a mistake. In configs, use Params directly without calling .value().`);
10
+ require_logger_index.warn(`example: { memory: memoryParam } not { memory: memoryParam.value() }`);
11
+ }
12
+ return this.runtimeValue();
13
+ }
14
+ /** @internal */
15
+ runtimeValue() {
16
+ throw new Error("Not implemented");
17
+ }
18
+ /** Returns the expression's representation as a braced CEL expression. */
19
+ toCEL() {
20
+ return `{{ ${this.toString()} }}`;
21
+ }
22
+ /** Returns the expression's representation as JSON. */
23
+ toJSON() {
24
+ return this.toString();
25
+ }
26
+ };
55
27
  function valueOf(arg) {
56
- return arg instanceof Expression ? arg.runtimeValue() : arg;
28
+ return arg instanceof Expression ? arg.runtimeValue() : arg;
57
29
  }
58
30
  /**
59
- * Returns how an entity (either an `Expression` or a literal value) should be represented in CEL.
60
- * - Expressions delegate to the `.toString()` method, which is used by the WireManifest
61
- * - Strings have to be quoted explicitly
62
- * - Arrays are represented as []-delimited, parsable JSON
63
- * - Numbers and booleans are not quoted explicitly
64
- */
31
+ * Returns how an entity (either an `Expression` or a literal value) should be represented in CEL.
32
+ * - Expressions delegate to the `.toString()` method, which is used by the WireManifest
33
+ * - Strings have to be quoted explicitly
34
+ * - Arrays are represented as []-delimited, parsable JSON
35
+ * - Numbers and booleans are not quoted explicitly
36
+ */
65
37
  function refOf(arg) {
66
- if (arg instanceof Expression) {
67
- return arg.toString();
68
- }
69
- else if (typeof arg === "string") {
70
- return `"${arg}"`;
71
- }
72
- else if (Array.isArray(arg)) {
73
- return JSON.stringify(arg);
74
- }
75
- else {
76
- return arg.toString();
77
- }
38
+ if (arg instanceof Expression) {
39
+ return arg.toString();
40
+ } else if (typeof arg === "string") {
41
+ return `"${arg}"`;
42
+ } else if (Array.isArray(arg)) {
43
+ return JSON.stringify(arg);
44
+ } else {
45
+ return arg.toString();
46
+ }
78
47
  }
79
48
  /**
80
- * A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
81
- */
82
- class TernaryExpression extends Expression {
83
- constructor(test, ifTrue, ifFalse) {
84
- super();
85
- this.test = test;
86
- this.ifTrue = ifTrue;
87
- this.ifFalse = ifFalse;
88
- this.ifTrue = ifTrue;
89
- this.ifFalse = ifFalse;
90
- }
91
- /** @internal */
92
- runtimeValue() {
93
- return this.test.runtimeValue() ? valueOf(this.ifTrue) : valueOf(this.ifFalse);
94
- }
95
- toString() {
96
- return `${this.test} ? ${refOf(this.ifTrue)} : ${refOf(this.ifFalse)}`;
97
- }
98
- }
99
- exports.TernaryExpression = TernaryExpression;
49
+ * A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
50
+ */
51
+ var TernaryExpression = class extends Expression {
52
+ constructor(test, ifTrue, ifFalse) {
53
+ super();
54
+ this.test = test;
55
+ this.ifTrue = ifTrue;
56
+ this.ifFalse = ifFalse;
57
+ this.ifTrue = ifTrue;
58
+ this.ifFalse = ifFalse;
59
+ }
60
+ /** @internal */
61
+ runtimeValue() {
62
+ return this.test.runtimeValue() ? valueOf(this.ifTrue) : valueOf(this.ifFalse);
63
+ }
64
+ toString() {
65
+ return `${this.test} ? ${refOf(this.ifTrue)} : ${refOf(this.ifFalse)}`;
66
+ }
67
+ };
100
68
  /**
101
- * A CEL expression that evaluates to boolean true or false based on a comparison
102
- * between the value of another expression and a literal of that same type.
103
- */
104
- class CompareExpression extends Expression {
105
- constructor(cmp, lhs, rhs) {
106
- super();
107
- this.cmp = cmp;
108
- this.lhs = lhs;
109
- this.rhs = rhs;
110
- }
111
- /** @internal */
112
- runtimeValue() {
113
- const left = this.lhs.runtimeValue();
114
- const right = valueOf(this.rhs);
115
- switch (this.cmp) {
116
- case "==":
117
- return Array.isArray(left) ? this.arrayEquals(left, right) : left === right;
118
- case "!=":
119
- return Array.isArray(left) ? !this.arrayEquals(left, right) : left !== right;
120
- case ">":
121
- return left > right;
122
- case ">=":
123
- return left >= right;
124
- case "<":
125
- return left < right;
126
- case "<=":
127
- return left <= right;
128
- default:
129
- throw new Error(`Unknown comparator ${this.cmp}`);
130
- }
131
- }
132
- /** @internal */
133
- arrayEquals(a, b) {
134
- return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
135
- }
136
- toString() {
137
- const rhsStr = refOf(this.rhs);
138
- return `${this.lhs} ${this.cmp} ${rhsStr}`;
139
- }
140
- /** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */
141
- thenElse(ifTrue, ifFalse) {
142
- return new TernaryExpression(this, ifTrue, ifFalse);
143
- }
144
- }
145
- exports.CompareExpression = CompareExpression;
69
+ * A CEL expression that evaluates to boolean true or false based on a comparison
70
+ * between the value of another expression and a literal of that same type.
71
+ */
72
+ var CompareExpression = class extends Expression {
73
+ constructor(cmp, lhs, rhs) {
74
+ super();
75
+ this.cmp = cmp;
76
+ this.lhs = lhs;
77
+ this.rhs = rhs;
78
+ }
79
+ /** @internal */
80
+ runtimeValue() {
81
+ const left = this.lhs.runtimeValue();
82
+ const right = valueOf(this.rhs);
83
+ switch (this.cmp) {
84
+ case "==": return Array.isArray(left) ? this.arrayEquals(left, right) : left === right;
85
+ case "!=": return Array.isArray(left) ? !this.arrayEquals(left, right) : left !== right;
86
+ case ">": return left > right;
87
+ case ">=": return left >= right;
88
+ case "<": return left < right;
89
+ case "<=": return left <= right;
90
+ default: throw new Error(`Unknown comparator ${this.cmp}`);
91
+ }
92
+ }
93
+ /** @internal */
94
+ arrayEquals(a, b) {
95
+ return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
96
+ }
97
+ toString() {
98
+ const rhsStr = refOf(this.rhs);
99
+ return `${this.lhs} ${this.cmp} ${rhsStr}`;
100
+ }
101
+ /** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */
102
+ thenElse(ifTrue, ifFalse) {
103
+ return new TernaryExpression(this, ifTrue, ifFalse);
104
+ }
105
+ };
146
106
  /** Create a select input from a series of values or a map of labels to values */
147
107
  function select(options) {
148
- let wireOpts;
149
- if (Array.isArray(options)) {
150
- wireOpts = options.map((opt) => ({ value: opt }));
151
- }
152
- else {
153
- wireOpts = Object.entries(options).map(([label, value]) => ({ label, value }));
154
- }
155
- return {
156
- select: {
157
- options: wireOpts,
158
- },
159
- };
108
+ let wireOpts;
109
+ if (Array.isArray(options)) {
110
+ wireOpts = options.map((opt) => ({ value: opt }));
111
+ } else {
112
+ wireOpts = Object.entries(options).map(([label, value]) => ({
113
+ label,
114
+ value
115
+ }));
116
+ }
117
+ return { select: { options: wireOpts } };
160
118
  }
161
- exports.select = select;
162
119
  /** Create a multi-select input from a series of values or map of labels to values. */
163
120
  function multiSelect(options) {
164
- let wireOpts;
165
- if (Array.isArray(options)) {
166
- wireOpts = options.map((opt) => ({ value: opt }));
167
- }
168
- else {
169
- wireOpts = Object.entries(options).map(([label, value]) => ({ label, value }));
170
- }
171
- return {
172
- multiSelect: {
173
- options: wireOpts,
174
- },
175
- };
121
+ let wireOpts;
122
+ if (Array.isArray(options)) {
123
+ wireOpts = options.map((opt) => ({ value: opt }));
124
+ } else {
125
+ wireOpts = Object.entries(options).map(([label, value]) => ({
126
+ label,
127
+ value
128
+ }));
129
+ }
130
+ return { multiSelect: { options: wireOpts } };
176
131
  }
177
- exports.multiSelect = multiSelect;
178
132
  /**
179
- * Autogenerate a list of buckets in a project that a user can select from.
180
- */
181
- exports.BUCKET_PICKER = {
182
- resource: {
183
- type: "storage.googleapis.com/Bucket",
184
- },
133
+ * Autogenerate a list of buckets in a project that a user can select from.
134
+ */
135
+ const BUCKET_PICKER = { resource: { type: "storage.googleapis.com/Bucket" } };
136
+ /**
137
+ * Represents a parametrized value that will be read from .env files if present,
138
+ * or prompted for by the CLI if missing. Instantiate these with the defineX
139
+ * methods exported by the firebase-functions/params namespace.
140
+ */
141
+ var Param = class extends Expression {
142
+ static {
143
+ this.type = "string";
144
+ }
145
+ constructor(name, options = {}) {
146
+ super();
147
+ this.name = name;
148
+ this.options = options;
149
+ }
150
+ /** @internal */
151
+ runtimeValue() {
152
+ throw new Error("Not implemented");
153
+ }
154
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
155
+ cmp(cmp, rhs) {
156
+ return new CompareExpression(cmp, this, rhs);
157
+ }
158
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
159
+ equals(rhs) {
160
+ return this.cmp("==", rhs);
161
+ }
162
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
163
+ notEquals(rhs) {
164
+ return this.cmp("!=", rhs);
165
+ }
166
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
167
+ greaterThan(rhs) {
168
+ return this.cmp(">", rhs);
169
+ }
170
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
171
+ greaterThanOrEqualTo(rhs) {
172
+ return this.cmp(">=", rhs);
173
+ }
174
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
175
+ lessThan(rhs) {
176
+ return this.cmp("<", rhs);
177
+ }
178
+ /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
179
+ lessThanOrEqualTo(rhs) {
180
+ return this.cmp("<=", rhs);
181
+ }
182
+ /**
183
+ * Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression.
184
+ * @deprecated A typo. Use lessThanOrEqualTo instead.
185
+ */
186
+ lessThanorEqualTo(rhs) {
187
+ return this.lessThanOrEqualTo(rhs);
188
+ }
189
+ toString() {
190
+ return `params.${this.name}`;
191
+ }
192
+ /** @internal */
193
+ toSpec() {
194
+ const { default: paramDefault,...otherOptions } = this.options;
195
+ const out = {
196
+ name: this.name,
197
+ ...otherOptions,
198
+ type: this.constructor.type
199
+ };
200
+ if (paramDefault instanceof Expression) {
201
+ out.default = paramDefault.toCEL();
202
+ } else if (paramDefault !== undefined) {
203
+ out.default = paramDefault;
204
+ }
205
+ if (out.input && "text" in out.input && out.input.text.validationRegex instanceof RegExp) {
206
+ out.input.text.validationRegex = out.input.text.validationRegex.source;
207
+ }
208
+ return out;
209
+ }
185
210
  };
186
211
  /**
187
- * Represents a parametrized value that will be read from .env files if present,
188
- * or prompted for by the CLI if missing. Instantiate these with the defineX
189
- * methods exported by the firebase-functions/params namespace.
190
- */
191
- class Param extends Expression {
192
- constructor(name, options = {}) {
193
- super();
194
- this.name = name;
195
- this.options = options;
196
- }
197
- /** @internal */
198
- runtimeValue() {
199
- throw new Error("Not implemented");
200
- }
201
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
202
- cmp(cmp, rhs) {
203
- return new CompareExpression(cmp, this, rhs);
204
- }
205
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
206
- equals(rhs) {
207
- return this.cmp("==", rhs);
208
- }
209
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
210
- notEquals(rhs) {
211
- return this.cmp("!=", rhs);
212
- }
213
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
214
- greaterThan(rhs) {
215
- return this.cmp(">", rhs);
216
- }
217
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
218
- greaterThanOrEqualTo(rhs) {
219
- return this.cmp(">=", rhs);
220
- }
221
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
222
- lessThan(rhs) {
223
- return this.cmp("<", rhs);
224
- }
225
- /** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */
226
- lessThanOrEqualTo(rhs) {
227
- return this.cmp("<=", rhs);
228
- }
229
- /**
230
- * Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression.
231
- * @deprecated A typo. Use lessThanOrEqualTo instead.
232
- */
233
- lessThanorEqualTo(rhs) {
234
- return this.lessThanOrEqualTo(rhs);
235
- }
236
- toString() {
237
- return `params.${this.name}`;
238
- }
239
- /** @internal */
240
- toSpec() {
241
- const { default: paramDefault, ...otherOptions } = this.options;
242
- const out = {
243
- name: this.name,
244
- ...otherOptions,
245
- type: this.constructor.type,
246
- };
247
- if (paramDefault instanceof Expression) {
248
- out.default = paramDefault.toCEL();
249
- }
250
- else if (paramDefault !== undefined) {
251
- out.default = paramDefault;
252
- }
253
- if (out.input && "text" in out.input && out.input.text.validationRegex instanceof RegExp) {
254
- out.input.text.validationRegex = out.input.text.validationRegex.source;
255
- }
256
- return out;
257
- }
258
- }
259
- exports.Param = Param;
260
- Param.type = "string";
212
+ * A parametrized string whose value is stored in Cloud Secret Manager
213
+ * instead of the local filesystem. Supply instances of SecretParams to
214
+ * the secrets array while defining a Function to make their values accessible
215
+ * during execution of that Function.
216
+ */
217
+ var SecretParam = class {
218
+ static {
219
+ this.type = "secret";
220
+ }
221
+ constructor(name) {
222
+ this.name = name;
223
+ }
224
+ /** @internal */
225
+ runtimeValue() {
226
+ const val = process.env[this.name];
227
+ if (val === undefined) {
228
+ require_logger_index.warn(`No value found for secret parameter "${this.name}". A function can only access a secret if you include the secret in the function's dependency array.`);
229
+ }
230
+ return val || "";
231
+ }
232
+ /** @internal */
233
+ toSpec() {
234
+ return {
235
+ type: "secret",
236
+ name: this.name
237
+ };
238
+ }
239
+ /** Returns the secret's value at runtime. Throws an error if accessed during deployment. */
240
+ value() {
241
+ if (process.env.FUNCTIONS_CONTROL_API === "true") {
242
+ throw new Error(`Cannot access the value of secret "${this.name}" during function deployment. Secret values are only available at runtime.`);
243
+ }
244
+ return this.runtimeValue();
245
+ }
246
+ };
261
247
  /**
262
- * A parametrized string whose value is stored in Cloud Secret Manager
263
- * instead of the local filesystem. Supply instances of SecretParams to
264
- * the secrets array while defining a Function to make their values accessible
265
- * during execution of that Function.
266
- */
267
- class SecretParam {
268
- constructor(name) {
269
- this.name = name;
270
- }
271
- /** @internal */
272
- runtimeValue() {
273
- const val = process.env[this.name];
274
- if (val === undefined) {
275
- logger.warn(`No value found for secret parameter "${this.name}". A function can only access a secret if you include the secret in the function's dependency array.`);
276
- }
277
- return val || "";
278
- }
279
- /** @internal */
280
- toSpec() {
281
- return {
282
- type: "secret",
283
- name: this.name,
284
- };
285
- }
286
- /** Returns the secret's value at runtime. Throws an error if accessed during deployment. */
287
- value() {
288
- if (process.env.FUNCTIONS_CONTROL_API === "true") {
289
- throw new Error(`Cannot access the value of secret "${this.name}" during function deployment. Secret values are only available at runtime.`);
290
- }
291
- return this.runtimeValue();
292
- }
293
- }
294
- exports.SecretParam = SecretParam;
295
- SecretParam.type = "secret";
248
+ * A parametrized object whose value is stored as a JSON string in Cloud Secret Manager.
249
+ * This is useful for managing groups of related configuration values, such as all settings
250
+ * for a third-party API, as a single unit. Supply instances of JsonSecretParam to the
251
+ * secrets array while defining a Function to make their values accessible during execution
252
+ * of that Function.
253
+ */
254
+ var JsonSecretParam = class {
255
+ static {
256
+ this.type = "secret";
257
+ }
258
+ constructor(name) {
259
+ this.name = name;
260
+ }
261
+ /** @internal */
262
+ runtimeValue() {
263
+ const val = process.env[this.name];
264
+ if (val === undefined) {
265
+ throw new Error(`No value found for secret parameter "${this.name}". A function can only access a secret if you include the secret in the function's dependency array.`);
266
+ }
267
+ try {
268
+ return JSON.parse(val);
269
+ } catch (error) {
270
+ throw new Error(`"${this.name}" could not be parsed as JSON. Please verify its value in Secret Manager. Details: ${error}`);
271
+ }
272
+ }
273
+ /** @internal */
274
+ toSpec() {
275
+ return {
276
+ type: "secret",
277
+ name: this.name,
278
+ format: "json"
279
+ };
280
+ }
281
+ /** Returns the secret's parsed JSON value at runtime. Throws an error if accessed during deployment, if the secret is not set, or if the value is not valid JSON. */
282
+ value() {
283
+ if (process.env.FUNCTIONS_CONTROL_API === "true") {
284
+ throw new Error(`Cannot access the value of secret "${this.name}" during function deployment. Secret values are only available at runtime.`);
285
+ }
286
+ return this.runtimeValue();
287
+ }
288
+ };
296
289
  /**
297
- * A parametrized value of String type that will be read from .env files
298
- * if present, or prompted for by the CLI if missing.
299
- */
300
- class StringParam extends Param {
301
- /** @internal */
302
- runtimeValue() {
303
- return process.env[this.name] || "";
304
- }
305
- }
306
- exports.StringParam = StringParam;
290
+ * A parametrized value of String type that will be read from .env files
291
+ * if present, or prompted for by the CLI if missing.
292
+ */
293
+ var StringParam = class extends Param {
294
+ /** @internal */
295
+ runtimeValue() {
296
+ return process.env[this.name] || "";
297
+ }
298
+ };
307
299
  /**
308
- * A CEL expression which represents an internal Firebase variable. This class
309
- * cannot be instantiated by developers, but we provide several canned instances
310
- * of it to make available parameters that will never have to be defined at
311
- * deployment time, and can always be read from process.env.
312
- * @internal
313
- */
314
- class InternalExpression extends Param {
315
- constructor(name, getter) {
316
- super(name);
317
- this.getter = getter;
318
- }
319
- /** @internal */
320
- runtimeValue() {
321
- return this.getter(process.env) || "";
322
- }
323
- toSpec() {
324
- throw new Error("An InternalExpression should never be marshalled for wire transmission.");
325
- }
326
- }
327
- exports.InternalExpression = InternalExpression;
300
+ * A CEL expression which represents an internal Firebase variable. This class
301
+ * cannot be instantiated by developers, but we provide several canned instances
302
+ * of it to make available parameters that will never have to be defined at
303
+ * deployment time, and can always be read from process.env.
304
+ * @internal
305
+ */
306
+ var InternalExpression = class extends Param {
307
+ constructor(name, getter) {
308
+ super(name);
309
+ this.getter = getter;
310
+ }
311
+ /** @internal */
312
+ runtimeValue() {
313
+ return this.getter(process.env) || "";
314
+ }
315
+ toSpec() {
316
+ throw new Error("An InternalExpression should never be marshalled for wire transmission.");
317
+ }
318
+ };
328
319
  /**
329
- * A parametrized value of Integer type that will be read from .env files
330
- * if present, or prompted for by the CLI if missing.
331
- */
332
- class IntParam extends Param {
333
- /** @internal */
334
- runtimeValue() {
335
- return parseInt(process.env[this.name] || "0", 10) || 0;
336
- }
337
- }
338
- exports.IntParam = IntParam;
339
- IntParam.type = "int";
320
+ * A parametrized value of Integer type that will be read from .env files
321
+ * if present, or prompted for by the CLI if missing.
322
+ */
323
+ var IntParam = class extends Param {
324
+ static {
325
+ this.type = "int";
326
+ }
327
+ /** @internal */
328
+ runtimeValue() {
329
+ return parseInt(process.env[this.name] || "0", 10) || 0;
330
+ }
331
+ };
340
332
  /**
341
- * A parametrized value of Float type that will be read from .env files
342
- * if present, or prompted for by the CLI if missing.
343
- */
344
- class FloatParam extends Param {
345
- /** @internal */
346
- runtimeValue() {
347
- return parseFloat(process.env[this.name] || "0") || 0;
348
- }
349
- }
350
- exports.FloatParam = FloatParam;
351
- FloatParam.type = "float";
333
+ * A parametrized value of Float type that will be read from .env files
334
+ * if present, or prompted for by the CLI if missing.
335
+ */
336
+ var FloatParam = class extends Param {
337
+ static {
338
+ this.type = "float";
339
+ }
340
+ /** @internal */
341
+ runtimeValue() {
342
+ return parseFloat(process.env[this.name] || "0") || 0;
343
+ }
344
+ };
352
345
  /**
353
- * A parametrized value of Boolean type that will be read from .env files
354
- * if present, or prompted for by the CLI if missing.
355
- */
356
- class BooleanParam extends Param {
357
- /** @internal */
358
- runtimeValue() {
359
- return !!process.env[this.name] && process.env[this.name] === "true";
360
- }
361
- /** @deprecated */
362
- then(ifTrue, ifFalse) {
363
- return this.thenElse(ifTrue, ifFalse);
364
- }
365
- thenElse(ifTrue, ifFalse) {
366
- return new TernaryExpression(this, ifTrue, ifFalse);
367
- }
368
- }
369
- exports.BooleanParam = BooleanParam;
370
- BooleanParam.type = "boolean";
346
+ * A parametrized value of Boolean type that will be read from .env files
347
+ * if present, or prompted for by the CLI if missing.
348
+ */
349
+ var BooleanParam = class extends Param {
350
+ static {
351
+ this.type = "boolean";
352
+ }
353
+ /** @internal */
354
+ runtimeValue() {
355
+ return !!process.env[this.name] && process.env[this.name] === "true";
356
+ }
357
+ /** @deprecated */
358
+ then(ifTrue, ifFalse) {
359
+ return this.thenElse(ifTrue, ifFalse);
360
+ }
361
+ thenElse(ifTrue, ifFalse) {
362
+ return new TernaryExpression(this, ifTrue, ifFalse);
363
+ }
364
+ };
371
365
  /**
372
- * A parametrized value of String[] type that will be read from .env files
373
- * if present, or prompted for by the CLI if missing.
374
- */
375
- class ListParam extends Param {
376
- /** @internal */
377
- runtimeValue() {
378
- const val = JSON.parse(process.env[this.name]);
379
- if (!Array.isArray(val) || !val.every((v) => typeof v === "string")) {
380
- return [];
381
- }
382
- return val;
383
- }
384
- /** @hidden */
385
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
386
- greaterThan(rhs) {
387
- throw new Error(">/< comparison operators not supported on params of type List");
388
- }
389
- /** @hidden */
390
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
391
- greaterThanOrEqualTo(rhs) {
392
- throw new Error(">/< comparison operators not supported on params of type List");
393
- }
394
- /** @hidden */
395
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
396
- lessThan(rhs) {
397
- throw new Error(">/< comparison operators not supported on params of type List");
398
- }
399
- /** @hidden */
400
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
401
- lessThanorEqualTo(rhs) {
402
- throw new Error(">/< comparison operators not supported on params of type List");
403
- }
404
- }
366
+ * A parametrized value of String[] type that will be read from .env files
367
+ * if present, or prompted for by the CLI if missing.
368
+ */
369
+ var ListParam = class extends Param {
370
+ static {
371
+ this.type = "list";
372
+ }
373
+ /** @internal */
374
+ runtimeValue() {
375
+ const val = JSON.parse(process.env[this.name]);
376
+ if (!Array.isArray(val) || !val.every((v) => typeof v === "string")) {
377
+ return [];
378
+ }
379
+ return val;
380
+ }
381
+ /** @hidden */
382
+ greaterThan(rhs) {
383
+ throw new Error(">/< comparison operators not supported on params of type List");
384
+ }
385
+ /** @hidden */
386
+ greaterThanOrEqualTo(rhs) {
387
+ throw new Error(">/< comparison operators not supported on params of type List");
388
+ }
389
+ /** @hidden */
390
+ lessThan(rhs) {
391
+ throw new Error(">/< comparison operators not supported on params of type List");
392
+ }
393
+ /** @hidden */
394
+ lessThanorEqualTo(rhs) {
395
+ throw new Error(">/< comparison operators not supported on params of type List");
396
+ }
397
+ };
398
+
399
+ //#endregion
400
+ exports.BUCKET_PICKER = BUCKET_PICKER;
401
+ exports.BooleanParam = BooleanParam;
402
+ exports.CompareExpression = CompareExpression;
403
+ exports.Expression = Expression;
404
+ exports.FloatParam = FloatParam;
405
+ exports.IntParam = IntParam;
406
+ exports.InternalExpression = InternalExpression;
407
+ exports.JsonSecretParam = JsonSecretParam;
405
408
  exports.ListParam = ListParam;
406
- ListParam.type = "list";
409
+ exports.Param = Param;
410
+ exports.SecretParam = SecretParam;
411
+ exports.StringParam = StringParam;
412
+ exports.TernaryExpression = TernaryExpression;
413
+ exports.multiSelect = multiSelect;
414
+ exports.select = select;