firebase-functions 6.6.0 → 7.0.0-rc.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.
- package/lib/_virtual/rolldown_runtime.js +34 -0
- package/lib/bin/firebase-functions.js +78 -103
- package/lib/common/app.js +35 -55
- package/lib/common/change.js +54 -75
- package/lib/common/config.js +41 -41
- package/lib/common/debug.js +23 -47
- package/lib/common/encoding.js +59 -82
- package/lib/common/onInit.js +26 -28
- package/lib/common/options.js +22 -42
- package/lib/common/params.d.ts +6 -6
- package/lib/common/params.js +0 -23
- package/lib/common/providers/database.js +270 -300
- package/lib/common/providers/firestore.js +66 -92
- package/lib/common/providers/https.d.ts +0 -1
- package/lib/common/providers/https.js +537 -539
- package/lib/common/providers/identity.js +393 -444
- package/lib/common/providers/tasks.js +64 -98
- package/lib/common/timezone.js +544 -542
- package/lib/common/trace.d.ts +0 -1
- package/lib/common/trace.js +63 -55
- package/lib/common/utilities/assertions.d.ts +11 -0
- package/lib/common/utilities/assertions.js +18 -0
- package/lib/common/utilities/encoder.js +20 -37
- package/lib/common/utilities/path-pattern.js +106 -132
- package/lib/common/utilities/path.js +28 -27
- package/lib/common/utilities/utils.js +23 -45
- package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
- package/lib/esm/bin/firebase-functions.mjs +91 -0
- package/lib/esm/common/app.mjs +39 -0
- package/lib/esm/common/change.mjs +57 -0
- package/lib/esm/common/config.mjs +45 -0
- package/lib/esm/common/debug.mjs +28 -0
- package/lib/esm/common/encoding.mjs +69 -0
- package/lib/esm/common/onInit.mjs +33 -0
- package/lib/esm/common/options.mjs +22 -0
- package/lib/esm/common/params.mjs +1 -0
- package/lib/esm/common/providers/database.mjs +269 -0
- package/lib/esm/common/providers/firestore.mjs +78 -0
- package/lib/esm/common/providers/https.mjs +573 -0
- package/lib/esm/common/providers/identity.mjs +428 -0
- package/lib/esm/common/providers/tasks.mjs +67 -0
- package/lib/esm/common/timezone.mjs +544 -0
- package/lib/esm/common/trace.mjs +73 -0
- package/lib/esm/common/utilities/assertions.mjs +17 -0
- package/lib/esm/common/utilities/encoder.mjs +21 -0
- package/lib/esm/common/utilities/path-pattern.mjs +116 -0
- package/lib/esm/common/utilities/path.mjs +35 -0
- package/lib/esm/common/utilities/utils.mjs +29 -0
- package/lib/esm/function-configuration.mjs +1 -0
- package/lib/esm/logger/common.mjs +23 -0
- package/lib/esm/logger/compat.mjs +25 -0
- package/lib/esm/logger/index.mjs +131 -0
- package/lib/esm/params/index.mjs +160 -0
- package/lib/esm/params/types.mjs +400 -0
- package/lib/esm/runtime/loader.mjs +132 -0
- package/lib/esm/runtime/manifest.mjs +134 -0
- package/lib/esm/types/global.d.mjs +1 -0
- package/lib/esm/v1/cloud-functions.mjs +206 -0
- package/lib/esm/v1/config.mjs +14 -0
- package/lib/esm/v1/function-builder.mjs +252 -0
- package/lib/esm/v1/function-configuration.mjs +72 -0
- package/lib/esm/v1/index.mjs +27 -0
- package/lib/esm/v1/providers/analytics.mjs +212 -0
- package/lib/esm/v1/providers/auth.mjs +156 -0
- package/lib/esm/v1/providers/database.mjs +243 -0
- package/lib/esm/v1/providers/firestore.mjs +131 -0
- package/lib/esm/v1/providers/https.mjs +82 -0
- package/lib/esm/v1/providers/pubsub.mjs +175 -0
- package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
- package/lib/esm/v1/providers/storage.mjs +163 -0
- package/lib/esm/v1/providers/tasks.mjs +63 -0
- package/lib/esm/v1/providers/testLab.mjs +94 -0
- package/lib/esm/v2/core.mjs +4 -0
- package/lib/esm/v2/index.mjs +28 -0
- package/lib/esm/v2/options.mjs +102 -0
- package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
- package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
- package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
- package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
- package/lib/esm/v2/providers/alerts/index.mjs +22 -0
- package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
- package/lib/esm/v2/providers/database.mjs +197 -0
- package/lib/esm/v2/providers/dataconnect.mjs +130 -0
- package/lib/esm/v2/providers/eventarc.mjs +51 -0
- package/lib/esm/v2/providers/firestore.mjs +294 -0
- package/lib/esm/v2/providers/https.mjs +210 -0
- package/lib/esm/v2/providers/identity.mjs +103 -0
- package/lib/esm/v2/providers/pubsub.mjs +148 -0
- package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
- package/lib/esm/v2/providers/scheduler.mjs +84 -0
- package/lib/esm/v2/providers/storage.mjs +155 -0
- package/lib/esm/v2/providers/tasks.mjs +65 -0
- package/lib/esm/v2/providers/testLab.mjs +53 -0
- package/lib/esm/v2/trace.mjs +20 -0
- package/lib/function-configuration.d.ts +0 -0
- package/lib/function-configuration.js +0 -0
- package/lib/logger/common.js +21 -41
- package/lib/logger/compat.js +18 -33
- package/lib/logger/index.js +119 -130
- package/lib/params/index.d.ts +4 -2
- package/lib/params/index.js +150 -144
- package/lib/params/types.js +389 -423
- package/lib/runtime/loader.js +114 -148
- package/lib/runtime/manifest.js +106 -126
- package/lib/types/global.d.js +0 -0
- package/lib/v1/cloud-functions.d.ts +2 -2
- package/lib/v1/cloud-functions.js +193 -241
- package/lib/v1/config.d.ts +4 -7
- package/lib/v1/config.js +13 -75
- package/lib/v1/function-builder.js +239 -368
- package/lib/v1/function-configuration.js +70 -63
- package/lib/v1/index.js +118 -73
- package/lib/v1/providers/analytics.js +188 -235
- package/lib/v1/providers/auth.d.ts +2 -1
- package/lib/v1/providers/auth.js +159 -164
- package/lib/v1/providers/database.js +237 -242
- package/lib/v1/providers/firestore.js +131 -130
- package/lib/v1/providers/https.d.ts +2 -1
- package/lib/v1/providers/https.js +79 -86
- package/lib/v1/providers/pubsub.js +175 -172
- package/lib/v1/providers/remoteConfig.js +64 -68
- package/lib/v1/providers/storage.js +161 -163
- package/lib/v1/providers/tasks.d.ts +1 -1
- package/lib/v1/providers/tasks.js +65 -80
- package/lib/v1/providers/testLab.js +94 -94
- package/lib/v2/core.d.ts +1 -1
- package/lib/v2/core.js +5 -32
- package/lib/v2/index.d.ts +6 -3
- package/lib/v2/index.js +123 -75
- package/lib/v2/options.js +88 -114
- package/lib/v2/providers/alerts/alerts.js +76 -95
- package/lib/v2/providers/alerts/appDistribution.js +73 -78
- package/lib/v2/providers/alerts/billing.js +49 -53
- package/lib/v2/providers/alerts/crashlytics.js +110 -102
- package/lib/v2/providers/alerts/index.js +56 -53
- package/lib/v2/providers/alerts/performance.js +64 -74
- package/lib/v2/providers/database.js +177 -180
- package/lib/v2/providers/dataconnect.d.ts +95 -0
- package/lib/v2/providers/dataconnect.js +137 -0
- package/lib/v2/providers/eventarc.js +55 -77
- package/lib/v2/providers/firestore.js +262 -260
- package/lib/v2/providers/https.d.ts +3 -2
- package/lib/v2/providers/https.js +210 -247
- package/lib/v2/providers/identity.d.ts +2 -1
- package/lib/v2/providers/identity.js +96 -105
- package/lib/v2/providers/pubsub.js +149 -167
- package/lib/v2/providers/remoteConfig.js +54 -63
- package/lib/v2/providers/scheduler.js +84 -96
- package/lib/v2/providers/storage.js +147 -162
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/lib/v2/providers/tasks.js +68 -95
- package/lib/v2/providers/testLab.js +55 -64
- package/lib/v2/trace.js +18 -19
- package/package.json +321 -88
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
package/lib/params/types.js
CHANGED
|
@@ -1,448 +1,414 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
+
return arg instanceof Expression ? arg.runtimeValue() : arg;
|
|
57
29
|
}
|
|
58
30
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
/** @internal */
|
|
308
|
-
runtimeValue() {
|
|
309
|
-
const val = process.env[this.name];
|
|
310
|
-
if (val === undefined) {
|
|
311
|
-
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.`);
|
|
312
|
-
}
|
|
313
|
-
try {
|
|
314
|
-
return JSON.parse(val);
|
|
315
|
-
}
|
|
316
|
-
catch (error) {
|
|
317
|
-
throw new Error(`"${this.name}" could not be parsed as JSON. Please verify its value in Secret Manager. Details: ${error}`);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/** @internal */
|
|
321
|
-
toSpec() {
|
|
322
|
-
return {
|
|
323
|
-
type: "secret",
|
|
324
|
-
name: this.name,
|
|
325
|
-
format: "json",
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
/** 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. */
|
|
329
|
-
value() {
|
|
330
|
-
if (process.env.FUNCTIONS_CONTROL_API === "true") {
|
|
331
|
-
throw new Error(`Cannot access the value of secret "${this.name}" during function deployment. Secret values are only available at runtime.`);
|
|
332
|
-
}
|
|
333
|
-
return this.runtimeValue();
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
exports.JsonSecretParam = JsonSecretParam;
|
|
337
|
-
JsonSecretParam.type = "secret";
|
|
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
|
+
};
|
|
338
299
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
+
};
|
|
349
319
|
/**
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
runtimeValue() {
|
|
363
|
-
return this.getter(process.env) || "";
|
|
364
|
-
}
|
|
365
|
-
toSpec() {
|
|
366
|
-
throw new Error("An InternalExpression should never be marshalled for wire transmission.");
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
exports.InternalExpression = InternalExpression;
|
|
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
|
+
};
|
|
370
332
|
/**
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
class
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
};
|
|
382
345
|
/**
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
class
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
+
};
|
|
394
365
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
class
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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;
|
|
411
401
|
exports.BooleanParam = BooleanParam;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
/** @internal */
|
|
419
|
-
runtimeValue() {
|
|
420
|
-
const val = JSON.parse(process.env[this.name]);
|
|
421
|
-
if (!Array.isArray(val) || !val.every((v) => typeof v === "string")) {
|
|
422
|
-
return [];
|
|
423
|
-
}
|
|
424
|
-
return val;
|
|
425
|
-
}
|
|
426
|
-
/** @hidden */
|
|
427
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
428
|
-
greaterThan(rhs) {
|
|
429
|
-
throw new Error(">/< comparison operators not supported on params of type List");
|
|
430
|
-
}
|
|
431
|
-
/** @hidden */
|
|
432
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
433
|
-
greaterThanOrEqualTo(rhs) {
|
|
434
|
-
throw new Error(">/< comparison operators not supported on params of type List");
|
|
435
|
-
}
|
|
436
|
-
/** @hidden */
|
|
437
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
438
|
-
lessThan(rhs) {
|
|
439
|
-
throw new Error(">/< comparison operators not supported on params of type List");
|
|
440
|
-
}
|
|
441
|
-
/** @hidden */
|
|
442
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
443
|
-
lessThanorEqualTo(rhs) {
|
|
444
|
-
throw new Error(">/< comparison operators not supported on params of type List");
|
|
445
|
-
}
|
|
446
|
-
}
|
|
402
|
+
exports.CompareExpression = CompareExpression;
|
|
403
|
+
exports.Expression = Expression;
|
|
404
|
+
exports.FloatParam = FloatParam;
|
|
405
|
+
exports.IntParam = IntParam;
|
|
406
|
+
exports.InternalExpression = InternalExpression;
|
|
407
|
+
exports.JsonSecretParam = JsonSecretParam;
|
|
447
408
|
exports.ListParam = ListParam;
|
|
448
|
-
|
|
409
|
+
exports.Param = Param;
|
|
410
|
+
exports.SecretParam = SecretParam;
|
|
411
|
+
exports.StringParam = StringParam;
|
|
412
|
+
exports.TernaryExpression = TernaryExpression;
|
|
413
|
+
exports.multiSelect = multiSelect;
|
|
414
|
+
exports.select = select;
|