firebase-functions 3.21.1 → 3.23.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.
- package/lib/bin/firebase-functions.js +2 -1
- package/lib/cloud-functions.d.ts +1 -48
- package/lib/cloud-functions.js +2 -59
- package/lib/common/change.d.ts +46 -0
- package/lib/common/change.js +82 -0
- package/lib/common/providers/database.d.ts +145 -0
- package/lib/common/providers/database.js +271 -0
- package/lib/common/providers/identity.js +12 -7
- package/lib/common/providers/tasks.d.ts +8 -7
- package/lib/common/providers/tasks.js +13 -12
- package/lib/common/timezone.d.ts +2 -0
- package/lib/common/timezone.js +543 -0
- package/lib/function-builder.d.ts +2 -2
- package/lib/function-builder.js +2 -2
- package/lib/function-configuration.d.ts +6 -5
- package/lib/providers/database.d.ts +4 -146
- package/lib/providers/database.js +7 -251
- package/lib/providers/firestore.d.ts +2 -1
- package/lib/providers/firestore.js +2 -1
- package/lib/runtime/loader.js +6 -1
- package/lib/runtime/manifest.d.ts +19 -16
- package/lib/runtime/manifest.js +24 -0
- package/lib/utilities/path-pattern.d.ts +1 -0
- package/lib/utilities/path-pattern.js +142 -0
- package/lib/v2/core.d.ts +2 -0
- package/lib/v2/core.js +7 -0
- package/lib/v2/index.d.ts +4 -1
- package/lib/v2/index.js +7 -1
- package/lib/v2/options.d.ts +16 -6
- package/lib/v2/options.js +2 -2
- package/lib/v2/params/index.d.ts +14 -12
- package/lib/v2/params/index.js +25 -15
- package/lib/v2/params/types.d.ts +97 -24
- package/lib/v2/params/types.js +127 -67
- package/lib/v2/providers/alerts/alerts.d.ts +7 -6
- package/lib/v2/providers/alerts/appDistribution.d.ts +50 -5
- package/lib/v2/providers/alerts/appDistribution.js +23 -1
- package/lib/v2/providers/alerts/crashlytics.d.ts +6 -5
- package/lib/v2/providers/database.d.ts +183 -0
- package/lib/v2/providers/database.js +204 -0
- package/lib/v2/providers/eventarc.d.ts +6 -5
- package/lib/v2/providers/https.d.ts +6 -5
- package/lib/v2/providers/identity.d.ts +8 -7
- package/lib/v2/providers/pubsub.d.ts +6 -5
- package/lib/v2/providers/scheduler.d.ts +63 -0
- package/lib/v2/providers/scheduler.js +98 -0
- package/lib/v2/providers/storage.d.ts +6 -5
- package/lib/v2/providers/tasks.d.ts +7 -6
- package/package.json +18 -8
package/lib/v2/params/types.js
CHANGED
|
@@ -21,90 +21,169 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.
|
|
25
|
-
|
|
24
|
+
exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.StringParam = exports.SecretParam = exports.Param = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
|
|
25
|
+
/*
|
|
26
|
+
* A CEL expression which can be evaluated during function deployment, and
|
|
27
|
+
* resolved to a value of the generic type parameter: i.e, you can pass
|
|
28
|
+
* an Expression<number> as the value of an option that normally accepts numbers.
|
|
29
|
+
*/
|
|
30
|
+
class Expression {
|
|
31
|
+
// Returns the Expression's runtime value, based on the CLI's resolution of params.
|
|
32
|
+
value() {
|
|
33
|
+
throw new Error('Not implemented');
|
|
34
|
+
}
|
|
35
|
+
// Returns the Expression's representation as a braced CEL expression.
|
|
36
|
+
toCEL() {
|
|
37
|
+
return `{{ ${this.toString()} }}`;
|
|
38
|
+
}
|
|
39
|
+
toJSON() {
|
|
40
|
+
return this.toString();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Expression = Expression;
|
|
44
|
+
function quoteIfString(literal) {
|
|
45
|
+
//TODO(vsfan@): CEL's string escape semantics are slightly different than Javascript's, what do we do here?
|
|
46
|
+
return typeof literal === 'string' ? `"${literal}"` : literal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
|
|
50
|
+
*/
|
|
51
|
+
class TernaryExpression 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
|
+
value() {
|
|
61
|
+
return !!this.test.value ? this.ifTrue : this.ifFalse;
|
|
62
|
+
}
|
|
63
|
+
toString() {
|
|
64
|
+
return `${this.test} ? ${quoteIfString(this.ifTrue)} : ${quoteIfString(this.ifFalse)}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.TernaryExpression = TernaryExpression;
|
|
68
|
+
/**
|
|
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
|
+
class CompareExpression extends Expression {
|
|
73
|
+
constructor(cmp, lhs, rhs) {
|
|
74
|
+
super();
|
|
75
|
+
this.cmp = cmp;
|
|
76
|
+
this.lhs = lhs;
|
|
77
|
+
this.rhs = rhs;
|
|
78
|
+
}
|
|
79
|
+
value() {
|
|
80
|
+
const left = this.lhs.value();
|
|
81
|
+
switch (this.cmp) {
|
|
82
|
+
case '==':
|
|
83
|
+
return left === this.rhs;
|
|
84
|
+
case '>':
|
|
85
|
+
return left > this.rhs;
|
|
86
|
+
case '>=':
|
|
87
|
+
return left >= this.rhs;
|
|
88
|
+
case '<':
|
|
89
|
+
return left < this.rhs;
|
|
90
|
+
case '<=':
|
|
91
|
+
return left <= this.rhs;
|
|
92
|
+
default:
|
|
93
|
+
throw new Error('Unknown comparator ' + this.cmp);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
toString() {
|
|
97
|
+
return `${this.lhs} ${this.cmp} ${quoteIfString(this.rhs)}`;
|
|
98
|
+
}
|
|
99
|
+
then(ifTrue, ifFalse) {
|
|
100
|
+
return new TernaryExpression(this, ifTrue, ifFalse);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.CompareExpression = CompareExpression;
|
|
104
|
+
class Param extends Expression {
|
|
26
105
|
constructor(name, options = {}) {
|
|
106
|
+
super();
|
|
27
107
|
this.name = name;
|
|
28
108
|
this.options = options;
|
|
29
109
|
}
|
|
30
|
-
|
|
31
|
-
|
|
110
|
+
value() {
|
|
111
|
+
throw new Error('Not implemented');
|
|
32
112
|
}
|
|
33
|
-
|
|
34
|
-
return
|
|
113
|
+
cmp(cmp, rhs) {
|
|
114
|
+
return new CompareExpression(cmp, this, rhs);
|
|
35
115
|
}
|
|
36
|
-
|
|
37
|
-
return
|
|
116
|
+
equals(rhs) {
|
|
117
|
+
return this.cmp('==', rhs);
|
|
38
118
|
}
|
|
39
|
-
|
|
40
|
-
return this.
|
|
119
|
+
toString() {
|
|
120
|
+
return `params.${this.name}`;
|
|
41
121
|
}
|
|
42
122
|
toSpec() {
|
|
43
|
-
var _a, _b;
|
|
44
123
|
const out = {
|
|
45
124
|
name: this.name,
|
|
46
125
|
...this.options,
|
|
47
|
-
|
|
126
|
+
type: this.constructor.type,
|
|
48
127
|
};
|
|
49
|
-
if (this.options.default && typeof this.options.default !== 'string') {
|
|
50
|
-
out.default = (_b = (_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
51
|
-
}
|
|
52
128
|
return out;
|
|
53
129
|
}
|
|
54
130
|
}
|
|
55
131
|
exports.Param = Param;
|
|
56
|
-
Param.
|
|
132
|
+
Param.type = 'string';
|
|
133
|
+
class SecretParam {
|
|
134
|
+
constructor(name) {
|
|
135
|
+
this.name = name;
|
|
136
|
+
}
|
|
137
|
+
value() {
|
|
138
|
+
return process.env[this.name] || '';
|
|
139
|
+
}
|
|
140
|
+
toSpec() {
|
|
141
|
+
return {
|
|
142
|
+
type: 'secret',
|
|
143
|
+
name: this.name,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.SecretParam = SecretParam;
|
|
148
|
+
SecretParam.type = 'secret';
|
|
57
149
|
class StringParam extends Param {
|
|
150
|
+
value() {
|
|
151
|
+
return process.env[this.name] || '';
|
|
152
|
+
}
|
|
58
153
|
}
|
|
59
154
|
exports.StringParam = StringParam;
|
|
60
155
|
class IntParam extends Param {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const intVal = parseInt(this.rawValue || ((_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString()) || '0', 10);
|
|
64
|
-
if (Number.isNaN(intVal)) {
|
|
65
|
-
throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as integer`);
|
|
66
|
-
}
|
|
67
|
-
return intVal;
|
|
156
|
+
value() {
|
|
157
|
+
return parseInt(process.env[this.name] || '0', 10) || 0;
|
|
68
158
|
}
|
|
69
159
|
}
|
|
70
160
|
exports.IntParam = IntParam;
|
|
71
|
-
IntParam.
|
|
161
|
+
IntParam.type = 'int';
|
|
72
162
|
class FloatParam extends Param {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const floatVal = parseFloat(this.rawValue || ((_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString()) || '0');
|
|
76
|
-
if (Number.isNaN(floatVal)) {
|
|
77
|
-
throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as float`);
|
|
78
|
-
}
|
|
79
|
-
return floatVal;
|
|
163
|
+
value() {
|
|
164
|
+
return parseFloat(process.env[this.name] || '0') || 0;
|
|
80
165
|
}
|
|
81
166
|
}
|
|
82
167
|
exports.FloatParam = FloatParam;
|
|
83
|
-
FloatParam.
|
|
168
|
+
FloatParam.type = 'float';
|
|
84
169
|
class BooleanParam extends Param {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!['true', 'y', 'yes', '1', 'false', 'n', 'no', '0'].includes(lowerVal)) {
|
|
91
|
-
throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as boolean`);
|
|
92
|
-
}
|
|
93
|
-
return ['true', 'y', 'yes', '1'].includes(lowerVal);
|
|
170
|
+
value() {
|
|
171
|
+
return !!process.env[this.name];
|
|
172
|
+
}
|
|
173
|
+
then(ifTrue, ifFalse) {
|
|
174
|
+
return new TernaryExpression(this, ifTrue, ifFalse);
|
|
94
175
|
}
|
|
95
176
|
}
|
|
96
177
|
exports.BooleanParam = BooleanParam;
|
|
97
|
-
BooleanParam.
|
|
178
|
+
BooleanParam.type = 'boolean';
|
|
98
179
|
class ListParam extends Param {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
? this.rawValue.split(/, ?/)
|
|
102
|
-
: this.options.default || [];
|
|
180
|
+
value() {
|
|
181
|
+
throw new Error('Not implemented');
|
|
103
182
|
}
|
|
104
183
|
toSpec() {
|
|
105
184
|
const out = {
|
|
106
185
|
name: this.name,
|
|
107
|
-
|
|
186
|
+
type: 'list',
|
|
108
187
|
...this.options,
|
|
109
188
|
};
|
|
110
189
|
if (this.options.default && this.options.default.length > 0) {
|
|
@@ -114,23 +193,4 @@ class ListParam extends Param {
|
|
|
114
193
|
}
|
|
115
194
|
}
|
|
116
195
|
exports.ListParam = ListParam;
|
|
117
|
-
ListParam.
|
|
118
|
-
class JSONParam extends Param {
|
|
119
|
-
get value() {
|
|
120
|
-
var _a;
|
|
121
|
-
if (this.rawValue) {
|
|
122
|
-
try {
|
|
123
|
-
return JSON.parse(this.rawValue);
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
throw new Error(`unable to load param "${this.name}", value ${this.rawValue} could not be parsed as JSON: ${e.message}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('default')) {
|
|
130
|
-
return this.options.default;
|
|
131
|
-
}
|
|
132
|
-
return {};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.JSONParam = JSONParam;
|
|
136
|
-
JSONParam.valueType = 'json';
|
|
196
|
+
ListParam.type = 'list';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CloudEvent, CloudFunction } from '../../core';
|
|
2
2
|
import * as options from '../../options';
|
|
3
|
+
import { Expression } from '../../params';
|
|
3
4
|
/**
|
|
4
5
|
* The CloudEvent data emitted by Firebase Alerts.
|
|
5
6
|
* @typeParam T - the payload type that is expected for this alert.
|
|
@@ -28,7 +29,7 @@ export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
|
|
28
29
|
data: FirebaseAlertData<T>;
|
|
29
30
|
}
|
|
30
31
|
/** The underlying alert type of the Firebase Alerts provider. */
|
|
31
|
-
export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | string;
|
|
32
|
+
export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | 'appDistribution.inAppFeedback' | string;
|
|
32
33
|
/**
|
|
33
34
|
* Configuration for Firebase Alert functions.
|
|
34
35
|
*/
|
|
@@ -45,7 +46,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
|
|
45
46
|
* Amount of memory to allocate to a function.
|
|
46
47
|
* A value of null restores the defaults of 256MB.
|
|
47
48
|
*/
|
|
48
|
-
memory?: options.MemoryOption | null;
|
|
49
|
+
memory?: options.MemoryOption | Expression<number> | null;
|
|
49
50
|
/**
|
|
50
51
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
51
52
|
* HTTPS functions can specify a higher timeout.
|
|
@@ -56,19 +57,19 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
|
|
56
57
|
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
57
58
|
* timeout of 1,800s (30 minutes)
|
|
58
59
|
*/
|
|
59
|
-
timeoutSeconds?: number | null;
|
|
60
|
+
timeoutSeconds?: number | Expression<number> | null;
|
|
60
61
|
/**
|
|
61
62
|
* Min number of actual instances to be running at a given time.
|
|
62
63
|
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
63
64
|
* while idle.
|
|
64
65
|
* A value of null restores the default min instances.
|
|
65
66
|
*/
|
|
66
|
-
minInstances?: number | null;
|
|
67
|
+
minInstances?: number | Expression<number> | null;
|
|
67
68
|
/**
|
|
68
69
|
* Max number of instances to be running in parallel.
|
|
69
70
|
* A value of null restores the default max instances.
|
|
70
71
|
*/
|
|
71
|
-
maxInstances?: number | null;
|
|
72
|
+
maxInstances?: number | Expression<number> | null;
|
|
72
73
|
/**
|
|
73
74
|
* Number of requests a function can serve at once.
|
|
74
75
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
@@ -76,7 +77,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
|
|
76
77
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
77
78
|
* The maximum value for concurrency is 1,000.
|
|
78
79
|
*/
|
|
79
|
-
concurrency?: number | null;
|
|
80
|
+
concurrency?: number | Expression<number> | null;
|
|
80
81
|
/**
|
|
81
82
|
* Fractional number of CPUs to allocate to a function.
|
|
82
83
|
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { CloudEvent, CloudFunction } from '../../core';
|
|
6
6
|
import * as options from '../../options';
|
|
7
7
|
import { FirebaseAlertData } from './alerts';
|
|
8
|
+
import { Expression } from '../../params';
|
|
8
9
|
/**
|
|
9
10
|
* The internal payload object for adding a new tester device to app distribution.
|
|
10
11
|
* Payload is wrapped inside a `FirebaseAlertData` object.
|
|
@@ -20,6 +21,30 @@ export interface NewTesterDevicePayload {
|
|
|
20
21
|
/** The device ID */
|
|
21
22
|
testerDeviceIdentifier: string;
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The internal payload object for receiving in-app feedback from a tester.
|
|
26
|
+
* Payload is wrapped inside a `FirebaseAlertData` object.
|
|
27
|
+
*/
|
|
28
|
+
export interface InAppFeedbackPayload {
|
|
29
|
+
['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroInAppFeedbackPayload';
|
|
30
|
+
/** Resource name. Format: `projects/{project_number}/apps/{app_id}/releases/{release_id}/feedbackReports/{feedback_id}` */
|
|
31
|
+
feedbackReport: string;
|
|
32
|
+
/** Deep link back to the Firebase console. */
|
|
33
|
+
feedbackConsoleUri: string;
|
|
34
|
+
/** Name of the tester */
|
|
35
|
+
testerName?: string;
|
|
36
|
+
/** Email of the tester */
|
|
37
|
+
testerEmail: string;
|
|
38
|
+
/**
|
|
39
|
+
* Version consisting of `versionName` and `versionCode` for Android and
|
|
40
|
+
* `CFBundleShortVersionString` and `CFBundleVersion` for iOS.
|
|
41
|
+
*/
|
|
42
|
+
appVersion: string;
|
|
43
|
+
/** Text entered by the tester */
|
|
44
|
+
text: string;
|
|
45
|
+
/** URI to download screenshot. This URI is fast expiring. */
|
|
46
|
+
screenshotUri?: string;
|
|
47
|
+
}
|
|
23
48
|
/**
|
|
24
49
|
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
|
25
50
|
* @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object.
|
|
@@ -44,7 +69,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
|
|
|
44
69
|
* Amount of memory to allocate to a function.
|
|
45
70
|
* A value of null restores the defaults of 256MB.
|
|
46
71
|
*/
|
|
47
|
-
memory?: options.MemoryOption | null;
|
|
72
|
+
memory?: options.MemoryOption | Expression<number> | null;
|
|
48
73
|
/**
|
|
49
74
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
50
75
|
* HTTPS functions can specify a higher timeout.
|
|
@@ -55,19 +80,19 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
|
|
|
55
80
|
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
56
81
|
* timeout of 1,800s (30 minutes)
|
|
57
82
|
*/
|
|
58
|
-
timeoutSeconds?: number | null;
|
|
83
|
+
timeoutSeconds?: number | Expression<number> | null;
|
|
59
84
|
/**
|
|
60
85
|
* Min number of actual instances to be running at a given time.
|
|
61
86
|
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
62
87
|
* while idle.
|
|
63
88
|
* A value of null restores the default min instances.
|
|
64
89
|
*/
|
|
65
|
-
minInstances?: number | null;
|
|
90
|
+
minInstances?: number | Expression<number> | null;
|
|
66
91
|
/**
|
|
67
92
|
* Max number of instances to be running in parallel.
|
|
68
93
|
* A value of null restores the default max instances.
|
|
69
94
|
*/
|
|
70
|
-
maxInstances?: number | null;
|
|
95
|
+
maxInstances?: number | Expression<number> | null;
|
|
71
96
|
/**
|
|
72
97
|
* Number of requests a function can serve at once.
|
|
73
98
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
@@ -75,7 +100,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
|
|
|
75
100
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
76
101
|
* The maximum value for concurrency is 1,000.
|
|
77
102
|
*/
|
|
78
|
-
concurrency?: number | null;
|
|
103
|
+
concurrency?: number | Expression<number> | null;
|
|
79
104
|
/**
|
|
80
105
|
* Fractional number of CPUs to allocate to a function.
|
|
81
106
|
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
@@ -133,3 +158,23 @@ export declare function onNewTesterIosDevicePublished(appId: string, handler: (e
|
|
|
133
158
|
* @returns A function that you can export and deploy.
|
|
134
159
|
*/
|
|
135
160
|
export declare function onNewTesterIosDevicePublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
|
|
161
|
+
/**
|
|
162
|
+
* Declares a function that can handle receiving new in-app feedback from a tester.
|
|
163
|
+
* @param handler - Event handler which is run every time new feedback is received.
|
|
164
|
+
* @returns A function that you can export and deploy.
|
|
165
|
+
*/
|
|
166
|
+
export declare function onInAppFeedbackPublished(handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
|
167
|
+
/**
|
|
168
|
+
* Declares a function that can handle receiving new in-app feedback from a tester.
|
|
169
|
+
* @param appId - A specific application the handler will trigger on.
|
|
170
|
+
* @param handler - Event handler which is run every time new feedback is received.
|
|
171
|
+
* @returns A function that you can export and deploy.
|
|
172
|
+
*/
|
|
173
|
+
export declare function onInAppFeedbackPublished(appId: string, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
|
174
|
+
/**
|
|
175
|
+
* Declares a function that can handle receiving new in-app feedback from a tester.
|
|
176
|
+
* @param opts - Options that can be set on the function.
|
|
177
|
+
* @param handler - Event handler which is run every time new feedback is received.
|
|
178
|
+
* @returns A function that you can export and deploy.
|
|
179
|
+
*/
|
|
180
|
+
export declare function onInAppFeedbackPublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
|
@@ -21,10 +21,12 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.getOptsAndApp = exports.onNewTesterIosDevicePublished = exports.newTesterIosDeviceAlert = void 0;
|
|
24
|
+
exports.getOptsAndApp = exports.onInAppFeedbackPublished = exports.onNewTesterIosDevicePublished = exports.inAppFeedbackAlert = exports.newTesterIosDeviceAlert = void 0;
|
|
25
25
|
const alerts_1 = require("./alerts");
|
|
26
26
|
/** @internal */
|
|
27
27
|
exports.newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice';
|
|
28
|
+
/** @internal */
|
|
29
|
+
exports.inAppFeedbackAlert = 'appDistribution.inAppFeedback';
|
|
28
30
|
/**
|
|
29
31
|
* Declares a function that can handle adding a new tester iOS device.
|
|
30
32
|
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
@@ -45,6 +47,26 @@ function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
|
|
|
45
47
|
return func;
|
|
46
48
|
}
|
|
47
49
|
exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
|
|
50
|
+
/**
|
|
51
|
+
* Declares a function that can handle receiving new in-app feedback from a tester.
|
|
52
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
53
|
+
* @param handler - Event handler which is run every time new feedback is received.
|
|
54
|
+
* @returns A function that you can export and deploy.
|
|
55
|
+
*/
|
|
56
|
+
function onInAppFeedbackPublished(appIdOrOptsOrHandler, handler) {
|
|
57
|
+
if (typeof appIdOrOptsOrHandler === 'function') {
|
|
58
|
+
handler = appIdOrOptsOrHandler;
|
|
59
|
+
appIdOrOptsOrHandler = {};
|
|
60
|
+
}
|
|
61
|
+
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
|
62
|
+
const func = (raw) => {
|
|
63
|
+
return handler(raw);
|
|
64
|
+
};
|
|
65
|
+
func.run = handler;
|
|
66
|
+
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.inAppFeedbackAlert, appId);
|
|
67
|
+
return func;
|
|
68
|
+
}
|
|
69
|
+
exports.onInAppFeedbackPublished = onInAppFeedbackPublished;
|
|
48
70
|
/**
|
|
49
71
|
* Helper function to parse the function opts and appId.
|
|
50
72
|
* @internal
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { FirebaseAlertData } from '.';
|
|
6
6
|
import { CloudEvent, CloudFunction } from '../../core';
|
|
7
7
|
import * as options from '../../options';
|
|
8
|
+
import { Expression } from '../../params';
|
|
8
9
|
/** Generic Crashlytics issue interface */
|
|
9
10
|
export interface Issue {
|
|
10
11
|
/** The ID of the Crashlytics issue */
|
|
@@ -134,7 +135,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
|
|
|
134
135
|
* Amount of memory to allocate to a function.
|
|
135
136
|
* A value of null restores the defaults of 256MB.
|
|
136
137
|
*/
|
|
137
|
-
memory?: options.MemoryOption | null;
|
|
138
|
+
memory?: options.MemoryOption | Expression<number> | null;
|
|
138
139
|
/**
|
|
139
140
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
140
141
|
* HTTPS functions can specify a higher timeout.
|
|
@@ -145,19 +146,19 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
|
|
|
145
146
|
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
146
147
|
* timeout of 1,800s (30 minutes)
|
|
147
148
|
*/
|
|
148
|
-
timeoutSeconds?: number | null;
|
|
149
|
+
timeoutSeconds?: number | Expression<number> | null;
|
|
149
150
|
/**
|
|
150
151
|
* Min number of actual instances to be running at a given time.
|
|
151
152
|
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
152
153
|
* while idle.
|
|
153
154
|
* A value of null restores the default min instances.
|
|
154
155
|
*/
|
|
155
|
-
minInstances?: number | null;
|
|
156
|
+
minInstances?: number | Expression<number> | null;
|
|
156
157
|
/**
|
|
157
158
|
* Max number of instances to be running in parallel.
|
|
158
159
|
* A value of null restores the default max instances.
|
|
159
160
|
*/
|
|
160
|
-
maxInstances?: number | null;
|
|
161
|
+
maxInstances?: number | Expression<number> | null;
|
|
161
162
|
/**
|
|
162
163
|
* Number of requests a function can serve at once.
|
|
163
164
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
@@ -165,7 +166,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
|
|
|
165
166
|
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
166
167
|
* The maximum value for concurrency is 1,000.
|
|
167
168
|
*/
|
|
168
|
-
concurrency?: number | null;
|
|
169
|
+
concurrency?: number | Expression<number> | null;
|
|
169
170
|
/**
|
|
170
171
|
* Fractional number of CPUs to allocate to a function.
|
|
171
172
|
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Change } from '../../common/change';
|
|
2
|
+
import { DataSnapshot } from '../../common/providers/database';
|
|
3
|
+
import { CloudEvent, CloudFunction } from '../core';
|
|
4
|
+
import * as options from '../options';
|
|
5
|
+
import { Expression } from '../params';
|
|
6
|
+
export { DataSnapshot };
|
|
7
|
+
/** @hidden */
|
|
8
|
+
export interface RawRTDBCloudEventData {
|
|
9
|
+
['@type']: 'type.googleapis.com/google.events.firebase.database.v1.ReferenceEventData';
|
|
10
|
+
data: any;
|
|
11
|
+
delta: any;
|
|
12
|
+
}
|
|
13
|
+
/** @hidden */
|
|
14
|
+
export interface RawRTDBCloudEvent extends CloudEvent<RawRTDBCloudEventData> {
|
|
15
|
+
firebasedatabasehost: string;
|
|
16
|
+
instance: string;
|
|
17
|
+
ref: string;
|
|
18
|
+
location: string;
|
|
19
|
+
}
|
|
20
|
+
/** A CloudEvent that contains a DataSnapshot or a Change<DataSnapshot> */
|
|
21
|
+
export interface DatabaseEvent<T> extends CloudEvent<T> {
|
|
22
|
+
/** The domain of the database instance */
|
|
23
|
+
firebaseDatabaseHost: string;
|
|
24
|
+
/** The instance ID portion of the fully qualified resource name */
|
|
25
|
+
instance: string;
|
|
26
|
+
/** The database reference path */
|
|
27
|
+
ref: string;
|
|
28
|
+
/** The location of the database */
|
|
29
|
+
location: string;
|
|
30
|
+
/**
|
|
31
|
+
* An object containing the values of the path patterns.
|
|
32
|
+
* Only named capture groups will be populated - {key}, {key=*}, {key=**}
|
|
33
|
+
*/
|
|
34
|
+
params: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
/** ReferenceOptions extend EventHandlerOptions with provided ref and optional instance */
|
|
37
|
+
export interface ReferenceOptions extends options.EventHandlerOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Specify the handler to trigger on a database reference(s).
|
|
40
|
+
* This value can either be a single reference or a pattern.
|
|
41
|
+
* Examples: '/foo/bar', '/foo/{bar}'
|
|
42
|
+
*/
|
|
43
|
+
ref: string;
|
|
44
|
+
/**
|
|
45
|
+
* Specify the handler to trigger on a database instance(s).
|
|
46
|
+
* If present, this value can either be a single instance or a pattern.
|
|
47
|
+
* Examples: 'my-instance-1', 'my-instance-*'
|
|
48
|
+
* Note: The capture syntax cannot be used for 'instance'.
|
|
49
|
+
*/
|
|
50
|
+
instance?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Region where functions should be deployed.
|
|
53
|
+
*/
|
|
54
|
+
region?: options.SupportedRegion | string;
|
|
55
|
+
/**
|
|
56
|
+
* Amount of memory to allocate to a function.
|
|
57
|
+
* A value of null restores the defaults of 256MB.
|
|
58
|
+
*/
|
|
59
|
+
memory?: options.MemoryOption | Expression<number> | null;
|
|
60
|
+
/**
|
|
61
|
+
* Timeout for the function in sections, possible values are 0 to 540.
|
|
62
|
+
* HTTPS functions can specify a higher timeout.
|
|
63
|
+
* A value of null restores the default of 60s
|
|
64
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
65
|
+
* function depends on the type of function: Event handling functions have a
|
|
66
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
67
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
68
|
+
* timeout of 1,800s (30 minutes)
|
|
69
|
+
*/
|
|
70
|
+
timeoutSeconds?: number | Expression<number> | null;
|
|
71
|
+
/**
|
|
72
|
+
* Min number of actual instances to be running at a given time.
|
|
73
|
+
* Instances will be billed for memory allocation and 10% of CPU allocation
|
|
74
|
+
* while idle.
|
|
75
|
+
* A value of null restores the default min instances.
|
|
76
|
+
*/
|
|
77
|
+
minInstances?: number | Expression<number> | null;
|
|
78
|
+
/**
|
|
79
|
+
* Max number of instances to be running in parallel.
|
|
80
|
+
* A value of null restores the default max instances.
|
|
81
|
+
*/
|
|
82
|
+
maxInstances?: number | Expression<number> | null;
|
|
83
|
+
/**
|
|
84
|
+
* Number of requests a function can serve at once.
|
|
85
|
+
* Can only be applied to functions running on Cloud Functions v2.
|
|
86
|
+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
87
|
+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
88
|
+
* The maximum value for concurrency is 1,000.
|
|
89
|
+
*/
|
|
90
|
+
concurrency?: number | Expression<number> | null;
|
|
91
|
+
/**
|
|
92
|
+
* Fractional number of CPUs to allocate to a function.
|
|
93
|
+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
94
|
+
* This is different from the defaults when using the gcloud utility and is different from
|
|
95
|
+
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
96
|
+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
97
|
+
* to the value "gcf_gen1"
|
|
98
|
+
*/
|
|
99
|
+
cpu?: number | 'gcf_gen1';
|
|
100
|
+
/**
|
|
101
|
+
* Connect cloud function to specified VPC connector.
|
|
102
|
+
* A value of null removes the VPC connector
|
|
103
|
+
*/
|
|
104
|
+
vpcConnector?: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Egress settings for VPC connector.
|
|
107
|
+
* A value of null turns off VPC connector egress settings
|
|
108
|
+
*/
|
|
109
|
+
vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
|
|
110
|
+
/**
|
|
111
|
+
* Specific service account for the function to run as.
|
|
112
|
+
* A value of null restores the default service account.
|
|
113
|
+
*/
|
|
114
|
+
serviceAccount?: string | null;
|
|
115
|
+
/**
|
|
116
|
+
* Ingress settings which control where this function can be called from.
|
|
117
|
+
* A value of null turns off ingress settings.
|
|
118
|
+
*/
|
|
119
|
+
ingressSettings?: options.IngressSetting | null;
|
|
120
|
+
/**
|
|
121
|
+
* User labels to set on the function.
|
|
122
|
+
*/
|
|
123
|
+
labels?: Record<string, string>;
|
|
124
|
+
secrets?: string[];
|
|
125
|
+
/** Whether failed executions should be delivered again. */
|
|
126
|
+
retry?: boolean | Expression<boolean> | null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
|
130
|
+
*
|
|
131
|
+
* @param reference - The database reference path to trigger on.
|
|
132
|
+
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
|
133
|
+
*/
|
|
134
|
+
export declare function onValueWritten(reference: string, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
|
|
135
|
+
/**
|
|
136
|
+
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
|
137
|
+
*
|
|
138
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
139
|
+
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
|
140
|
+
*/
|
|
141
|
+
export declare function onValueWritten(opts: ReferenceOptions, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
|
|
142
|
+
/**
|
|
143
|
+
* Event handler which triggers when data is created in Realtime Database.
|
|
144
|
+
*
|
|
145
|
+
* @param reference - The database reference path to trigger on.
|
|
146
|
+
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
|
147
|
+
*/
|
|
148
|
+
export declare function onValueCreated(reference: string, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
|
|
149
|
+
/**
|
|
150
|
+
* Event handler which triggers when data is created in Realtime Database.
|
|
151
|
+
*
|
|
152
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
153
|
+
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
|
154
|
+
*/
|
|
155
|
+
export declare function onValueCreated(opts: ReferenceOptions, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
|
|
156
|
+
/**
|
|
157
|
+
* Event handler which triggers when data is updated in Realtime Database.
|
|
158
|
+
*
|
|
159
|
+
* @param reference - The database reference path to trigger on.
|
|
160
|
+
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
|
161
|
+
*/
|
|
162
|
+
export declare function onValueUpdated(reference: string, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
|
|
163
|
+
/**
|
|
164
|
+
* Event handler which triggers when data is updated in Realtime Database.
|
|
165
|
+
*
|
|
166
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
167
|
+
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
|
168
|
+
*/
|
|
169
|
+
export declare function onValueUpdated(opts: ReferenceOptions, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
|
|
170
|
+
/**
|
|
171
|
+
* Event handler which triggers when data is deleted in Realtime Database.
|
|
172
|
+
*
|
|
173
|
+
* @param reference - The database reference path to trigger on.
|
|
174
|
+
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
|
175
|
+
*/
|
|
176
|
+
export declare function onValueDeleted(reference: string, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
|
|
177
|
+
/**
|
|
178
|
+
* Event handler which triggers when data is deleted in Realtime Database.
|
|
179
|
+
*
|
|
180
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
181
|
+
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
|
182
|
+
*/
|
|
183
|
+
export declare function onValueDeleted(opts: ReferenceOptions, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
|